I'm trying to use a data driven query. What I'm tyring to do is - I'm bringing in a file from the as/400 and populating the sql server with the data. I want to either update or write depending on whether it already exists. I've found a sample of a data driven query in a book but it uses a case statement. What I'd like to do is use an if statment instead. But when I try to use the if its giving me a syntex error. Here's the code I'm trying to use.
Function Main()
If DTSDestination("StoreNumber"
=
DTSSource("DSRHSTR"
And
DTSDestination("Controller"
=
DTSSource("DSRHCTL"
And
DTSDestination("Register#"
=
DTSSource("DSRHREG"
And
DTSDestination("Transaction#"
=
DTSSource("DSRHTR#"
And
DTSDestination("TransactionDate"
= cdate(DTSSource("DSRHDATI"
) & " " & timevalue(DTSSource("DSRHTIME"
)
Then
DTSDestination("StoreIndex"
= DTSSource("DSRHSTX"
DTSDestination("Controller"
= DTSSource("DSRHCTL"
DTSDestination("Register#"
= DTSSource("DSRHREG"
DTSDestination("Transaction#"
= DTSSource("DSRHTT"
DTSDestination("TransactionDate"
= cdate(DTSSource etc...
Main = DTSTransformstat_UpdateQuery
Else
DTSDestination("StoreIndex"
= DTSSource("DSRHSTX"
DTSDestination("Controller"
= DTSSource("DSRHCTL"
DTSDestination("Register#"
= DTSSource("DSRHREG"
DTSDestination("Transaction#"
= DTSSource("DSRHTT"
DTSDestination("TransactionDate"
= cdate(DTSSource etc...
Main = DTSTransformstat_InsertQuery
Endif
End Function
Then after I have this working I woould go under the queries tab inthe data driven query and create the insert and update queries. But I can't seem to get this script to parse. Its getting the error on the if statment. All it gives me is syntax error. Not sure what the problem is. Any ideas?
Stacy
Function Main()
If DTSDestination("StoreNumber"
DTSSource("DSRHSTR"
DTSDestination("Controller"
DTSSource("DSRHCTL"
DTSDestination("Register#"
DTSSource("DSRHREG"
DTSDestination("Transaction#"
DTSSource("DSRHTR#"
DTSDestination("TransactionDate"
Then
DTSDestination("StoreIndex"
DTSDestination("Controller"
DTSDestination("Register#"
DTSDestination("Transaction#"
DTSDestination("TransactionDate"
Main = DTSTransformstat_UpdateQuery
Else
DTSDestination("StoreIndex"
DTSDestination("Controller"
DTSDestination("Register#"
DTSDestination("Transaction#"
DTSDestination("TransactionDate"
Main = DTSTransformstat_InsertQuery
Endif
End Function
Then after I have this working I woould go under the queries tab inthe data driven query and create the insert and update queries. But I can't seem to get this script to parse. Its getting the error on the if statment. All it gives me is syntax error. Not sure what the problem is. Any ideas?
Stacy