This topic is locked
[SOLVED]

 If Statement and Sql

2/25/2012 3:00:20 PM
ASPRunnerPro General questions
lefty author

I have a table called
PROMOTIONS
one of the fields in this table is approved or not approved . I have and if statement if approved then calculate using sql statement . If not approved then bypass both statements and update record. I have the following code below and have tested it. If I use it with the if statement nothing gets updated even if set toApproved. If I take the if statement out then all gets calculated as it would. See Code below for explanation.
After Update Event ....

Asprunner 7.0
If values("fldreason")=Approved Then
sql ="update POS_Inventory set fldinv = fldinv - " & values("posqty")& " Where pos IN ( Select pos From POS_Inventory where pos = '" & values("fldavail") & "') And Brand IN ( Select Brand from POS_Inventory where Brand = '" & values("fldbrand") & "') And Supplier IN ( Select Supplier from POS_Inventory where Supplier = '" & values("fldsupplier") & "')"

customQuery(sql)
' **End Query to update Inventory table after request approved**
' **Start Querty to update Customer Table to Amount spent (Cusotmer table field is "posbal"

sql="update Customers set posbal=posbal + (" & values("poscost") & "
" & values("posqty")& ") Where [Customer ID] IN (Select [Customer ID] from Customers where [Customer ID] = '" & values("fldcut_num") & "')"

customQuery(sql)
'**
End Query to update Customer Table to Amount spent ( Customer table field is "posbal" ***
Else

End IF
Seems with the if statement nothing gets updated . Syntax problem or If statement.??? No Errors

G
goomba 2/26/2012



I have a table called
PROMOTIONS
one of the fields in this table is approved or not approved . I have and if statement if approved then calculate using sql statement . If not approved then bypass both statements and update record. I have the following code below and have tested it. If I use it with the if statement nothing gets updated even if set toApproved. If I take the if statement out then all gets calculated as it would. See Code below for explanation.
After Update Event ....

Asprunner 7.0
If values("fldreason")=Approved Then
sql ="update POS_Inventory set fldinv = fldinv - " & values("posqty")& " Where pos IN ( Select pos From POS_Inventory where pos = '" & values("fldavail") & "') And Brand IN ( Select Brand from POS_Inventory where Brand = '" & values("fldbrand") & "') And Supplier IN ( Select Supplier from POS_Inventory where Supplier = '" & values("fldsupplier") & "')"

customQuery(sql)
' **End Query to update Inventory table after request approved**
' **Start Querty to update Customer Table to Amount spent (Cusotmer table field is "posbal"

sql="update Customers set posbal=posbal + (" & values("poscost") & "
" & values("posqty")& ") Where [Customer ID] IN (Select [Customer ID] from Customers where [Customer ID] = '" & values("fldcut_num") & "')"

customQuery(sql)
'**
End Query to update Customer Table to Amount spent ( Customer table field is "posbal" ***
Else

End IF
Seems with the if statement nothing gets updated . Syntax problem or If statement.??? No Errors


If I might ask a few questions. What is Approved, I mean is it a Boolean Var, a String, Long (sql:bigint) etc? Try adding thise to your source code:
response.write "" & Approved & "<BR>" : response.end
I use an editor for testing - that way I don't need to regen. This will onviously print the value of Approved surrounded by asteriks.
Hope it helps.

lefty author 2/26/2012



If I might ask a few questions. What is Approved, I mean is it a Boolean Var, a String, Long (sql:bigint) etc? Try adding thise to your source code:
response.write "" & Approved & "<BR>" : response.end
I use an editor for testing - that way I don't need to regen. This will onviously print the value of Approved surrounded by asteriks.
Hope it helps.


Thanks it is a CHAR Type text . I solved the above simply putting If values("fldreason")="Approved" Then

which seems to work fine. Don't know why as signle quotes shoud have worked to. Anyway thanks for the print help I use it know wwith debuggging statements. Thanks. Solved.