SET TERM ^ ;

CREATE OR ALTER PROCEDURE BUILD_FIO (
    I$F VARCHAR(400),
    I$I VARCHAR(400),
    I$O VARCHAR(400))
RETURNS (
    FULL_NAME VARCHAR(400))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE DATE2ISO (
    D TIMESTAMP,
    FULL_TIME SMALLINT = 1)
RETURNS (
    VAL VARCHAR(64))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE EXPLODE_STR (
    S VARCHAR(4000),
    DELIM VARCHAR(1) = ';')
RETURNS (
    ID VARCHAR(100),
    V VARCHAR(1000))
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))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_APPLY_NUMBERS (
    I$ORDER VARCHAR(8000),
    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),
    NUM VARCHAR(40),
    STATE SMALLINT,
    SUBTYPE_ID SMALLINT)
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_APPLY (
    I$OBJ_ID BIGINT,
    I$SERIE VARCHAR(10),
    I$NUM VARCHAR(40),
    I$NAME_LAST VARCHAR(200),
    I$NAME_FIRST VARCHAR(200),
    I$NAME_MID VARCHAR(200),
    I$USE_DATE DATE,
    I$USER_ID VARCHAR(40))
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))
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))
AS
BEGIN
END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_GET (
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40))
RETURNS (
    TAG_NAME VARCHAR(100),
    VAL VARCHAR(1000))
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),
    I$USER_ID VARCHAR(40))
RETURNS (
    STATE_ID BIGINT,
    ADD_NUMS VARCHAR(400))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_REVERT (
    I$BP_ID BIGINT,
    I$NUM BIGINT,
    I$USER_ID VARCHAR(40))
AS
BEGIN
END
^

CREATE OR ALTER PROCEDURE SDOCS_BLANK_SET (
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40),
    I$OU_ID BIGINT,
    I$ACCEPT_DATE DATE,
    I$ACCEPT_FROM VARCHAR(1000),
    I$SERIE VARCHAR(40),
    I$NUM_FROM VARCHAR(40),
    I$NUM_TO VARCHAR(40),
    I$TYPE_ID BIGINT,
    I$SUBTYPE_ID BIGINT,
    I$COMMENTS VARCHAR(200))
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))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_CLOSE_YEAR (
    I$STAGE_ID BIGINT,
    I$USER_ID VARCHAR(40))
AS
BEGIN
END
^

CREATE OR ALTER PROCEDURE SDOCS_COPY_TEMPLATE (
    I$OBJ_ID BIGINT,
    I$OU_ID BIGINT,
    I$NAME VARCHAR(400),
    I$USER_ID VARCHAR(40))
RETURNS (
    OBJ_ID BIGINT)
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_DELETE_BLANK (
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40))
AS
BEGIN
END
^

CREATE OR ALTER PROCEDURE SDOCS_DELETE_DOC (
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40))
RETURNS (
    OBJ_ID BIGINT)
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_DELETE_TEMPLATE (
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40))
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),
    I$PREV_DATE DATE,
    I$NAME_LAST VARCHAR(400),
    I$NAME_FIRST VARCHAR(400),
    I$NAME_MID VARCHAR(400),
    I$BIRTH_DATE DATE,
    I$GRAD_YEAR INTEGER,
    I$YEAR_ID BIGINT,
    I$DUB_STATE SMALLINT,
    I$USER_ID VARCHAR(40))
RETURNS (
    TAG_NAME VARCHAR(100),
    VAL VARCHAR(8000))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_GET (
    I$PERSON_ID BIGINT,
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40))
RETURNS (
    TAG_NAME VARCHAR(200),
    VAL VARCHAR(8000))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_DOCUMENT_GN (
    I$PERSON_ID BIGINT,
    I$NAME_LAST VARCHAR(400),
    I$NAME_FIRST VARCHAR(400),
    I$NAME_MID VARCHAR(400),
    I$BIRTH_DATE DATE,
    I$GRAD_YEAR INTEGER,
    I$YEAR_ID BIGINT,
    I$ACTION_DATE DATE,
    I$REF_NUM VARCHAR(100),
    I$USER_ID VARCHAR(40))
