Showing posts with label SqlPlus. Show all posts
Showing posts with label SqlPlus. Show all posts

Tuesday, March 22, 2011

SQLPlus in a Here Document

This is called a 'here document' - because it says "here is the text for your input". The redirection expressed as "<<EOF" says "take what follows as though I typed it at the keyboard, until you find a token to match EOF as the first token on a line". The token EOF has no special meaning - it's just a string of characters used as a marker to tell the 'here document' when the text input is completed.

sqlplus <<EOF
      Select something
       from somewhere;
EOF

Important: the ending token must appear as the first characters on a line by itself.

Thanks to Jim Benz of Pittsburgh for these notes.


Monday, March 21, 2011

Password Variables

#! /usr/bin/ksh

echo "#------------------------------------------------------------------------------"
echo "# get passwords for the ftp and for sqlplus and assign to variables."
echo "#------------------------------------------------------------------------------"

export FTP_PASS='cat /ux123/dfact/xlt/scripts/ust_grp.password'

export SQL_PASS='cat /ux123/dfact/xlt/scripts/xlt_ods_uat.password'

echo "#------------------------------------------------------------------------------"
echo "# start ftp from vax --i: turn off prompting    n: turn off login"
echo "#------------------------------------------------------------------------------"

ftp -in host1 <
quote user ust_grp
quote pass $FTP_PASS
...
quit
EOF

echo "#------------------------------------------------------------------------------"
echo "# In SQL+, ...
echo "#------------------------------------------------------------------------------"

sqlplus -s  $SQL_PASS << EOF
.
.
exit;
EOF