Grupy dyskusyjne Google nie obsługują już nowych postów ani subskrypcji z Usenetu. Treści historyczne nadal będą dostępne.

Insert in table on Oracle database using JDBC within RPG?

226 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Joe

nieprzeczytany,
30 sty 2009, 10:00:1630.01.2009
do
I have a requirement to load data from DB2/400 into an Oracle database
table.

I have gotten the sample code (JDBCR4,etc) from Scott Klement's
article on accessing the oracle database via JDBC in RPG, however no
matter how setup the do loop processing the DB2/400 file I end up with
only the last record in the Oracle database table.

I looked on the Oracle sight and found an example of intserting
multiple rows into a table and based my code to basically perform one
insert per record read from the DB2/400 file. Yet when I look at the
oracle table I only see 1 row which is the last record in the DB2/400
file.

Has anyone else used JDBCR4 to actualy insert multiple rows into a
database table?

Any help would be greatly appreciated!

Below is the section of my code that is supposed to do this(RPG ILE):

// Add to the database table

stmt = jdbc_PrepStmt( conn : 'INSERT INTO HOLDING '
+ ' (CO_ID, BRH_NBR, ORD_ID, ORD_LN_ID, '
+ ' PROD_ID, BRH_NM)'
+ ' values(?,?,?,?,?,?) '
);
if (stmt = *NULL);
ErrMsg = 'Prepare Statement failed!';
return;
endif;

recno = 0;

setgt recno bldprc;

dou %eof;

read bldprc;

if %eof;

JDBC_setString (stmt: 1: coid : *OFF);
JDBC_setString (stmt: 2: brhnbr : *OFF);
JDBC_setString (stmt: 3: ORDID : *OFF);
JDBC_setInt (stmt: 4: ORDLNID : *OFF);
JDBC_setString (stmt: 5: PRODID : *OFF);
JDBC_setString (stmt: 6: BRANCH : *OFF);

rc = JDBC_ExecPrepUpd( stmt );

if (rc < 0);
ErrMsg = 'Execute Prepared Failed!';
return;
endif;

JDBC_Commit( conn );

endif;


enddo;

JDBC_FreePrepStmt( stmt );


dieter...@t-online.de

nieprzeczytany,
30 sty 2009, 13:15:0930.01.2009
do
Hi,

i would not recommend this kind of embedded java in RPG and use Java to do
the transfer. For Batch like transfers I have written an open Source Tool
called TransferData, its fully parametrized (driver properties, select
statement of the Source database and insert statement and driver settings
of the target database) you will find it at my (sorry) german wepsite
www.bender-dv.de . If you have problems with the language, feel free to
send me an email (you will find the email adress at my website.
For interactive record by record transfer I have written an appserver4rpg
ist open Source too and you will find it at my website or at sourceforge.

Dieter Bender

Kaj Julius

nieprzeczytany,
8 lut 2009, 17:47:328.02.2009
do

"Joe" <jcha...@chathamsteel.com> skrev i en meddelelse
news:ef931d9e-7866-4144...@i24g2000prf.googlegroups.com...

You only execute the insert on %EOF - this must be changed to 'If not %EOF'
for it to work.


Nowe wiadomości: 0