ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL - trying to insert into database

Post new topic  Reply to topic
 ESQL - trying to insert into database « View previous topic :: View next topic » 
Author Message
Jane
PostPosted: Mon May 24, 2004 7:09 am    Post subject: ESQL - trying to insert into database Reply with quote

Newbie

Joined: 22 Apr 2004
Posts: 8

Hi,

I am trying to insert into a database from an XML formatted file with an element 'Containers' that can occur multiple times within the file. Then each of the child elements need to be inserted as a single row in the DB2 table. My ESQL is as follows:

CREATE PROCEDURE PackInsert(IN K INTEGER)
BEGIN
DECLARE PackBookAgtSub CHARACTER;
DECLARE PackBookAgtNbr INTEGER;
DECLARE PackEstNbr CHARACTER;
DECLARE PackAgtSub CHARACTER;
DECLARE PackAgtNbr INTEGER;
DECLARE PackCodeServofPnt CHARACTER;
DECLARE PackRateTypeCode CHARACTER;
DECLARE PackOtRateused CHARACTER;
DECLARE PackFullUnpackIndt CHARACTER;
DECLARE PackItemCode CHARACTER;
DECLARE PackCartonCode INTEGER;
DECLARE PackQuantity1 INTEGER;
DECLARE B INTEGER 1;
DECLARE C INTEGER;


SET OutputRoot.*[K] = InputRoot.*[K];
SET C = CARDINALITY(InputBody.order_hhg[K].containers[]);

SET PackBookAgtSub = InputBody.order_hhg
[K].estimate_id.booking_agt_subsidiary;
SET PackBookAgtNbr = InputBody.order_hhg
[K].estimate_id.booking_agt_number;
SET PackEstNbr = InputBody.order_hhg
[K].estimate_id.est_number;

--Containers
SET B = 1;

WHILE B < C DO

SET PackAgtSub = InputBody.order_hhg[K].containers
[B].agt_subsidiary;
SET PackAgtNbr = InputBody.order_hhg[K].containers
[B].agt_number;
SET PackCodeServofPnt = InputBody.order_hhg[K].containers
[B].point_of_service;
SET PackItemCode = '054';
SET PackRateTypeCode = 'CT';
SET PackOtRateused = InputBody.order_hhg[K].containers
[B].ot_rateused;
SET PackFullUnpackIndt = ' ';

If InputBody.order_hhg[K].containers[B].dish > 0 then
SET PackCartonCode = 005;
SET PackQuantity1 = InputBody.order_hhg[K].containers
[B].dish;
CALL InsertPacking( PackBookAgtSub,
PackBookAgtNbr, PackEstNbr,
PackAgtSub,
PackAgtNbr,
PackCodeServofPnt,
PackRateTypeCode,
PackOtRateused,
PackFullUnpackIndt,
PackItemCode,
PackCartonCode,
PackQuantity1,
C);

End If;

If InputBody.order_hhg[K].containers[B].c15 > 0 then
SET PackCartonCode = 010;
SET PackQuantity1 = InputBody.order_hhg[K].containers
[B].c15;

CALL InsertPacking(
PackBookAgtSub,
PackBookAgtNbr,
PackEstNbr,
PackAgtSub,
PackAgtNbr,
PackCodeServofPnt,
PackRateTypeCode,
PackOtRateused,
PackFullUnpackIndt,
PackItemCode,
PackCartonCode,
PackQuantity1,
C);
End if;

SET B = B + 1;

END WHILE;


CREATE PROCEDURE InsertPacking(
INOUT PackBookAgtSub CHARACTER,
INOUT PackBookAgtNbr INTEGER,
INOUT PackEstNbr CHARACTER,
INOUT PackAgtSub CHARACTER,
INOUT PackAgtNbr INTEGER,
INOUT PackCodeServofPnt CHARACTER,
INOUT PackRateTypeCode CHARACTER,
INOUT PackOtRateused CHARACTER,
INOUT PackFullUnpackIndt CHARACTER,
INOUT PackItemCode CHARACTER,
INOUT PackCartonCode INTEGER,
INOUT PackQuantity1 INTEGER,
INOUT C INTEGER)

BEGIN

INSERT INTO Database.TESTPACK
(NBR_AGT_EST,
NBR_EST,
CODE_SUB_CMPY_EST,

IDEN_SCRN, DESC_ITEM,
cont with rest of table columns)

VALUES
(PackBookAgtNbr, SUBSTRING(PackEstNbr FROM 1 FOR 7),
SUBSTRING(PackBookAgtSub FROM 1 FOR 1),
' ',
COALESCE(PackAgtNbr,0),
SUBSTRING(COALESCE(PackCodeServofPnt,' ')
FROM 1 FOR 1),
' ',
' ',
' ',
' ',
' ',
' ',
' ',
SUBSTRING(COALESCE(PackItemCode,' ') FROM 1 FOR 3),
' ',
COALESCE(PackCartonCode,0),
SUBSTRING(COALESCE(PackRateTypeCode,' ') FROM 1 FOR 2),
' ',
' ',
0.00,
0.00,
SUBSTRING(COALESCE(PackOtRateused,' ') FROM 1 FOR 1),
' ',
' ',
COALESCE(PackQuantity1,0),
C,
0,
0,
0,
0,
0,
0,
' ',
0,
0,
CURRENT_TIMESTAMP,
'UPLD',
' ',
' ',
SUBSTRING(COALESCE(PackAgtSub,' ') FROM 1 FOR 1),
' ',
' ',
' ',
0,
' ',
' ',
' ',
SUBSTRING(COALESCE(PackFullUnpackIndt,' ') FROM 1 FOR 1)
);


IF ((SQLCode <> 0) and (SQLSTATE <> 23502)) then

THROW USER EXCEPTION MESSAGE 2950 VALUES
('TESTPACK',SQLSTATE,SQLCODE,SQLERRORTEXT,SQLNATIVEERROR);

END IF;


END;

END MODULE;
Back to top
View user's profile Send private message
Jane
PostPosted: Mon May 24, 2004 7:12 am    Post subject: ESQL - insert to database table Reply with quote

Newbie

Joined: 22 Apr 2004
Posts: 8

Sorry,

Additional information to original message. We are using MQ Integrator Version 5.1. The code only inserts the one row of the container element,
when my input has two container elements. I inserted the Cardinality value into one of the rows on the table and it is displaying '2'.

What am I missing with the ESQL to get the second row to insert?

Thank you,
Jane
Back to top
View user's profile Send private message
JT
PostPosted: Mon May 24, 2004 8:22 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

Code:
WHILE B < C DO

You want:
Code:
WHILE B <= C DO

A debug trace would have shown this condition failed on the second occurrence.
Back to top
View user's profile Send private message
Jane
PostPosted: Mon May 24, 2004 8:28 am    Post subject: ESQL - trying to insert into a database Reply with quote

Newbie

Joined: 22 Apr 2004
Posts: 8

Thank you JT for the info. We cannot use the Debug trace here because
it locks up the Configuration Manager.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL - trying to insert into database
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.