Hello,
Using PowerBuilder 2017 R3, PostgreSQL 11
Need to pass a string array value to the following query, written in an itemchanged event.
Select count(*) into :ll_count from tableA where series in (:ls_array);
Tried:
Method 1:
String ls_array[]
Long ll-count
ls_array[1] = 'Value1'
ls_array[2] = 'Value2'
Select Count(*) into :ll_count from TableA where series in (:ls_array) ;
This gives the following error:
---------- Compiler: Errors (15:20:02)
basecommon.pbl(w_entry_voucherseries_master_branch).dw_entry.itemchanged.44: Error C0044: Variable reference in database statement has unsupported data type.
---------- Finished Errors (15:20:02)
Method 2:
ls_sql ="Select Count(*) from co_voucherseries_master_branch where prefix = ? And voucherseries in (?) "
PREPARE sqlsa FROM :ls_sql;
Describe Sqlsa into Sqlda ;
Declare my_cursor Dynamic Cursor for Sqlsa ;
SetDynamicParm(Sqlda, 1, ls_prefix)
ll_ret = SetDynamicParm(Sqlda, 2, {'VHCUSTMAS', 'VHSUPPMAS'})
Messagebox('ret', ll_ret)
OPEN DYNAMIC my_cursor using Descriptor Sqlda ;
//EXECUTE Dynamic Procedure :ll_count, :ls_prefix, :ls_checkseries ;
FETCH my_cursor INTO :ll_count ;
CLOSE my_cursor ;
Assigning an array into Parm2 returns -1.
Method 3:
String ls_array
Long ll_count
ls_array = "'Value1', 'Value2'"
Select Count(*) into :ll_count from TableA where series in (:ls_array) ;
Wrong result.
Any ways to pass arrays and get the result without using datawindow or datastore or database procedure. Looks like a simple one, but could not achieve it.
Happiness Always
BKR Sivaprakash
Need to create plenty of datawindow objects, which I want to avoid. Writing a query looks easier in certain (such) conditions. Or should find a way to create datawindow objects from sql, run it and return the result.
Any link or code snippet to create such solutions ?
Created a nvo with a method to accept sql as a parameter, that creates a datawindow object from the passed sql and return the value.
This resolves this issue. Trying to create a more generic solution to return all the columns and rows from the retrieved ds.