Conditional IF by SQL

PaulJL

New Member
Joined
Oct 9, 2002
Messages
48
I am trying to build 2 SQL statements that are only executed if they fulfill the If..Then conditional statements below. I have a parameter called approve that can have the value of "Yes" or "No". Please note that the SQL works fine without the If...Then. I've tried all the combinations but I am getting nowhere:

If '::approve::'='Yes' Then
UPDATE customer_IN SET approve='::approve::', client_notes_to_ubm='::notes::', cleared_bank='cleared' WHERE customer_account_ref='::customer_reference::' AND account_name='::account_name::'
End If

If '::approve::'<>'Yes' Then
UPDATE customer_IN SET approve='::not_approved::', client_notes_to_ubm='::notes::', cleared_bank='cleared' WHERE customer_account_ref='::customer_reference::' AND account_name='::account_name::'
End If

If someone could kindly help me if it is possible to wrap 2 SQL statements in If..Then conditions.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
On 2002-12-05 10:52, PaulJL wrote:
I am trying to build 2 SQL statements that are only executed if they fulfill the If..Then conditional statements below. I have a parameter called approve that can have the value of "Yes" or "No". Please note that the SQL works fine without the If...Then. I've tried all the combinations but I am getting nowhere:

If '::approve::'='Yes' Then
UPDATE customer_IN SET approve='::approve::', client_notes_to_ubm='::notes::', cleared_bank='cleared' WHERE customer_account_ref='::customer_reference::' AND account_name='::account_name::'
End If

If '::approve::'<>'Yes' Then
UPDATE customer_IN SET approve='::not_approved::', client_notes_to_ubm='::notes::', cleared_bank='cleared' WHERE customer_account_ref='::customer_reference::' AND account_name='::account_name::'
End If

If someone could kindly help me if it is possible to wrap 2 SQL statements in If..Then conditions.

I'm confused. You are having the user enter a parameter which you name "approve", then you want to update that same field ("approve") to something else? First, I think you should re-name the parameter that the user enters. For this example, let's call it APP.

Try the IIF function. Something like:

SET approve=IIF([APP]="YES",'::approve::','::not_approved::'), client_notes_....

You may want to put in a UCase([APP]) to account for the case where "yes" is put in. Note that this will change anything other than yes to not_approved.

HTH,

Rusell
 
Upvote 0

Forum statistics

Threads
1,221,490
Messages
6,160,133
Members
451,622
Latest member
xmrwnx89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top