Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Insert statement

Former Member
0 Kudos

Hi Experts ,

I have a reqment to connect to remote database with entry maintained in DBCON table .I am replacing the open SQL with kind of native SQL thru classes

I am making use of instances of Cl_SQL_CONNECTION and its related classes .

I am finding a problem with the insert statement .

the earlier program used to be

insert into zabcd values wa_insert.

Now for DB2 remote connectivity , I replac the insert with

concatenate

'insert into' c_tabname 'values ('''wa_insert-f1,'''wa_abcd-f2'','''wa_insert-f3'')'

into l_stmt separated by space.

and then i pass this l_stmt to the l_prepstmt_ref which is an instance of cl_sql_prepared_statement

l_prepstmt_ref->execute_update( l_stmt ).

Now my problem is

if i write insert like

'insert into' c_tabname 'values ('''wa_insert''')' into l_stmt seperated by space .

SQL0117N The number of values assigned is not the same as the number of specified or implied columns.

Is there anyway to pass like above .

1 REPLY 1

Former Member
0 Kudos

Try something like this:

DATA: code TYPE TABLE OF rssource-line.

DATA:STRPR TYPE STRING.

data:i type i.

data:ci type c.

data:cstr(200) type c.

APPEND 'REPORT ZTESTING2.' TO CODE.

APPEND 'EXEC SQL.' TO CODE.

i = 8.

ci = i.

concatenate 'select agzdau into :gf_agzdau from APZD0'ci '/AG' into cstr.

append cstr to code.

APPEND ' where AGMAID = ''77732'' and' to code.

APPEND ' AGJAHR = 2008 and' to code.

APPEND ' AGMON = 09 and' to code.

APPEND ' AGSPAL = ''ZASALD'' to code.

APPEND ' %_HINTS AS400 ''HARD_CLOSE''' to code.

ENDEXEC.

INSERT REPORT 'ZTESTING' FROM code.

SUBMIT ZTESTING AND RETURN.