Question

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?

Was it helpful?

Solution

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)

OTHER TIPS

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 (menu Design / Data source, then in your cb_start.clicked() you just call your_dw.retrieve()

  • if you need a key that may vary, define it in the Retrieval arguments of the DW when in the data source view: choose a datatype and a name (e.g. thing) and in the DW SELECT syntax you can say WHERE key1=:thing (notice the colon) and in the pbscript code in the clicked() event add the value of the argument in the retrieve arguments your_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 the retrieve() statement, the DW will ask for it (or them) in dialog box at the beginning of the retrieval.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top