if the above code is true, the problem is that you overwrite the ls_sql variable with the where criteria. The ls_sql should contain the whole sql statement including the select * from xytable where key = 1 So you should APPEND the where criteria (but I think you should you retrieval arguments, it is easyier)
PowerBuilder graph DataWindow
-
31-05-2022 - |
문제
I'm new to PowerBuilder 10.5 so I have a question... I created a graph DataWindow. It's a usual graph model, with a simple SQL code.
SELECT data1, data2 FROM table1, table2;
Now I need to get into my "START" command button clicked event and write such a statement which would call my DataWindow under a simple condition:
WHERE key1=key2.
Any advice? I'm trying with the "SETsql" statements?
해결책
다른 팁
There is a simpler way than using the SetSQL()
statement, because the SetSQL
must match the columns that are defined in the DW (you can create them dynamically, but as you state being new to PB I will skip this possibility):
If your SQL statement is always the same and does not need a key provided by code or by the user, you can simply define the
SELECT
directly in the DW painter (menuDesign / Data source
, then in yourcb_start.clicked()
you just callyour_dw.retrieve()
if you need a key that may vary, define it in the
Retrieval arguments
of the DW when in thedata source view
: choose a datatype and a name (e.g.thing
) and in the DWSELECT
syntax you can sayWHERE key1=:thing
(notice the colon) and in the pbscript code in theclicked()
event add the value of the argument in the retrieve argumentsyour_dw.retrieve("42")
. Obviously you can replace the literal by a variable of the correct type that can be defined and populated formerly in the code. If you do not provide the value of retrieval arguments via theretrieve()
statement, the DW will ask for it (or them) in dialog box at the beginning of the retrieval.