- Sivaprakash BKR
- PowerBuilder
- Saturday, 3 November 2018 09:59 AM UTC
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
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.