Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » quick parameter question
quick parameter question [message #53338] Mon, 30 March 2020 00:42 Go to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

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 #53340 is a reply to message #53338] Mon, 30 March 2020 01:33 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
Have you checked Sql::SetParam already?

Regards,
Novo
Re: quick parameter question [message #53341 is a reply to message #53340] Mon, 30 March 2020 01:56 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

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 #53342 is a reply to message #53341] Mon, 30 March 2020 02:04 Go to previous messageGo to next message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

HI Novo-

I think I've got it now. No worries.

It is under the reference docs.

Thanks!
Re: quick parameter question [message #53343 is a reply to message #53342] Mon, 30 March 2020 02:19 Go to previous message
mtdew3q is currently offline  mtdew3q
Messages: 181
Registered: July 2010
Location: Upstate, NY (near Canada)
Experienced Member

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
Previous Topic: Soci developer leaving
Next Topic: Copy from stdin (PostgreSQL) support in U++ SQL
Goto Forum:
  


Current Time: Thu Mar 28 10:06:27 CET 2024

Total time taken to generate the page: 0.01285 seconds