- 论坛徽章:
- 0
|
FUNCTION DAT_chkSql_getRows(V_work_id,V_tabname,V_sql_str)
DEFINE V_tabname CHAR(20), V_work_id CHAR(20),
V_sql_str CHAR(1024),V_event CHAR(256),
V_rows SMALLINT
CALL DAT_taskiniFUN("資料檢查")
CALL DAT_set_curr_group("T") #---類別為task
LET V_rows = 0
LET V_sql_str = "SELECT COUNT(*) FROM ",V_tabname CLIPPED,
" WHERE ",V_sql_str CLIPPED
CALL DAT_rec_event(0,V_work_id,V_sql_str)
WHENEVER ERROR CONTINUE
PREPARE V_sql_dat01 FROM V_sql_str
IF STATUS <> 0 THEN
LET V_rows = -1 #--負數為語法問題
LET V_event = "任務ID:",V_work_id CLIPPED,"中SQL語法錯誤。"
CALL DAT_rec_event(-1,V_work_id,V_event)
RETURN V_rows
END IF
WHENEVER ERROR CONTINUE
DECLARE V_sql_exc01 CURSOR FOR V_sql_dat01
FOREACH V_sql_exc01 INTO V_rows
EXIT FOREACH
END FOREACH
WHENEVER ERROR STOP
LET V_event = "任務ID:",V_work_id CLIPPED,"中SQL語法檢查正確,",
"存在資料筆數為:",V_rows
CALL DAT_rec_event(1,V_work_id,V_event)
RETURN V_rows
END FUNCTION
我在程式中執行
CALL DAT_chkSql_getRows("201103190827380002","cusmexh"," prdate[1,6] between '201102' and '201102'") 還回的結果為-1876
有知道的 還請指出什麽問題 多謝! |
|