Posted: Fri Jul 12, 2002 12:12 pm Post subject: Need help from ESQL guru
Apprentice
Joined: 04 Jun 2002 Posts: 26
This is my input message:
<Message>
<ACTION>INSERT</ACTION>
<TEST1>HIT1 10</TEST1>
</Message>
This is what is in my database node and it works. Please note I hardcoded the table
name and the column name in the insert statement.
If Body.Message.ACTION = 'INSERT' THEN
INSERT
INTO Database.DAVID.TEST1 (COL1)
VALUES (Body.Message.TEST1);
END IF;
However, I would like NOT to hardcode the the insert statement with the table name and column name but have them picked up from some varaibles ; that is,
I would like my input message to be
<Message>
<ACTION>INSERT</ACTION>
<TABLE>DAVID.TEST1</TABLE>
<COLUMN>COL1</COLUMN>
<TEST1>HIT1 10</TEST1>
</Message
How to code the database node to pick up the table name and column name dynamically ?
If Body.Message.ACTION = 'INSERT' THEN
INSERT
INTO Database.XXXX (YYY )
VALUES ((Body.Message.TEST1);
END IF;
what ESQL functions should I use to resolve XXXX to David.TEST1
and YYY to COL1 ?
Posted: Fri Jul 12, 2002 1:58 pm Post subject: How to pick up the table name dynamically from the insert DB
Apprentice
Joined: 04 Jun 2002 Posts: 26
I can resolve the value of YYY by declaring
DECLARE YYY REFERENCE TO Body.Message.COLUMN and it works.
Howver it still fails on the XXX because after INTO it expects 'Database' keyword
These are what I have UNSUCCESSFULLY tried :
If Body.Message.ACTION = 'INSERT' THEN
INSERT
INTO Body.Message.TABLE (YYY ) // It fails because it expects the Database keyword
VALUES ((Body.Message.TEST1);
END IF;
DECLARE TABLE CHARACTER;
SET TABL=Body.Message.TABLE;
If Body.Message.ACTION = 'INSERT' THEN
INSERT
INTO Database.(SUBSTRING(TABL FROM 1 FOR LENGTH(TABL)))(YYY )
-- It fails because it thinks Database.(SUBSTRING.....as the database name)
VALUES ((Body.Message.TEST1);
END IF;
Joined: 05 Sep 2001 Posts: 3779 Location: Torrance, CA, USA
You could try using EVAL statement to build your INSERT statement dynamically. _________________ Kiran
IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries
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