473,382 Members | 1,386 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to pass variable in dynamic SQL?

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

Nov 12 '05 #1
1 2808
vs*****@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
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: J.R. | last post by:
Hi folks, The python can only support passing value in function call (right?), I'm wondering how to effectively pass a large parameter, such as a large list or dictionary? It could achieved...
23
by: John | last post by:
Last year, I remember finding a web page describing how to pass the name of a file to another web page, and have that web page load that image file. Now, I can't find my record of that (it was...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
6
by: david | last post by:
For example, I can call <xsl:value-of select="concat('name','(',value,')')"/>, is there anyway I can pass the expression concat('name','(',value,')') as a variable from outside the template? ...
3
by: markaelkins | last post by:
Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am basically trying to send an ID variable into sql to return different records. I've searched everywhere and cannot find the...
12
by: FI | last post by:
Hello All, I am relatively new to C programming and I am struck with a problem in dynamic memory allocation. I would like to know if it is ok to pass the 'memory address' returned by...
4
by: simon | last post by:
hello. relatively new to vb.net, i'm using VS 2003 and .net 2.0 i have a web app that i'm i have a user control that displays a simple 1 row table as the header of the page. the user control...
16
by: John | last post by:
Does the length of my C variable names have any affect, performance-wise, on my final executable program? I mean, once compiled, etc., is there any difference between these two: number = 3; n =...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.