Dathan Camacho
New Member
- Joined
- Mar 30, 2010
- Messages
- 37
I'm using an Excel macro to run several SQL queries. Some are Teradata queries, and one query is a DB2 query.
To synch up all the queries to return comparable data, I’m using a column in a worksheet to define parameters for the SQL where statements. This lets me control the inputs in one place.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
This simple code, where Inputs is an Excel worksheet, associates the worksheet values with a variable I'm calling SQL_Where_Parameter:
<o></o>
<o></o>
Here’s the part I need help with:<o></o>
<o></o>
The queries that hit Teradata are working just fine using this method to call the worksheet inputs:<o></o>
<o></o>
<o></o>
I used the same syntax in the DB2 query, but it doesn’t work. Here is the error returned from DB2:<o></o>
Any insight appreciated, thanks!
To synch up all the queries to return comparable data, I’m using a column in a worksheet to define parameters for the SQL where statements. This lets me control the inputs in one place.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
This simple code, where Inputs is an Excel worksheet, associates the worksheet values with a variable I'm calling SQL_Where_Parameter:
Code:
[FONT=Calibri][COLOR=black]With Inputs[/COLOR][/FONT]
[FONT=Calibri][COLOR=black]LastRow = .Cells(Rows.Count, "A").End(xlUp).Row<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=black]SQL_Where_Parameter = "'" & Join(Application.Transpose(Sheets("Inputs").Range("A" & FIRST_DATA_ROW & ":A" & LastRow).Value), "','") & "'"<o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=black]<o:p></o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Calibri]End With[/FONT][/COLOR]
<o></o>
Here’s the part I need help with:<o></o>
<o></o>
The queries that hit Teradata are working just fine using this method to call the worksheet inputs:<o></o>
Code:
[FONT=Calibri][COLOR=black]select… [/COLOR][/FONT]
[FONT=Calibri][COLOR=black]from… <o:p></o:p>[/COLOR][/FONT]
[FONT=Calibri][COLOR=black]where t.table_column in (" & SQL_Where_Parameter & ") <o:p></o:p>[/COLOR][/FONT]
[COLOR=black][FONT=Calibri]group by…[/FONT][/COLOR]
<o></o>
I used the same syntax in the DB2 query, but it doesn’t work. Here is the error returned from DB2:<o></o>
Does anyone know the correct syntax? I haven’t been able to solve it through trial and error.Run-time error '-2147467259 (80004005)':
[IBM][CLI Driver][DB2] SQL0401N The data types of the operands for the operation "" are not compatible. SQLSTATE=42818
Any insight appreciated, thanks!