473,434 Members | 1,854 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,434 software developers and data experts.

dynamic sql EXEC SQL EXECUTE

I have some problems with dynamic SQL statements in DB2

in a c file we have the following statements in sequence:-

1)EXEC SQL DECLARE my_stmt STATEMENT ;
2)EXEC SQL PREPARE my_stmt FROM :SQL_STMT;

here the variable SQL_STMT contains " INSERT INTO MY_INS_TABLE (
CUSTOMER_ID
,CREATEDATE,LASTUPDATEDATE , NAME) (SELECT :v1, current date, current
date,NAME from MY_LOAD_TABLE where FSI=:fsi and FCI=:fci)"

3)EXEC SQL EXECUTE my_stmt
using :CUST_ID ,:fsi ,:fci;

the SQL_ERROR= -727 and error message is in an encrypted format.

SQLERRM: 2˙-418˙42610˙
SQLERRCODE:-727

Is there any way to decrypt an encrypted message thrown by DB2.
OR is there any known problem using Dynamic SQL Statements (with bind
variables) along with 'EXEC SQL EXECUTE' in DB2.
Nov 12 '05 #1
6 25287
"Arti Potnis" <ar******@yahoo.com> wrote in message
news:ec**************************@posting.google.c om...
I have some problems with dynamic SQL statements in DB2

in a c file we have the following statements in sequence:-

1)EXEC SQL DECLARE my_stmt STATEMENT ;
2)EXEC SQL PREPARE my_stmt FROM :SQL_STMT;

here the variable SQL_STMT contains " INSERT INTO MY_INS_TABLE (
CUSTOMER_ID
,CREATEDATE,LASTUPDATEDATE , NAME) (SELECT :v1, current date, current
date,NAME from MY_LOAD_TABLE where FSI=:fsi and FCI=:fci)"

3)EXEC SQL EXECUTE my_stmt
using :CUST_ID ,:fsi ,:fci;

the SQL_ERROR= -727 and error message is in an encrypted format.

SQLERRM: 2˙-418˙42610˙
SQLERRCODE:-727

Is there any way to decrypt an encrypted message thrown by DB2.
OR is there any known problem using Dynamic SQL Statements (with bind
variables) along with 'EXEC SQL EXECUTE' in DB2.


Did you check out the Messages and Codes manual? All manuals can be
downloaded from the IBM website in PDF format. The SQLERRCODE messages are
in volume 2.
Nov 12 '05 #2
db2 => ? SQL0418;
SQL0418N A statement contains a use of a parameter marker that
is not valid.

Actually I think your ptoblem is the reverse: You try to use
Hostvariables where you should use parameter markers.

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
Serge Rielau <sr*****@ca.eye-be-em.com> wrote in message news:<ca**********@hanover.torolab.ibm.com>...
db2 => ? SQL0418;
SQL0418N A statement contains a use of a parameter marker that
is not valid.

Actually I think your ptoblem is the reverse: You try to use
Hostvariables where you should use parameter markers.

Cheers
Serge


I have tried with various combinations like:-
1)my_stmt is :-
INSERT INTO MY_INS_TABLE (
CUSTOMER_ID,CREATEDATE,LASTUPDATEDATE , NAME) (SELECT ?, current date, current
date,NAME from MY_LOAD_TABLE where FSI=? and FCI=?)"

EXEC SQL EXECUTE my_stmt
using :CUST_ID ,:fsi ,:fci;

ERROR:SQL0418

2)my_stmt is :-
INSERT INTO MY_INS_TABLE (
CUSTOMER_ID,CREATEDATE,LASTUPDATEDATE , NAME) (SELECT :v1, current date, current
date,NAME from MY_LOAD_TABLE where FSI=:v2 and FCI=:v3)"

EXEC SQL EXECUTE my_stmt
using :CUST_ID ,:fsi ,:fci;

ERROR: SQL0312
Nov 12 '05 #4
Check the "Programming Client Applications" manual. It has a great
section (with examples) on dynamic SQL.

Your SQL statement raises questions about why you are trying to use
dynamic SQL. Dynamic SQL incurs additional run-time costs for the
prepare. There is also potential for additional contention on the
catalog during prepare. Using Parameter markers looses the greatest
benefit (optimization) of dynamic SQL over static SQL.

