10-07-2008 12:25 PM
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 .
10-07-2008 9:07 PM
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.