RETURNS (
    TAG_NAME VARCHAR(100),
    VAL VARCHAR(8000))
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) NOT NULL,
    I$NAME_FIRST VARCHAR(200) NOT NULL,
    I$NAME_MID VARCHAR(200),
    I$BIRTH_DATE DATE NOT NULL,
    I$DOC_TYPE_ID BIGINT NOT NULL,
    I$BP_ID BIGINT,
    I$BLANK_NUM VARCHAR(40),
    I$FORMAT_ID BIGINT,
    I$GRAD_YEAR SMALLINT,
    I$DATA VARCHAR(8000),
    I$USER_ID VARCHAR(40),
    I$REF_NUM VARCHAR(100) = null,
    I$ACTION_DATE DATE = null,
    I$REG_NUM VARCHAR(100) = 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),
    I$SPEC VARCHAR(400),
    I$OP_DUR VARCHAR(100),
    I$QUAL VARCHAR(200),
    I$UO VARCHAR(100),
    I$PREV_DOC VARCHAR(100),
    I$GAK_DATE DATE,
    I$GAK_FIO VARCHAR(200),
    I$DPLDATA VARCHAR(8000))
AS
BEGIN
END
^

CREATE OR ALTER PROCEDURE SDOCS_DUB_DATA (
    I$ORDER_ID BIGINT,
    I$PERSON_ID BIGINT)
RETURNS (
    PREV_FIO VARCHAR(400),
    PREV_BD DATE,
    NEW_FIO VARCHAR(400),
    NEW_BD DATE,
    GRAD_YEAR INTEGER,
    PREV_DATE DATE,
    PREV_NUM VARCHAR(100),
    BLANK_NUM VARCHAR(100))
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),
    DOC_TYPE_NAME VARCHAR(100),
    DOC_STATUS VARCHAR(30),
    F_LOSS VARCHAR(10),
    F_CHANGE VARCHAR(10),
    F_DROP VARCHAR(10),
    STAGE VARCHAR(100),
    DOC_SERIE VARCHAR(20),
    DOC_NUM VARCHAR(40),
    GIVE_DATE DATE,
    REG_NUM VARCHAR(40),
    YEAR_START INTEGER,
    YEAR_FINISH INTEGER,
    NAME_LAST VARCHAR(200),
    NAME_FIRST VARCHAR(200),
    NAME_MID VARCHAR(200),
    BIRTH_DATE DATE,
    SNILS VARCHAR(20),
    CITIZENSHIP VARCHAR(40),
    EDU_AVAIL VARCHAR(40),
    GENDER VARCHAR(20),
    PAY_SRC VARCHAR(100),
    EDU_FORM VARCHAR(50),
    PREV_DOC_NAME VARCHAR(50),
    PREV_SERIE VARCHAR(20),
    PREV_NUM VARCHAR(20),
    PREV_REG_NUM VARCHAR(40),
    PREV_DATE DATE,
    PREV_NAME_LAST VARCHAR(200),
    PREV_NAME_FIRST VARCHAR(200),
    PREV_NAME_MID VARCHAR(200),
    PROF_NAME VARCHAR(400),
    SPEC_NAME VARCHAR(400),
    QUALIFICATION VARCHAR(200))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_MIGRATE_BLANK (
    I$TYPE_ID BIGINT,
    I$OU_ID BIGINT,
    I$SERIE VARCHAR(40),
    I$NUM VARCHAR(40),
    I$NFROM VARCHAR(40),
    I$NTO VARCHAR(40),
    I$DATE DATE,
    I$SUPPLIER VARCHAR(4000),
    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),
    I$NAME_FIRST VARCHAR(100),
    I$NAME_MID VARCHAR(100),
    I$DOB DATE,
    I$SEQ_NO INTEGER,
    I$GRAD_YEAR INTEGER,
    I$DOC_DATA VARCHAR(8000),
    I$CLASS_NAME VARCHAR(100),
    I$PROF_NAME VARCHAR(400),
    I$SPEC_NAME VARCHAR(400),
    I$OP_DUR VARCHAR(100),
    I$GAK_DATE DATE,
    I$GAK_FIO VARCHAR(200),
    I$UO VARCHAR(100),
    I$QUALIFICATION VARCHAR(200),
    I$ORDER_DATE DATE,
    I$ACTION_DATE DATE,
    I$ORDER_NUM VARCHAR(100),
    I$REC_DATE DATE,
    I$PREV_NUM VARCHAR(40))
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),
    PARENT_DATE DATE,
    PARENT_SEQ_NO INTEGER,
    REG_ID VARCHAR(100))
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_PRE_NUMBERS (
    I$STAGE_ID BIGINT)
RETURNS (
    TAG_NAME VARCHAR(100),
    VAL VARCHAR(400))
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),
    ORDER_ID BIGINT,
    ORDER_DATE DATE,
    ORDER_NUM VARCHAR(100),
    DOC_TYPE_ID BIGINT)
AS
BEGIN
  SUSPEND;
END
^

CREATE OR ALTER PROCEDURE SDOCS_RESET_TEMPLATE (
    I$OBJ_ID BIGINT,
    I$USER_ID VARCHAR(40))
AS
BEGIN
END
^

