從資料庫返回多條紀錄賦值給shell變數

zhyuh發表於2004-12-09

這個shell比較有趣,雖然並沒有什麼新的技巧。

它的意義在於讓我認識到對於資料庫裡的多條紀錄,可以將值分別付給shell變數,並且分別處理。

[@more@]

表中的資料:

SQL> select * from aa;

      COL1
----------
         1
         2
         3

shell指令碼:

/export/home/deverdb/p482/scripts>cat test1
#!/usr/bin/bash

for i in `sqlplus -s

執行結果:
/export/home/deverdb/p482/scripts>sh test1
1
haha
2
haha
3
haha

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

相關文章