Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Building an Update statement

Status
Not open for further replies.

Cullenward

Programmer
Jun 1, 2006
7
US
Is there a way to build an update statement piece by piece?

For example, depending on which variables have values I would like to add them to the WHERE clause and then execute the update statement.

so when variable var1 is greater than 100 it would add

AND var1 > 100

to the where statement, but if it was less than 100 it wouldn't. I'm trying to avoid having 10-20 IF statements to account for the different situations.
 
U can use the GenerateSQL in order to suffice for ur requirement.
You will then need to create a Datastore and assign this SQL to it....
 
In the sqlpreview event of the datawindow you can examine and alter the statement prior to it being sent to the database. You can add any additional where clauses and whatnot prior to executing a setsqlpreview command to send the modified statement to the database.

Matt

"Nature forges everything on the anvil of time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top