Home » U++ Library support » U++ SQL » quick parameter question
quick parameter question [message #53338] |
Mon, 30 March 2020 00:42 |
|
Hi-
I looked everywhere in the docs on-line and forums. Is there a way to do select sql with a parameter either U++ style expr or native? I need something like select acctnum from accounts where acctname = ?.
The ? mark is going to hold the value of an acctname based on the contents of a control. I think I can get at the value of a control by using GetActiveControl();
I'm using postgresql for the db.
thanks!
roboloki
|
|
|
|
Re: quick parameter question [message #53341 is a reply to message #53340] |
Mon, 30 March 2020 01:56 |
|
Hi Novo-
I am just not sure in the syntax for use with the parameter. I see how they do it in an insert statement on the sql tutorial, but I am not sure how to use a select statement with a parameter.
U++ comes with a zillion sql expressions, but for whatever reason, I haven't seen an example with select used for a select statement and a parameter.I could figure out the SQL::SetParam piece, but I don't know how the sql syntax works with that.
I looked in the examples of sql expressions that are in postgresql translated to U++ expressions on the website.
Is there any way someone can give me an example of how to do that with a parameter in the where clause?
Thanks,
roboloki
|
|
|
|
Re: quick parameter question [message #53343 is a reply to message #53342] |
Mon, 30 March 2020 02:19 |
|
Hi Novo-
It was so easy after all. Thanks for the encouragement. Here it is...
sql.SetStatement("Select ACCTNUM from ACCOUNTS WHERE ACCTNAME = ?");
sql.SetParam(0,"ABC");
sql.Execute();
while(sql.Fetch()){ }
etc...
I'm going to be working on U++ during covid.
Have a cool rest of your weekend,
thanks - roboloki
|
|
|
Goto Forum:
Current Time: Thu Mar 28 10:06:27 CET 2024
Total time taken to generate the page: 0.01285 seconds
|