Have you tried to use a parameter marker for the data structure?
Sqlstmt = 'Insert Into ' + %trimr( wxlib ) + '/' + %trimr( wxdb ) + ' ' +
' ? rows values(?)';
Exec SQL Prepare ....;
Exec SQL Execute using(:rowsreturned, :ds);
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
stefan@xxxxxxxxxx
Sent: Dienstag, 27. Juli 2021 10:44
To: RPG400-L@xxxxxxxxxxxxxxxxxx
Subject: How to prepare a multi-row insert?
Hi!
Having this working insert into statement:
exec sql
Insert Into TAGSTE/CPDETAILS :rowsreturned rows
values( :ds );
Now I need to be able to change the table name/library.
My understanding is that host variables cannot be used in a prepared
statement so:
Sqlstmt = 'Insert Into ' + %trimr( wxlib ) + '/' + %trimr( wxdb ) + ' ' +
' ? rows values(' + ds + ')';
exec sql
prepare tcanzjrn_insert_cpdetails
from :sqlstmt;
exec sql
execute tcanzjrn_insert_cpdetails
using
:rowsreturned;
The ds is declared as:
dcl-ds ds qualified dim(100);
CPCODE CHAR( 1 ); // Journal code
CPENTT CHAR( 2 ); // Entry type
CPTSTP TIMESTAMP; // Timestamp of entry
...
end-ds;
The compiler pukes at my first sqlstmt assignment by claiming:
*RNF5343 30 1 Array has too many omitted indexes; specification is
ignored.
How can I circumvent this?
Thanks!
Stefan Tageson
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.