資源描述:
《oracle開發(fā) VS INFORMIX開發(fā)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、變量定義Oracle:??v_table_nameUSER_TABLES.table_name%TYPE;Informix:define??v_table_namelikesystables.tabname;判斷某張表是否被鎖住Oracle:??selectcount(*)intov_countfromv$locked_objectwhereobject_id??in(selectobject_idfromuser_objectswhereobject_name=upper('fact_g_gprs_settle'));Informix:selectcount(*)i
2、ntov_countfromsysmaster:syslockswhereowner>0andwaiter>0andtabname=lower(‘fact_G_gprs_settle'));to_char和to_date函數(shù)Oracle:to_char(sysdate,'yyyymmdd')to_date(‘20080910’,’yyyymmdd’)Informix:??to_char(today,’%Y%m%d‘);to_char(current,’%Y%m%d’);to_date(‘20080910’,%Y%m%d);在日期中增加某個(gè)單元值Oracle:增加1天:
3、??sysdate+1增加一分鐘:SYSDATE+1/24/60Informix:增加1天:??today+1unitsday(增加其他時(shí)間單元方法類似);增加1分鐘:current+1unitsminute判斷是否是星期六Oracle:to_char(to_date(sampling_date,'yyyymmdd'),'fmday')='星期六'??informix:weekday(to_date(sampling_date,'yyyymmdd'))=6DUALOracle:selectto_char(sysdate-i,'yyyymmdd')intov_datef
4、romdual;Informix:letv_date=to_char(today–iunitsday,’%Y%m%d’)不需要和數(shù)據(jù)庫(kù)交互;或者selectto_char(today–iunitsday,‘%Y%m%d')intov_datefromdual;其中dual是sysmaster:sysdual的同義詞,已經(jīng)在zhjs_app中創(chuàng)建。其中:i是整形變量others??exception的轉(zhuǎn)換Oracle:exception??whenotherstheno_returncode:=-1;o_returnmsg??:=substr('[01]'
5、
6、'p_bi
7、_control_call_code錯(cuò)誤告警'
8、
9、sqlerrm,1,255);rollback;Informix:definesql_errint;defineisqm_errint;defineerr_infovarchar(255)onexceptionsetsql_err,isam_err,err_info--informix依次把sqlcode,isamcode和錯(cuò)誤信息傳遞給上述3個(gè)變量;leto_return_code=-1let=substr('[01]'
10、
11、'p_bi_control_call_code錯(cuò)誤告警'
12、
13、err_info,1,255);r
14、ollback;returno_returncode,o_returnmsg;endexception;人工觸發(fā)exceptionOracle:e_errorexception;/*exception是一個(gè)變量*/ifv_flagnotin('a','b')thenraisee_error;endif;exceptionwhene_errorthenrollback;vo_errmsg:='[p_expdb_acc_d_sms]error:'
15、
16、vo_errmsg;vo_return:='1161';Informix:??onexceptionin(30000)rol
17、lback;letvo_errmsg='[p_expdb_acc_d_sms]error:'
18、
19、vo_errmsg;letvo_return='1161';returnvo_errrms,vo_returnendexception;ifv_flagnotin('a','b')thenraiseexception30000;endif;注意:1)exception的錯(cuò)誤號(hào)必須是一個(gè)smallint的數(shù)字;2)informix通過(guò)return語(yǔ)句獲得返回值;而oracle通過(guò)頭文件的聲明來(lái)獲得;3)無(wú)論是informix還是oracle在觸發(fā)except