/* Stored procedures */


SET TERM ^ ;


CREATE OR ALTER PROCEDURE BUILD_FIO (
  I$F VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$I VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$O VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  FULL_NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE DATE2ISO (
  D TIMESTAMP, 
  FULL_TIME SMALLINT = 1)
RETURNS (
  VAL VARCHAR(64) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE EXPLODE_STR (
  S VARCHAR(4000) CHARACTER SET UTF8 COLLATE UTF8, 
  DELIM VARCHAR(1) CHARACTER SET UTF8 COLLATE UTF8 = ';')
RETURNS (
  ID VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  V VARCHAR(1000) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE IMPORT_LISTVALS
AS
BEGIN

END
^

CREATE OR ALTER PROCEDURE SDOCS_ADD_NUMS (
  I$BLANK_ID BIGINT, 
  I$DOC_ID BIGINT)
RETURNS (
  ADD_NUMS VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_APPLY_NUMBERS (
  I$ORDER VARCHAR(8000) CHARACTER SET UTF8 COLLATE UTF8, 
  I$STAGE_ID BIGINT, 
  I$DATE DATE)
RETURNS (
  CNT INTEGER)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANKS_ENUM (
  I$TYPE_ID BIGINT, 
  I$USED_FL SMALLINT = 0)
RETURNS (
  SERIE VARCHAR(10) CHARACTER SET UTF8 COLLATE UTF8, 
  NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  STATE SMALLINT, 
  SUBTYPE_ID SMALLINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_APPLY (
  I$OBJ_ID BIGINT, 
  I$SERIE VARCHAR(10) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_LAST VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_FIRST VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_MID VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$USE_DATE DATE, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  BLANK_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_DISCARD (
  I$OBJ_ID BIGINT, 
  I$BLANK_ID BIGINT, 
  I$ACTION SMALLINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  DOC_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_DROP (
  I$BP_ID BIGINT, 
  I$FROM BIGINT, 
  I$TO BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_GET (
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  TAG_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  VAL VARCHAR(1000) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_MASK (
  I$OBJ_ID BIGINT NOT NULL, 
  I$PAGE INTEGER, 
  I$MARKS_ALL SMALLINT, 
  I$BLANKS VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  STATE_ID BIGINT, 
  ADD_NUMS VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_REVERT (
  I$BP_ID BIGINT, 
  I$NUM BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_SET (
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$OU_ID BIGINT, 
  I$ACCEPT_DATE DATE, 
  I$ACCEPT_FROM VARCHAR(1000) CHARACTER SET UTF8 COLLATE UTF8, 
  I$SERIE VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NUM_FROM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NUM_TO VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$TYPE_ID BIGINT, 
  I$SUBTYPE_ID BIGINT, 
  I$COMMENTS VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  OBJ_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_CLASS_INFO (
  I$PERSON_ID BIGINT, 
  I$DATE DATE)
RETURNS (
  RUK_NAME VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_CLOSE_YEAR (
  I$STAGE_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

END
^

CREATE OR ALTER PROCEDURE SDOCS_COPY_TEMPLATE (
  I$OBJ_ID BIGINT, 
  I$OU_ID BIGINT, 
  I$NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  OBJ_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DELETE_BLANK (
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

END
^

CREATE OR ALTER PROCEDURE SDOCS_DELETE_DOC (
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  OBJ_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DELETE_TEMPLATE (
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  OBJ_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_DUB (
  I$PERSON_ID BIGINT, 
  I$DOC_TYPE_ID BIGINT, 
  I$ORDER_ID BIGINT, 
  I$PARENT_ID BIGINT, 
  I$PREV_NUM VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$PREV_DATE DATE, 
  I$NAME_LAST VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_FIRST VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_MID VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$BIRTH_DATE DATE, 
  I$GRAD_YEAR INTEGER, 
  I$YEAR_ID BIGINT, 
  I$DUB_STATE SMALLINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  TAG_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  VAL VARCHAR(8000) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_GET (
  I$PERSON_ID BIGINT, 
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  TAG_NAME VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  VAL VARCHAR(8000) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_GN (
  I$PERSON_ID BIGINT, 
  I$NAME_LAST VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_FIRST VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_MID VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$BIRTH_DATE DATE, 
  I$GRAD_YEAR INTEGER, 
  I$YEAR_ID BIGINT, 
  I$ACTION_DATE DATE, 
  I$REF_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  TAG_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  VAL VARCHAR(8000) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_SET (
  I$OBJ_ID BIGINT, 
  I$OU_ID INTEGER, 
  I$YEAR_ID BIGINT, 
  I$ORDER_ID BIGINT, 
  I$PERSON_ID BIGINT NOT NULL, 
  I$NAME_LAST VARCHAR(200) CHARACTER SET UTF8 NOT NULL COLLATE UTF8, 
  I$NAME_FIRST VARCHAR(200) CHARACTER SET UTF8 NOT NULL COLLATE UTF8, 
  I$NAME_MID VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$BIRTH_DATE DATE NOT NULL, 
  I$DOC_TYPE_ID BIGINT NOT NULL, 
  I$BP_ID BIGINT, 
  I$BLANK_NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$FORMAT_ID BIGINT, 
  I$GRAD_YEAR SMALLINT, 
  I$DATA VARCHAR(8000) CHARACTER SET UTF8 COLLATE UTF8, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$REF_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8 = null, 
  I$ACTION_DATE DATE = null, 
  I$REG_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8 = null)
RETURNS (
  OBJ_ID BIGINT, 
  BLANK_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_SET_SPO (
  I$DOC_ID BIGINT, 
  I$PROF VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$SPEC VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$OP_DUR VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$QUAL VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$UO VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$PREV_DOC VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$GAK_DATE DATE, 
  I$GAK_FIO VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$DPLDATA VARCHAR(4000) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

END
^

CREATE OR ALTER PROCEDURE SDOCS_DUB_DATA (
  I$ORDER_ID BIGINT, 
  I$PERSON_ID BIGINT)
RETURNS (
  PREV_FIO VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_BD DATE, 
  NEW_FIO VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  NEW_BD DATE, 
  GRAD_YEAR INTEGER, 
  PREV_DATE DATE, 
  PREV_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  BLANK_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_EXPORT_FRDO (
  I$YEAR_ID BIGINT, 
  I$STAGE_ID BIGINT, 
  I$VALID INTEGER, 
  I$DATE_FROM DATE, 
  I$DATE_TO DATE)
RETURNS (
  DOC_TYPE_ID BIGINT, 
  DOC_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  DOC_TYPE_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  DOC_STATUS VARCHAR(30) CHARACTER SET UTF8 COLLATE UTF8, 
  F_LOSS VARCHAR(10) CHARACTER SET UTF8 COLLATE UTF8, 
  F_CHANGE VARCHAR(10) CHARACTER SET UTF8 COLLATE UTF8, 
  F_DROP VARCHAR(10) CHARACTER SET UTF8 COLLATE UTF8, 
  STAGE VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  DOC_SERIE VARCHAR(20) CHARACTER SET UTF8 COLLATE UTF8, 
  DOC_NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  GIVE_DATE DATE, 
  REG_NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  YEAR_START INTEGER, 
  YEAR_FINISH INTEGER, 
  NAME_LAST VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  NAME_FIRST VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  NAME_MID VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  BIRTH_DATE DATE, 
  SNILS VARCHAR(20) CHARACTER SET UTF8 COLLATE UTF8, 
  CITIZENSHIP VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  EDU_AVAIL VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  GENDER VARCHAR(20) CHARACTER SET UTF8 COLLATE UTF8, 
  PAY_SRC VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  EDU_FORM VARCHAR(50) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_DOC_NAME VARCHAR(50) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_SERIE VARCHAR(20) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_NUM VARCHAR(20) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_REG_NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_DATE DATE, 
  PREV_NAME_LAST VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_NAME_FIRST VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  PREV_NAME_MID VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  PROF_NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  SPEC_NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  QUALIFICATION VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_MIGRATE_BLANK (
  I$TYPE_ID BIGINT, 
  I$OU_ID BIGINT, 
  I$SERIE VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NFROM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NTO VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  I$DATE DATE, 
  I$SUPPLIER VARCHAR(4000) CHARACTER SET UTF8 COLLATE UTF8, 
  I$STATE BIGINT)
RETURNS (
  OBJ_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_MIGRATE_DOC (
  I$DOC_TYPE BIGINT, 
  I$OU_ID BIGINT, 
  I$PERSON_ID BIGINT, 
  I$ORDER_ID BIGINT, 
  I$BLANK_ID BIGINT, 
  I$STATE_ID BIGINT, 
  I$NAME_LAST VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_FIRST VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$NAME_MID VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$DOB DATE, 
  I$SEQ_NO INTEGER, 
  I$GRAD_YEAR INTEGER, 
  I$DOC_DATA VARCHAR(8000) CHARACTER SET UTF8 COLLATE UTF8, 
  I$CLASS_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$PROF_NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$SPEC_NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  I$OP_DUR VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$GAK_DATE DATE, 
  I$GAK_FIO VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$UO VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$QUALIFICATION VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8, 
  I$ORDER_DATE DATE, 
  I$ACTION_DATE DATE, 
  I$ORDER_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  I$REC_DATE DATE, 
  I$PREV_NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
RETURNS (
  OBJ_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_PARENT_INFO (
  I$PARENT_ID BIGINT, 
  I$PERSON_ID BIGINT = null)
RETURNS (
  PARENT_BLANK_NUM VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8, 
  PARENT_DATE DATE, 
  PARENT_SEQ_NO INTEGER, 
  REG_ID VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_PRE_NUMBERS (
  I$STAGE_ID BIGINT)
RETURNS (
  TAG_NAME VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  VAL VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_PRE_NUMBERS_ROWS (
  I$STAGE_ID BIGINT, 
  I$YEAR_ID BIGINT)
RETURNS (
  PERSON_ID BIGINT, 
  GRADE_NAME VARCHAR(400) CHARACTER SET UTF8 COLLATE UTF8, 
  ORDER_ID BIGINT, 
  ORDER_DATE DATE, 
  ORDER_NUM VARCHAR(100) CHARACTER SET UTF8 COLLATE UTF8, 
  DOC_TYPE_ID BIGINT)
AS
BEGIN

  SUSPEND;

END
^

CREATE OR ALTER PROCEDURE SDOCS_RESET_TEMPLATE (
  I$OBJ_ID BIGINT, 
  I$USER_ID VARCHAR(40) CHARACTER SET UTF8 COLLATE UTF8)
AS
BEGIN

END
^



COMMIT WORK^


