Five Stars

Appending Tables: One Issue

Hello. Here is what I want to do:

1. During runtime, use SQL to get a *value* (date) from the target table (such as the last update date).

2. Use the *value* in a SQL WHERE clause to pull just the needed subset of data from the source table.

3. Append the subset of source data to the target table.

 

The problem I am having is injecting the *value* into the SQL WHERE clause. I can get the *value* through a lookup (tMSSqlInput), but I do not know how to pass that value into the SQL code. 

 

Example code.

SELECT
ID,
Name,
Address1,
Address2,
City,
Zip,
UpdateDate
FROM dbo.DatabaseSource.Table
WHERE UpdateDate > passedIn*Value*

 

 

Thanks for any help!

 

Alllen

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Twelve Stars TRF
Twelve Stars

Re: Appending Tables: One Issue

Store the value into a global variable (as the result of a tMSSQLInput for example) the reuse the variable to construct the select like this:

"SELECT
ID,
Name,
Address1,
Address2,
City,
Zip,
UpdateDate
FROM dbo.DatabaseSource.Table
WHERE UpdateDate > '" + (String)globalMap.get("yourVariableHere") + "'"

Hope this helps.


TRF
2 REPLIES
Highlighted
Twelve Stars TRF
Twelve Stars

Re: Appending Tables: One Issue

Store the value into a global variable (as the result of a tMSSQLInput for example) the reuse the variable to construct the select like this:

"SELECT
ID,
Name,
Address1,
Address2,
City,
Zip,
UpdateDate
FROM dbo.DatabaseSource.Table
WHERE UpdateDate > '" + (String)globalMap.get("yourVariableHere") + "'"

Hope this helps.


TRF
Seven Stars sgv
Seven Stars

Re: Appending Tables: One Issue

Hello,

if you can get the *value* you have to put it on globalMap with the following code :  globalMap.put("myValue", *value*)

 

then in your sql code you can write this :  "select * from table where column = ' "+(String)globalMap.get("myValue")+" ' "

 

hope this help,

 

Good luck,

SGV