Validate A Query Without Executing In PowerBuilder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | Long ll_rc Long ll_result String ls_sql, ls_test String ls_message //Arbitrary SQL ls_sql = "SELECT * FROM DUAL" //This SQL when executed will always return 0 if successful. ls_test = "select count(*) from ( " + ls_sql + " WHERE 1 = 2 )" Declare l_cursor Dynamic Cursor For SQLSA ; Prepare SQLSA From :ls_test; Open Dynamic l_cursor; ll_rc = SQLCA.SQLCode Choose Case ll_rc Case 0 //Success ls_message = "SQL is properly formed" Case 100 //Fetched row not found. This should not be the case since we only opened the cursor ls_message = SQLCA.SQLErrText Case -1 //Error; the statement failed. Use SQLErrText or SQLDBCode to obtain the detail. ls_message = SQLCA.SQLErrText End Choose Close l_cursor ; //This will fail if open cursor failed. MessageBox( "Result", ls_message ) |
Good Luck!
I enjoyed this post! I read your blog frequently and you’re
always releasing some great information. I’ll be sure to share this
on my FB page and my followers should like this
also. Keep up the good work!
Thank you very much!