From the manual:
"The recommendation is to use static SQL with host variables or dynamic
SQL without parameter markers as the most efficient options."

Phil Sherman
Arti Potnis wrote:
Serge Rielau <sr*****@ca.eye-be-em.com> wrote in message news:<ca**********@hanover.torolab.ibm.com>...
db2 => ? SQL0418;
SQL0418N A statement contains a use of a parameter marker that
is not valid.

Actually I think your ptoblem is the reverse: You try to use
Hostvariables where you should use parameter markers.

Cheers
Serge

I have tried with various combinations like:-
1)my_stmt is :-
INSERT INTO MY_INS_TABLE (
CUSTOMER_ID,CREATEDATE,LASTUPDATEDATE , NAME) (SELECT ?, current date, current
date,NAME from MY_LOAD_TABLE where FSI=? and FCI=?)"

EXEC SQL EXECUTE my_stmt
using :CUST_ID ,:fsi ,:fci;

ERROR:SQL0418

2)my_stmt is :-
INSERT INTO MY_INS_TABLE (
CUSTOMER_ID,CREATEDATE,LASTUPDATEDATE , NAME) (SELECT :v1, current date, current
date,NAME from MY_LOAD_TABLE where FSI=:v2 and FCI=:v3)"

EXEC SQL EXECUTE my_stmt
using :CUST_ID ,:fsi ,:fci;

ERROR: SQL0312


Nov 12 '05 #5

INSERT INTO MY_INS_TABLE (
CUSTOMER_ID,CREATEDATE,LASTUPDATEDATE , NAME)
(SELECT
?, -- <-- TROUBLE HERE
current date, current
date,NAME from MY_LOAD_TABLE where FSI=? and FCI=?)

You need to cast(? as <datatype>)

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #6
Serge Rielau <sr*****@ca.eye-be-em.com> wrote in message news:<ca**********@hanover.torolab.ibm.com>...
INSERT INTO MY_INS_TABLE (
CUSTOMER_ID,CREATEDATE,LASTUPDATEDATE , NAME)
(SELECT
?, -- <-- TROUBLE HERE
current date, current
date,NAME from MY_LOAD_TABLE where FSI=? and FCI=?)

You need to cast(? as <datatype>)

Cheers
Serge

-----------------------------
Thanks a lot. It worked.

-Arti.
Nov 12 '05 #7

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

Similar topics

14
by: Hemanth | last post by:
Hello there, I'm new to PHP. I'm trying to run a simple php script (on a Red hat linux machine with apache web server ) through a windows web browser (IE). I'm using an exec() function in my...
1
by: PJ | last post by:
<% Set Conn = Server.CreateObject("ADODB.Connection") Conn.open application("dtat_motor_connectionstring") set rs = new adodb.recordset 'Set RS = Conn.Execute(' "exec spcn_update_transactions &...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
31
by: NickName | last post by:
/* goal: dynamic evaluation of table row platform: sql 2000 */ use northwind; declare @tbl sysname set @tbl = 'customers' EXEC('select count(*) from ' +@tbl)
3
by: JDPope | last post by:
I have a situation which I cannot get a good lead on how to resolve. One of the applications I support uses the Hibernate software to generate SQL. The app is JAVA with JDBC. In testing the users...
2
by: Wei Wang | last post by:
Hi, I want to do a select in dynamic command, something like: TRIGGER FUNCTION DECLARE table_name_suffix text; temp_result RECORD; temp_result2 RECORD;
2
by: chets | last post by:
Hi All, I am facing problem in executing one dynamic query in PRO *C program on linux. I want to update table mytable by data MADURAI for a column mycolumn1 where primary key is myPK.I want to...
3
by: Madhavi Moravaneni | last post by:
can anybody give the syntax? How to use all_tab_columns in from clause with where codition in dynamic SQL (execute immediate) .
0
by: tickle | last post by:
Need to convert this PL/SQL script to Dynamic SQL Method 2 * copybook - celg02u3.sql SIR 24265 * * updates dt_deny for all rows in * * ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.