0
我必須使用嵌套的if/then/else語句來檢查從oracle數據庫獲取的查詢。 我是unix新手。從搜索谷歌,我明白了將sql數據存儲到變量的過程。但是當我必須使用嵌套的if語句時,我該怎麼做?將sql數據存儲在嵌套if變量中
我無法再次連接到數據庫以將數據存儲到變量中。有人可以幫忙嗎?
我在這裏寫的是代碼。原諒錯誤的語法。我來自編碼爲PHP
LOGFILE = #enter path here
fetchdate = `sqlplus -s prmappo/[email protected] << EOFSQL
select min(call_start_datetime) from error_repository;
exit;
EOFSQL`
if (("${fetchdate:4:2}" == "02"));
then
$query_1 = select * from error_repository_BKP partition(part_maxval);
if (($query_1 == NULL));
then
$query_2 = "alter table error_repository_BKP
exchange partition part_maxval
with table error_repository
without validation;" >> $LOGFILE
commit;
fi
$query_3 = "select * from error_repository;"
此外,請告訴我如何讀取存儲在變量中的SQL行數據?
我個人的感覺是從一個shell腳本,SQLPLUS不利於複雜的邏輯。 Perl作爲主要Oracle版本的一部分進行安裝,因此爲在服務器上運行的東西提供了一個很好的選擇。 – 2011-05-17 06:43:59