|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Accessing Tables Using Function |
« View previous topic :: View next topic » |
Author |
Message
|
venkat kumar |
Posted: Tue Feb 03, 2004 12:40 am Post subject: Accessing Tables Using Function |
|
|
Newbie
Joined: 26 Sep 2003 Posts: 9 Location: Bangalore, India
|
Hi,
i need to access different tables in a database and insert values into them. I thought i will write a function for this, where the function accepts the Table name as one of the arguments. But this is not working as when i say Database.variablename, it tries to access for a table with name "variablename". I also tried using eval() function, but does not work. How do i achieve this ?
Thanks
Venkat |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Feb 03, 2004 6:06 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Have you tried "Database.{variablename}"?
Have you tried using passthru? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
dhincali |
Posted: Tue Feb 03, 2004 11:23 am Post subject: |
|
|
Novice
Joined: 29 Dec 2003 Posts: 22
|
Hi Venkat,
As jeff suggested you can use a Passthru function. Well, this is from the top of my mind. You can try it out in a compute node. EVAL is very costly in MQSI terms and PASSTHRU is the best.
DECLARE NUM_COLS INT 1;
DECLARE IND INTEGER;
DECLARE COLS CHAR ' ';
DECLARE VAL_CNT INT 1;
SET IND = 1;
DECLARE L INT; --anywhere your XML structure begins
DECLARE REF1 REFERENCE TO InputBody.XX.Det[IND];
WHILE LASTMOVE(REF1) = TRUE DO
SET SQL = 'INSERT INTO ' ||
InputRoot.XX.Det[IND].Tablename || ' (';
SET PARMS = '?,';
SET NUM_COLS = CARDINALITY(InputRoot.XX.Det[IND].(XML.Element)*[]);
WHILE L <= NUM_COLS DO
SET COLS = FIELDNAME(InputRoot.XX.Det[IND].(XML.Element)*[J]) || ',';
SET Environment.Values[VAL_CNT] = InputRoot.XX.Det[IND].(XML.Element)*[J];
SET VAL_CNT = VAL_CNT + 1;
SET L = L + 1;
END WHILE;
SET SQL = SQL || COLS || ') ' || 'VALUES( ' || PARMS || ' ) ';
PASSTHRU( SQL, Environment.Values[]);
MOVE OUTERREC NEXTSIBLING REPEAT TYPE NAME;
SET IND = IND + 1;
SET L = 3;
SET VAL_CNT = 1;
END WHILE;
Make sure you mention the DataSource name for the flow. You can otherwise simply give the Database name as follows.
Right click on your Input node and click promote property(Data Source).Mention the database name there.Hope this helps. _________________ learning traveller |
|
Back to top |
|
 |
dhincali |
Posted: Tue Feb 03, 2004 2:58 pm Post subject: |
|
|
Novice
Joined: 29 Dec 2003 Posts: 22
|
Hi,
I assumed you were doin in XML domain and format. Well anyway, hope that helped. _________________ learning traveller |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|