PowerBuilder 2019R#, b2703
Windows 64 bit platform
Below in BROWN text is my code to call a PostgreSQL stored procedure using a CURSOR; the CURSOR code is in BLUE. This code is not working, I’m getting this on the OPEN call:
Research says this is most likely a SYNTAX error, however the stored procedure DOES work when you call it as follows in PGADMIN:
exec sp_test_glextract_master('21-JUN-2022');
Notice the output is a series of strings. I want to capture those lines of output and display them in a DW, thus the CURSOR.
Here’s my code:
boolean lb_connected
date ldt_date
long ll_rc, ll_new
string ls_hdr, ls_err, ls_out, ls_date
lb_connected = sqlcG.of_isconnected( )
IF (NOT lb_connected) THEN
ls_hdr = "Not Connected to xxxV5"
ls_err = "We are not connected to the xxxV5 (PG) database." + &
"Please connect to the xxxV5 (pg) database, and try again."
GOTO Exit_script
END IF
// Get the RUN DATE; the format required is 'dd-MON-YYYY'
// - here's the code in the SP: vrun_date := to_date(vIn_Date, 'dd-MON-YYYY');
ls_date = sle_date.Text
// Convert from dd/mm/yyyy to dd-mmm-yyyy for the SP
ldt_date = Date (ls_date)
ls_date = UPPER (String (ldt_date, 'DD-MMM-YYYY'))
// Start the dynamic call to run the stored procedure
DECLARE seq_cursor1 CURSOR FOR sp_test_glextract_master (:ls_date)
USING sqlcG;
// Clear the dw of previous msgs
ll_rc = dw_msgs.Reset ()
// Open the cursor to start the stored procedure
OPEN seq_cursor1;
ll_rc = sqlcG.sqlCode
DO WHILE (ll_rc >= 0)
// Get the next line of output
FETCH seq_cursor1 INTO :ls_out;
// Check the status
ll_rc = sqlcG.sqlCode
IF (ll_rc >= 0) THEN
// Write the output to the DW
ll_new = dw_msgs.InsertRow (0)
ll_rc = dw_msgs.SetItem (ll_new, "msg", ls_out)
ll_rc = dw_msgs.ScrollToRow (ll_new)
END IF
LOOP
// Close the cursor
CLOSE seq_cursor1;
// --------------------------------------
Thanks in advance, folks!