兩個小例子:把從表中取得的資料傳給Unix的shell變數

lawzjf發表於2007-10-08

[oracle@redhat ~]$ cat sqlvalue
#!/bin/bash

VALUE=`sqlplus -s scott/tiger <set pagesize 0 feedback off verify off heading off echo off
select count(deptno) from dept;
exit;
END`
echo ""$VALUE" rows returned from database"


[oracle@redhat ~]$ cat sqlvalue2
#!/bin/bash

sqlplus -s >junk1 /nolog <connect scott/tiger
column num_rows new_value num_rows format 9999
select count(*) num_rows from dept;
exit num_rows
EOF
echo "Number of rows are: $?"


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/37724/viewspace-152645/,如需轉載,請註明出處,否則將追究法律責任。

相關文章