* SET_DB_P.TXT HARASAWA (PostgreSQL)
*********( CREATE DATABASE )*********************************************************
=IF{_DB!='P'}JUMP{P_SKIP};
*W-FORM=☆お願い☆：実行開始後、端末画面側でエラー確認、Enterで続行下さい。};
W+=SET{WC.CREATEDB='"'+$INSTALL_PATH+'\bin\createdb" -U ?_LOGIN_ID? i_?WC.L_SYSTEM?',WC.FILE='SETUP_?_SYSTEM?.BAT'};
W-=SET{WC.CREATEDB='su - -c ''createdb i_?WC.L_SYSTEM? 1>?_TMP?CREATEDB.LOG  2>&1'' ?_LOGIN_ID?',WC.FILE='CREATEDB.SH'};
=WRITE_OPEN{A,?_TMP??WC.FILE?,OT,SHIFT_JIS};
W+=WRITE{A,'@echo off'};
W+=WRITE{A,'echo ======================================================================='};
W+=WRITE{A,'echo ☆お願い☆：パスワードを要求された場合は'?_LOGIN_ID?'のパスワードを入力下さい。'};
W+=WRITE{A,'echo =============================================================================='};
W+=WRITE{A,'echo ?WC.CREATEDB?'};
W-=WRITE{A,'#!/bin/sh'};
=WRITE{A,WC.CREATEDB};
W+=WRITE{A,'echo ==========================================='};
=WRITE_CLOSE{A};
W-=COMMAND{chmod 777 ?_TMP??WC.FILE?};
=IF_ERROR_COMMAND{?_TMP??WC.FILE?}NOP{};データベースが既に有る場合のエラー回避*
*(PERMISSION_BEGIN)*
=IF{_DB!='P'}JUMP{P_SKIP};
*********( SET )*************************************
REPEAT0=$W0.PERMISSION
=SET{_LOWER=WC.PER$$,WC.PER$$=_LOWER};
REPEAT0=4
=SET{_LOWER=WC.DIOL$$,WC.DIOL$$=_LOWER};
REPEAT0=3
=SET{_LOWER=WC.RTT$$,WC.RTT$$=_LOWER};
=SET{_LOWER=WC.RRT$$,WC.RRT$$=_LOWER};
REPEAT0=2
=SET{_LOWER=WC.R_T$$,WC.R_T$$=_LOWER};
=SET{_LOWER=WC.M_W$$,WC.M_W$$=_LOWER};
REPEAT0=
=SET{_LOWER=WC.IS,WC.IS=_LOWER};
*********( CREATE USER )*************************************
=MESSAGE{CREATE USER};
REPEAT0=$W0.PERMISSION
REPEAT=2 (WC.REAL_TEST##)
***=SET{WC.PAS=WC.PASSWORD_?WC.REAL_TEST##?};
=SET{WC.LTR=WC.REAL_TEST##};
*=SET{WC.CU='CREATEDB CREATEUSER'}; VER21.1*
=SET{WC.CU='CREATEDB'}; VER21.1*
=SET{W0.REPEAT2CNT=0};
REPEAT2=4 (WC.DIOL--)
=COMPUTE{W0.REPEAT2CNT+=1};
=SET{WC.DIOL=WC.DIOL?W0.REPEAT2CNT?};
***=IF{W0.REPEAT2CNT=4}SET{WC.PAS=WC.PASSWORD_LINK};
=IF{W0.REPEAT2CNT=4}SET{WC.LTR='LINK'};
=IF{W0.REPEAT2CNT=2}SET{WC.CU=};
*=LOGIN_SQL{BEGIN TRANSACTION};
***=IF_ERROR_LOGIN_SQL{
***=  CREATE USER ?WC.IS??WC.R_T##?_?WC.DIOL?_?WC.PER$$?
***=   WITH ?WC.CU? PASSWORD '?WC.PAS?'}
=IF_ERROR_LOGIN_ZZ_ADDLOGIN{?WC.LTR?}
=  {?WC.IS??WC.R_T##?_?WC.DIOL?_?WC.PER$$?}{?WC.CU?}
=  IF{_DB_I_ERROR!='EXIST'}ERROR{LOGIN_SQL ?_DB_ERROR?};
*=LOGIN_SQL{COMMIT TRANSACTION};
REPEAT0=
*********( REVOKE PUBLIC )***********************************
=LOGIN_SQL{REVOKE ALL ON SCHEMA public from public};
*********( CREATE SCEMA )************************************
=MESSAGE{CREATE SCHEMA};
=SET{_LOWER='D',WC.D_L=_LOWER};
REPEAT0=$W0.PERMISSION
REPEAT=2  (WC.R_T##=R;T)
=SET{W0.REPEAT2CNT=0};
REPEAT2=2 (WC.M_W--=M;W)
=COMPUTE{W0.REPEAT2CNT+=1};
=SET{WC.M_W=WC.M_W?W0.REPEAT2CNT?}; 
=IF_ERROR_LOGIN_SQL{
= CREATE SCHEMA ?WC.IS??WC.R_T##?_?WC.M_W?_?WC.PER$$?
=   AUTHORIZATION ?WC.IS??WC.R_T##?_?WC.D_L?_?WC.PER$$?}
=  IF{_DB_I_ERROR!='EXIST'}ERROR{?_DB_ERROR? ?_ERROR?};
=LOGIN_SQL{GRANT USAGE ON SCHEMA 
=  ?WC.IS??WC.R_T##?_?WC.M_W?_?WC.PER$$? TO PUBLIC};
REPEAT0=
*************( GRANT ALL )***********************************
=SET{_LOWER='R_D_ZZZZ',WC.R_D_ZZZZ_L=_LOWER};
REPEAT0=$W0.PERMISSION
=MESSAGE{GRANT ...(?WC.PER$$?)};
REPEAT=3
=SET{_LOWER='ZZZZ',WC.PERX=_LOWER,WC.ZZZZ=_LOWER};
=SET{W0.REPEAT2CNT=0};
REPEAT2=2 (WC.PER--;ZZZZ;自分))
=COMPUTE{W0.REPEAT2CNT+=1};
=IF{W0.REPEAT2CNT=2}SET{_LOWER=WC.PER$$,WC.PERX=_LOWER};
=SET{WC.G
= ='GRANT ALL PRIVILEGES ON SCHEMA ?WC.IS??WC.RTT##?'};
=LOGIN_SQL{?WC.G?_M_?WC.PER$$? TO ?WC.IS??WC.R_D_ZZZZ_L?};
=LOGIN_SQL{?WC.G?_M_?WC.PER$$? TO 
= ?WC.IS??WC.RRT##?_D_?WC.PERX?};
=LOGIN_SQL{?WC.G?_W_?WC.PER$$? TO 
= ?WC.IS??WC.RRT##?_D_?WC.PERX?};
=LOGIN_SQL{?WC.G?_W_?WC.PER$$? TO 
= ?WC.IS??WC.RRT##?_I_?WC.PERX?};
=LOGIN_SQL{?WC.G?_W_?WC.PER$$? TO 
= ?WC.IS??WC.RRT##?_O_?WC.PERX?};
=IF{WC.PER$$=WC.ZZZZ}JUMP{SKIP};
REPEAT2=
=SKIP:
REPEAT0=
REPEAT0=2
=SET{_UPPER=WC.R_T$$,WC.R_T$$=_UPPER};
=SET{_UPPER=WC.M_W$$,WC.M_W$$=_UPPER};
REPEAT0=
=IF{_DB_SOFT>='P15'}JUMP{P15};
=LOGIN_SQL{GRANT EXECUTE ON FUNCTION PG_START_BACKUP
=  TO ?WC.IS??_L(R_D_ZZZZ)?};
=LOGIN_SQL{GRANT EXECUTE ON FUNCTION PG_STOP_BACKUP()
=  TO ?WC.IS??_L(R_D_ZZZZ)?};
=JUMP{P_SKIP};
=P15:
=LOGIN_SQL{GRANT EXECUTE ON FUNCTION PG_BACKUP_START
=  TO ?WC.IS??_L(R_D_ZZZZ)?};
=LOGIN_SQL{GRANT EXECUTE ON FUNCTION PG_BACKUP_STOP
=  TO ?WC.IS??_L(R_D_ZZZZ)?};
=JUMP{P_SKIP};
********( CREATE VIEW )**************************************
*****( OBJECT_VIEW )*****************************************
NAME=P_OBJECT_VIEW
=SET{WC.ADSRC='D.ADSRC'};
=IF_NOT{_DB_SOFT/'P9'}IF{_DB_SOFT>='P12'}
=   SET{WC.ADSRC='PG_GET_EXPR(D.ADBIN,D.ADRELID)'};
=SET{WC.I=WC.INSERT+'''P'','};
COPY=ADD10
=SQL{?WC?'(SYSTEM_KIND,SYSTEM_REAL,SYSTEM_WORK')};
COPY=ADD10
=SQL{?WC?',SYSTEM_USER_X,SYSTEM_NAME,SYSTEM_TEXT')};
COPY=ADD10
=SQL{?WC?',SYSTEM_ADD_DATE17,SYSTEM_CHANGE_DATE17')};
COPY=ADD10
=SQL{?WC?',TYPES) AS SELECT')};
COPY=ADD10
=SQL{?WC?' CAST(''TABLE''  AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(TABLEOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(TABLEOWNER)-5,1)) AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(TABLENAME) AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS VARCHAR(4000))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS CHAR(17))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS CHAR(17))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS VARCHAR(4000))')};
COPY=ADD10
=SQL{?WC?' FROM PG_TABLES WHERE ')};
COPY=ADD10
=SQL{?WC?' SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' UNION SELECT')};
COPY=ADD10
=SQL{?WC?' CAST(''VIEW''  AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(VIEWOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(VIEWOWNER)-5,1)) AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(VIEWNAME) AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',CAST(DEFINITION AS VARCHAR(4000))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS CHAR(17))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS CHAR(17))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS VARCHAR(4000))')};
COPY=ADD10
=SQL{?WC?' FROM PG_VIEWS WHERE')};
COPY=ADD10
=SQL{?WC?' SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' UNION SELECT CAST(''FUNC''  AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(USENAME')};
COPY=ADD10
=SQL{?WC?',LENGTH(USENAME)-5,1)) AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(PRONAME) AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',CAST(PROSRC AS VARCHAR(4000))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS CHAR(17))')};
COPY=ADD10
=SQL{?WC?',CAST('' '' AS CHAR(17))')};
COPY=ADD10
=SQL{?WC?',CAST( UPPER(''(''||CASE')};
COPY=ADD10
=SQL{?WC?' WHEN PRONARGS=0 THEN '''' ELSE')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[0])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<2 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[1])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<3 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[2])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<4 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE')};
COPY=ADD10
=SQL{?WC?' WHERE OID=PROARGTYPES[3])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<5 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[4])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<6 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[5])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<7 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[6])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<8 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[7])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<9 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[8])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<10 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[9])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<11 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[10])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<12 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[11])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<13 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[12])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<14 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[13])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<15 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[14])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<16 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[15])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<17 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[16])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<18 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[17])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<19 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[18])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<20 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[19])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<21 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[20])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<22 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[21])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<23 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[22])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<24 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[23])END')};
COPY=ADD10
=SQL{?WC?'||CASE WHEN PRONARGS<25 THEN ''''')};
COPY=ADD10
=SQL{?WC?' ELSE '',''||')};
COPY=ADD10
=SQL{?WC?'(SELECT TYPNAME FROM PG_TYPE WHERE')};
COPY=ADD10
=SQL{?WC?' OID=PROARGTYPES[24])END')};
COPY=ADD10
=SQL{?WC?'||'')'') AS VARCHAR(4000))')};
COPY=ADD10
=SQL{?WC?' FROM PG_PROC P')};
COPY=ADD10
=SQL{?WC?' ,PG_USER U WHERE PROOWNER=USESYSID')};
COPY=ADD10
=SQL{?WC?' AND USENAME')};
COPY=ADD10
=SQL{?WC?' ?WC.P_OWNER1?')};
COPY=ADD10
=SQL{?WC?' ?WC.P_OWNER2?')};
*****( COLUMN_VIEW )*****************************************
NAME=P_COLUMN_VIEW
=SET{WC.I=WC.INSERT+'''P'','};
COPY=ADD10
=SQL{?WC?'(SYSTEM_KIND,SYSTEM_REAL,SYSTEM_WORK')};
COPY=ADD10
=SQL{?WC?',SYSTEM_USER_X,SYSTEM_NAME,SYSTEM_SEQ')};
COPY=ADD10
=SQL{?WC?',SYSTEM_DATA_NAME,SYSTEM_DEFAULT_TYPE')};
COPY=ADD10
=SQL{?WC?',SYSTEM_DEFAULT_LENGTH1,SYSTEM_DEFAULT_LENGTH2')};
COPY=ADD10
=SQL{?WC?',SYSTEM_DEFAULT,SYSTEM_NULL)')};
COPY=ADD10
=SQL{?WC?' AS SELECT CAST(''TABLE'' AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(TABLEOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(TABLEOWNER)-5,1)) AS CHAR(1))')};
NAME2=P_COLUMN
COPY=ADD10
=SQL{?WC?',CAST(UPPER(C.RELNAME) AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',A.ATTNUM,CAST(UPPER(A.ATTNAME) AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE UPPER(TYPNAME)')};
COPY=ADD10
=SQL{?WC?' WHEN ''NUMERIC'' THEN CHAR ''DECIMAL''')};
COPY=ADD10
=SQL{?WC?' WHEN ''INT4'' THEN CHAR ''INT''')};
COPY=ADD10
=SQL{?WC?' WHEN ''INT2'' THEN CHAR ''INT''')};
COPY=ADD10
=SQL{?WC?' WHEN ''FLOAT8'' THEN CHAR ''FLOAT''')};
COPY=ADD10
=SQL{?WC?' WHEN ''TIMESTAMP'' THEN CHAR ''DATETIME''')};
COPY=ADD10
=SQL{?WC?' WHEN  ''VARCHAR'' THEN ')};
COPY=ADD10
=SQL{?WC?' CASE SYSTEM_DEFAULT_TYPE')};
COPY=ADD10
=SQL{?WC?' WHEN ''NVARCHAR'' THEN ''NVARCHAR''')};
COPY=ADD10
=SQL{?WC?' ELSE ''VARCHAR'' END')};
COPY=ADD10
=SQL{?WC?' ELSE')};
COPY=ADD10
=SQL{?WC?' CASE WHEN  UPPER(TYPNAME)')};
COPY=ADD10
=SQL{?WC?' IN(''BPCHAR'',''CHAR'') THEN')};
COPY=ADD10
=SQL{?WC?' CASE SYSTEM_DEFAULT_TYPE')};
COPY=ADD10
=SQL{?WC?' WHEN ''NCHAR'' THEN ''NCHAR''')};
COPY=ADD10
=SQL{?WC?' ELSE ''CHAR'' END')};
COPY=ADD10
=SQL{?WC?' ELSE UPPER(TYPNAME) END')};
COPY=ADD10
=SQL{?WC?' END AS CHAR(9))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN UPPER(TYPNAME)')};
COPY=ADD10
=SQL{?WC?' IN(''BPCHAR'',''VARCHAR'')')};
COPY=ADD10
=SQL{?WC?' THEN A.ATTTYPMOD-4 ')};
COPY=ADD10
=SQL{?WC?' ELSE CASE UPPER(TYPNAME)')};
COPY=ADD10
=SQL{?WC?' WHEN ''NUMERIC''')};
COPY=ADD10
=SQL{?WC?' THEN (A.ATTTYPMOD-4)/65536 ')};
COPY=ADD10
=SQL{?WC?' WHEN ''TIMESTAMP'' THEN 17')};
COPY=ADD10
=SQL{?WC?' WHEN ''DATE'' THEN 8')};
COPY=ADD10
=SQL{?WC?' WHEN ''TEXT'' THEN 4000')};
COPY=ADD10
=SQL{?WC?' ELSE 9 END END AS INT)')};
COPY=ADD10
=SQL{?WC?',CAST(CASE UPPER(TYPNAME)')};
COPY=ADD10
=SQL{?WC?' WHEN ''NUMERIC''')};
COPY=ADD10
=SQL{?WC?' THEN (A.ATTTYPMOD-4)%65536')};
COPY=ADD10
=SQL{?WC?' ELSE 0 END AS INT)')};
COPY=ADD10
=SQL{?WC?',CAST(REPLACE(REPLACE(REPLACE')};
COPY=ADD10
=SQL{?WC?'(UPPER(?WC.ADSRC?),''::BPCHAR'','''')')};
COPY=ADD10
=SQL{?WC?',''::CHARACTER VARYING'','''')')};
COPY=ADD10
=SQL{?WC?',''(''''NOW''''::TEXT)::DATE''')};
COPY=ADD10
=SQL{?WC?',''CURRENT_DATE'') AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN A.ATTNOTNULL')};
COPY=ADD10
=SQL{?WC?' THEN ''0'' ELSE ''1'' END')};
COPY=ADD10
=SQL{?WC?' AS CHAR(1)) FROM PG_CLASS C JOIN ')};
NAME2=
COPY=ADD10
=SQL{?WC?' PG_TABLES T')};
COPY=ADD10
=SQL{?WC?' ON C.RELNAME=T.TABLENAME')};
COPY=ADD10
=SQL{?WC?' AND C.RELKIND=LOWER(''R'') AND')};
COPY=ADD10
=SQL{?WC?' T.SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' JOIN PG_USER U')};
COPY=ADD10
=SQL{?WC?' ON U.USENAME=T.TABLEOWNER')};
NAME2=P_COLUMN_JOIN
COPY=ADD10
=SQL{?WC?' AND C.RELOWNER=U.USESYSID')};
COPY=ADD10
=SQL{?WC?' JOIN PG_ATTRIBUTE A')};
COPY=ADD10
=SQL{?WC?' ON C.OID=A.ATTRELID')};
COPY=ADD10
=SQL{?WC?' AND A.ATTNUM>0')};
COPY=ADD10
=SQL{?WC?' JOIN PG_TYPE TY')};
COPY=ADD10
=SQL{?WC?' ON A.ATTTYPID=TY.OID')};
COPY=ADD10
=SQL{?WC?' LEFT JOIN PG_ATTRDEF D')};
COPY=ADD10
=SQL{?WC?' ON C.OID=D.ADRELID')};
COPY=ADD10
=SQL{?WC?' AND A.ATTNUM=D.ADNUM LEFT JOIN')};
COPY=ADD10
=SQL{?WC?' I_?_Q?_SYSTEM?_Q?_R_M_ZZZZ')};
COPY=ADD10
=SQL{?WC?'.ZZZZZZ_I_DICTIONARY_TABLE')};
COPY=ADD10
=SQL{?WC?' ON UPPER(A.ATTNAME)')};
COPY=ADD10
=SQL{?WC?'=SYSTEM_DATA_NAME')};
COPY=ADD10
=SQL{?WC?' AND SYSTEM_PERMISSION=''?WC.PER?''')};
COPY=ADD10
=SQL{?WC?' AND SYSTEM_LANG=''?_LANG_SYSTEM?''')};
NAME2=
COPY=ADD10
=SQL{?WC?' UNION SELECT')};
COPY=ADD10
=SQL{?WC?' CAST(''VIEW'' AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?''')};
COPY=ADD10
=SQL{?WC?' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(VIEWOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(VIEWOWNER)-5,1)) AS CHAR(1))')};
COPY=P_COLUMN
COPY=ADD10
=SQL{?WC?' PG_VIEWS T')};
COPY=ADD10
=SQL{?WC?' ON C.RELNAME=T.VIEWNAME')};
COPY=ADD10
=SQL{?WC?' AND C.RELKIND=LOWER(''V'') AND')};
COPY=ADD10
=SQL{?WC?' T.SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' JOIN PG_USER U')};
COPY=ADD10
=SQL{?WC?' ON U.USENAME=T.VIEWOWNER')};
COPY=P_COLUMN_JOIN
*****( INDEX_VIEW )******************************************
NAME=P_INDEX_VIEW
=SET{WC.I=WC.INSERT+'''P'','};
COPY=ADD10
=SQL{?WC?'(SYSTEM_REAL,SYSTEM_WORK')};
COPY=ADD10
=SQL{?WC?',SYSTEM_USER_X,SYSTEM_NAME')};
COPY=ADD10
=SQL{?WC?',SYSTEM_DATA_NAME,SYSTEM_IX,SYSTEM_NO)')};
COPY=ADD10
=SQL{?WC?'AS SELECT')};
NAME2=P_SQL1
COPY=ADD10
=SQL{?WC?' CAST(''?_Q?_REAL_TEST?_Q?''')};
COPY=ADD10
=SQL{?WC?' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(TABLEOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(TABLEOWNER)-5,1)) AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(I.TABLENAME) AS CHAR(30)),')};
NAME2=P_SPLIT
COPY=ADD10
=SQL{?WC?'CAST(TRIM(UPPER(TRIM(SPLIT_PART(')};
COPY=ADD10
=SQL{?WC?'SUBSTRING(INDEXDEF')};
COPY=ADD10
=SQL{?WC?',POSITION(''('' IN INDEXDEF)+1')};
COPY=ADD10
=SQL{?WC?',POSITION('')'' IN INDEXDEF)')};
COPY=ADD10
=SQL{?WC?'-POSITION(''('' IN INDEXDEF)-1)')};
COPY=ADD10
=SQL{?WC?','','',')};
NAME2=
COPY=ADD10
=SQL{?WC?' 1))),''"'') AS CHAR(30)),')};
NAME2=P_SQL2
COPY=ADD10
=SQL{?WC?' CAST(SUBSTRING(INDEXNAME')};
COPY=ADD10
=SQL{?WC?',LENGTH(TRIM(INDEXNAME)),1)')};
COPY=ADD10
=SQL{?WC?' AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN INDEXDEF LIKE')};
COPY=ADD10
=SQL{?WC?' ''CREATE UNIQUE %'' THEN')};
NAME2=
COPY=ADD10
=SQL{?WC?' ''0'' ELSE ''1''')};
NAME2=P_SQL3
COPY=ADD10
=SQL{?WC?' END AS INT) FROM PG_INDEXES I')};
COPY=ADD10
=SQL{?WC?',PG_TABLES T')};
COPY=ADD10
=SQL{?WC?' WHERE I.TABLENAME=T.TABLENAME')};
COPY=ADD10
=SQL{?WC?' AND I.SCHEMANAME=T.SCHEMANAME AND')};
COPY=ADD10
=SQL{?WC?' I.SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' AND TRIM('' '')<>')};
NAME2=
COPY=P_SPLIT
COPY=ADD10
=SQL{?WC?' 1))),''"'')')};
COPY=ADD10
=SQL{?WC?' AS CHAR(30)) ')};
**************************************************
=SET{W0.REPEAT2CNT=0}; 
*REPEAT2=8
=P_SQLX:
=COMPUTE{W0.REPEAT2CNT+=1
=  ,W0.REPEAT2CNT_P1=W0.REPEAT2CNT+1};
**************************************************
COPY=ADD10
=SQL{?WC?' UNION SELECT')};
COPY=P_SQL1
COPY=P_SPLIT
COPY=ADD10
=SQL{?WC?' ?W0.REPEAT2CNT_P1?))),''"'')')};
COPY=ADD10
=SQL{?WC?' AS CHAR(30)),')};
COPY=P_SQL2
COPY=ADD10
=SQL{?WC?' ''?W0.REPEAT2CNT?''')};
COPY=ADD10
=SQL{?WC?' ELSE ''?W0.REPEAT2CNT_P1?''')};
COPY=P_SQL3
COPY=P_SPLIT
COPY=ADD10
=SQL{?WC?' ?W0.REPEAT2CNT_P1?))),''"'')')};
COPY=ADD10
=SQL{?WC?' AS CHAR(30))')};
**************************************************
=IF{W0.REPEAT2CNT<8}BACK{P_SQLX};
**************************************************
COPY=ADD10
=SQL{?WC?' UNION SELECT')};
COPY=P_SQL1
COPY=P_SPLIT
COPY=ADD10
=SQL{?WC?' 10))),''"'') AS CHAR(30)),')};
COPY=P_SQL2
COPY=ADD10
=SQL{?WC?' ''9'' ELSE ''0''')};
COPY=P_SQL3
COPY=P_SPLIT
COPY=ADD10
=SQL{?WC?' 10))),''"'') AS CHAR(30))')};
*****( GRANT_VIEW )******************************************
NAME=P_GRANT_VIEW
=SET{WC.P_GRANT_SW=0};
=SET{WC.I=WC.INSERT+'''P'','};
COPY=ADD10
=SQL{?WC?'(SYSTEM_KIND,SYSTEM_REAL,SYSTEM_WORK')};
COPY=ADD10
=SQL{?WC?',SYSTEM_USER_X,SYSTEM_NAME,SYSTEM_GRANT')};
COPY=ADD10
=SQL{?WC?',SYSTEM_SELECT,SYSTEM_INSERT,SYSTEM_UPDATE')};
COPY=ADD10
=SQL{?WC?',SYSTEM_DELETE,SYSTEM_EXECUTE)AS')};
=SET{W0.L8=WC.L_SYSTEM@LENGTH};COMPUTE{W0.L8+=8};
=SET{WC.UNION=,WC.SQL=};
=SET{WC.GRANT='PUBLIC',WC.GRANTX=};
=SET{WC.DBD='/?_Q?_DB_HEADER?_Q?_D_'};
*=======NAME=GRANT$$===============================
=P_GRANT_LOOP:
COPY=ADD10
=SQL{?WC?' ?WC.UNION?')};
COPY=ADD10
=SQL{?WC?' SELECT CAST(''TABLE'' AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(TABLEOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(TABLEOWNER)-5,1)) AS CHAR(1))')};
******
NAME2=GRANT_SUB_A
COPY=ADD10
=SQL{?WC?',CAST(UPPER(C.RELNAME) AS CHAR(30))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.GRANT?'' AS CHAR(6))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=R?WC.DBD?ZZZZ'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) OR ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=R?WC.DBD??WC.PER?'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) THEN CHAR ''S'' ELSE CHAR '' ''')};
COPY=ADD10
=SQL{?WC?' END AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=A?WC.DBD?ZZZZ'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) OR ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=A?WC.DBD??WC.PER?'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) THEN CHAR ''I'' ELSE CHAR '' ''')};
COPY=ADD10
=SQL{?WC?' END AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=W?WC.DBD?ZZZZ'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) OR ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=W?WC.DBD??WC.PER?'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) THEN CHAR ''U'' ELSE CHAR '' ''')};
COPY=ADD10
=SQL{?WC?' END AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST(CASE WHEN ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=D?WC.DBD?ZZZZ'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) OR ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=D?WC.DBD??WC.PER?'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) THEN CHAR ''D'' ELSE CHAR '' ''')};
COPY=ADD10
=SQL{?WC?' END AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?',CAST('' ''AS CHAR(1))')};
COPY=ADD10
=SQL{?WC?' FROM PG_CLASS C,PG_USER U')};
NAME2=
COPY=ADD10
=SQL{?WC?',PG_TABLES T WHERE')};
COPY=ADD10
=SQL{?WC?' C.RELNAME=T.TABLENAME AND')};
COPY=ADD10
=SQL{?WC?' T.SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' AND U.USENAME=T.TABLEOWNER')};
COPY=ADD10
=SQL{?WC?' AND C.RELKIND=LOWER(''R'')')};
NAME2=GRANT_SUB_B
COPY=ADD10
=SQL{?WC?' AND C.RELOWNER=U.USESYSID')};
COPY=ADD10
=SQL{?WC?' AND(ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=R?WC.DBD?ZZZZ'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM) OR  ACLCONTAINS(RELACL,LOWER(')};
COPY=ADD10
=SQL{?WC?'''?WC.GRANTX?=R?WC.DBD??WC.PER?'')')};
COPY=ADD10
=SQL{?WC?'::ACLITEM))')};
NAME2=
COPY=ADD10
=SQL{?WC?' UNION SELECT ')};
COPY=ADD10
=SQL{?WC?' CAST(''VIEW'' AS CHAR(5))')};
COPY=ADD10
=SQL{?WC?',CAST(''?_Q?_REAL_TEST?_Q?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(''?WC.MAST_WORK?'' AS CHAR(4))')};
COPY=ADD10
=SQL{?WC?',CAST(UPPER(SUBSTR(VIEWOWNER')};
COPY=ADD10
=SQL{?WC?',LENGTH(VIEWOWNER)-5,1)) AS CHAR(1))')};
COPY=GRANT_SUB_A
COPY=ADD10
=SQL{?WC?',PG_VIEWS V WHERE')};
COPY=ADD10
=SQL{?WC?' C.RELNAME=V.VIEWNAME AND')};
COPY=ADD10
=SQL{?WC?' V.SCHEMANAME')};
COPY=ADD10
=SQL{?WC?'=LOWER(''?WC.P_DB?'')')};
COPY=ADD10
=SQL{?WC?' AND U.USENAME=V.VIEWOWNER')};
COPY=ADD10
=SQL{?WC?' AND C.RELKIND=LOWER(''V'')')};
COPY=GRANT_SUB_B
=IF{WC.P_GRANT_SW=1}JUMP{P_GRANT1};
=IF{WC.P_GRANT_SW=2}JUMP{P_GRANT2};
=IF{WC.P_GRANT_SW=3}JUMP{P_GRANT3};
=IF{WC.P_GRANT_SW=4}JUMP{P_GRANT4};
*======================================================
=SET{WC.UNION=' UNION'};
=SET{W0.REPEAT2CNT=0};
=SET{W0._P_PER_COUNT=1};
=P_PER_LOOP:
=COMPUTE{W0.REPEAT2CNT+=1};
=SET{WC.PERX=WC.PERMISSION?W0.REPEAT2CNT?};
=SET{WC.GRANT='D_'+WC.PERX};
=SET{WC.GRANTX='?_Q?_DB_HEADER?_Q?_D_?WC.PERX?'};
=SET{WC.P_GRANT_SW=1};BACK{P_GRANT_LOOP};
=P_GRANT1:
=SET{_UPPER=WC.PERX,WC.GRANT='I_'+_UPPER};
=SET{WC.GRANTX='?_Q?_DB_HEADER?_Q?_I_?WC.PERX?'};
=SET{WC.P_GRANT_SW=2};BACK{P_GRANT_LOOP};
=P_GRANT2:
=SET{_UPPER=WC.PERX,WC.GRANT='O_'+_UPPER};
=SET{WC.GRANTX='?_Q?_DB_HEADER?_Q?_O_?WC.PERX?'};
=SET{WC.P_GRANT_SW=3};BACK{P_GRANT_LOOP};
=P_GRANT3:
=SET{_UPPER=WC.PERX,WC.GRANT='L_'+_UPPER};
=SET{WC.GRANTX='?_Q?_DB_HEADER?_Q?_L_?WC.PERX?'};
=SET{WC.P_GRANT_SW=4};BACK{P_GRANT_LOOP};
=P_GRANT4:
=COMPUTE{W0._P_PER_COUNT+=1};
=IF{W0._P_PER_COUNT<=W0.PER_MAX}BACK{P_PER_LOOP};
NAME=
*************************************************************
=P_SKIP:
=SET{_REAL_TEST='REAL'};
*(PERMISSION_END)*
