vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi y'all I have a dynamic query in an application program written in C++ that I need to convert from Sybase to DB2. I am unable to figure out how to pass the variable in DB2. Following is the code snippet. .... CString sql = "DECLARE @current_date INT"; sql += " SELECT @current_date = <value>"; sql += " UPDATE <table> " "SET t1.columny = t2.columny " "FROM table1 t1, table2 t2 " "WHERE " ... "t2.columnx <= @current_date"; .... db->executeSql(sql); Currently, I am using Sybase database API to connect to it and will be using ODBC for DB2. The DB2 version is 7.1.2 running on OS/390. Thanks in advance for you replies. Vikas |
| ||||
| vsaraog@gmail.com wrote: > Hi y'all > > I have a dynamic query in an application program written in C++ that I > need to convert from Sybase to DB2. I am unable to figure out how to > pass the variable in DB2. Following is the code snippet. > > ... > CString sql = "DECLARE @current_date INT"; > > sql += " SELECT @current_date = <value>"; > > sql += " UPDATE <table> " > "SET t1.columny = t2.columny " > "FROM table1 t1, table2 t2 " > "WHERE " > ... > "t2.columnx <= @current_date"; > ... > db->executeSql(sql); > > > Currently, I am using Sybase database API to connect to it and will be > using ODBC for DB2. The DB2 version is 7.1.2 running on OS/390. > > Thanks in advance for you replies. > > Vikas > Faszinating... use parameter markers (?) in DB2: " UPDATE <table> " "SET t1.columny = t2.columny " "FROM table1 t1, table2 t2 " "WHERE " ... "t2.columnx <= ?"; I don't know ODBC, but there should be a generic way to bind variacles to the statement when you execute. -- Serge Rielau DB2 SQL Compiler Development IBM Toronto Lab |