#--------start pl/sql
{
DECLARE
CURSOR pah_cs IS
select id from table
where letter = 'abcd';
temp number;
echo "-------"
BEGIN
OPEN pah_cs;
LOOP
FETCH pah_cs INTO temp;
EXIT WHEN pah_cs%NOTFOUND;
echo $temp > tt.csv 2>&1;
ND LOOP;
CLOSE pah_cs;
END;
}
exit
EOM`
}
test_sql
I want to use call pl/sql in unix script and put the output into another file and I want the file format is saving the output lilne by line.
but now it seems my pl/sql script hasnt been called at all.
Dunno what the problem is, anyone could help me?? many thanks.
test_sql()
{
$ORACLE_HOME/bin/sqlplus -s $user/$passwd << EOM
set verify off
set heading off
set feedback off
DECLARE
CURSOR pah_cs IS
select id from table
where letter = 'abcd';
temp number;
BEGIN
OPEN pah_cs;
LOOP
FETCH pah_cs INTO temp;
EXIT WHEN pah_cs%NOTFOUND;
END LOOP;
CLOSE pah_cs;
END;
/
EOM
}
test_sql
thanks for your response. good point but not enough.
the next problem is how I can put the 'temp' into a file. Such as if there are 5 records, whenever the cursor fetch one value then put it into a file,so that it would be 5 lines in the file.