I have korn shell scripts.
I want to pass a variable to a script which will execute a a sql script to read a table that contains env. variables. I want to read and then somehow export at unix level variables
example
for every row selected from the table build export command line
field1 := 'export SHELL = /app/pasf/sqr; ';
I some how need to get these back to unix korn script so I can create the variable at the unix level. It will be valid only while the session is open.
Not sure the best way to do this.
So far I created a the following(its just a start):
SET serveroutput ON
DECLARE
recordtype varchar2 (6) :='DBASE1';
SHELL VARCHAR2 (36);
SHELL1 VARCHAR2 (36);
SHELL2 VARCHAR2 (36);
PARMS VARCHAR2 (36);
SQR VARCHAR2 (31);
SQLq VARCHAR2 (36);
CTL VARCHAR2 (36);
TNS_ADMIN VARCHAR2 (44);
ORACLE_HOME1 VARCHAR2 (44);
PATH1 VARCHAR2 (30);
CURSOR XXX_cursor IS
SELECT PROGRAM_ID,STRING_ID,LABEL_ID,STRING_TEXT,COL_WIDTH from PS_XXX_ENV_VARS
WHERE PROGRAM_ID = recordtype;
XXX_VARS XXX_cursor%ROWTYPE;
BEGIN
IF NOT XXX_cursor%isopen THEN
OPEN XXX_cursor;
END IF;
LOOP
fetch XXX_cursor into XXX_VARS;
EXIT WHEN XXX_cursor%notfound;
SHELL2 := XXX_VARS.STRING_TEXT ;
SHELL1 := XXX_VARS.STRING_ID;
DBMS_OUTPUT.put_line (SHELL1);
EXIT WHEN XXX_cursor%notfound;
END LOOP;
CLOSE XXX_cursor ;
END;
output is
EXPORT PARMS= /unixsxxx/apps/psf/zzz/CCC/
EXPORT SHELL= /unixsxxx/apps/psf/zzz/CCC/
EXPORT SQL= /unixsxxx/apps/psf/zzz/CCCC/
EXPORT SQR= /unixsxx/apps/psf/zzz/