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 » Inserting into SolidDB using ESQL

Post new topic  Reply to topic
 Inserting into SolidDB using ESQL « View previous topic :: View next topic » 
Author Message
tank_n_spank
PostPosted: Mon Sep 22, 2014 7:20 am    Post subject: Inserting into SolidDB using ESQL Reply with quote

Apprentice

Joined: 02 Sep 2014
Posts: 37

Hello,

I am currently trying to insert an XML file into a SolidDB table by just using an ESQL note.

Code:

CREATE COMPUTE MODULE InstProc_Compute
   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      -- CALL CopyMessageHeaders();
      CALL CopyEntireMessage();
      
      DECLARE MsgBlob BLOB;
      DECLARE Msg CHARACTER;
      DECLARE MID CHARACTER;
      
      DECLARE Table  CHARACTER 'xmlstuff';
      

      
      DECLARE SQLState1 CHARACTER;   
      DECLARE SQLErrorText1 CHARACTER;   
      DECLARE SQLCode1 INTEGER;   
      DECLARE SQLNativeError1 INTEGER; 
      
      --Retrieve the database return codes --
      SET SQLState1 = SQLSTATE;
      SET SQLCode1 = SQLCODE;
      SET SQLErrorText1 = SQLERRORTEXT;
      SET SQLNativeError1 = SQLNATIVEERROR;
      
      --Use the THROW statement to back out the database and issue a user exception--
      THROW USER EXCEPTION MESSAGE 2950 VALUES
      ( 'The SQL State' , SQLState1 , SQLCode1 , SQLNativeError1 ,
      SQLErrorText1 );
            
      SET OutputRoot.MRM = InputRoot.MRM;
   
      INSERT INTO Database.xmlstuff (INSTRUCTIONS, TASK)
            VALUES(InputRoot.XMLNSC.INSTRUCTIONS.COMPLETED.TASK.INSTRUCTIONS.TASK,
                  InputRoot.XMLNSC.Reservation.ListOfPassengers.PassengerDetails.TASK);
      
      
      RETURN TRUE;
   END;

   CREATE PROCEDURE CopyMessageHeaders() BEGIN
      DECLARE I INTEGER 1;
      DECLARE J INTEGER;
      SET J = CARDINALITY(InputRoot.*[]);
      WHILE I < J DO
         SET OutputRoot.*[I] = InputRoot.*[I];
         SET I = I + 1;
      END WHILE;
   END;

   CREATE PROCEDURE CopyEntireMessage() BEGIN
      SET OutputRoot = InputRoot;
   END;
END MODULE;


However, it is also marking my database.xmlstuff table, I have defined the ODBC.

When I run the message flow nothing's being inserted.

Kind regards,
Back to top
View user's profile Send private message
smdavies99
PostPosted: Mon Sep 22, 2014 9:52 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

There is something wrong here
Code:

      SET OutputRoot.MRM = InputRoot.MRM;
   
      INSERT INTO Database.xmlstuff (INSTRUCTIONS, TASK)
            VALUES(InputRoot.XMLNSC.INSTRUCTIONS.COMPLETED.TASK.INSTRUCTIONS.TASK,
                  InputRoot.XMLNSC.Reservation.ListOfPassengers.PassengerDetails.TASK);
       

What domain are you really using? MRM or XMLNSC?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Sep 22, 2014 10:02 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It's also not clear how the compute node would ever reach the INSERT statement, given the statements that will get executed before the INSERT.

I mean, if we're being technical.
Back to top
View user's profile Send private message
tank_n_spank
PostPosted: Tue Sep 23, 2014 3:05 am    Post subject: Reply with quote

Apprentice

Joined: 02 Sep 2014
Posts: 37

Hello,

I first had a problem with my DB and connection, sorted that out, now I insert a NULL value into the database.

Code:
DECLARE refTASK CHARACTER;
      SET refTASK = InputRoot.XMLNSC.INSTRUCTIONS.COMPLETED.TASK;
      --DECLARE refTASK    REFERENCE TO InputRoot.XMLNSC.INSTRUCTIONS.COMPLETED.TASK;
   
      INSERT INTO Database.DBA.XMLSTUFF (INSTRUCTIONS, TASK)
            VALUES(refTASK,
                  refTASK);



I am using XMLNSC, I deleted the rest rubbish I didn't need.

In the debugging the value is set to refTASK:UNKNOWN:null

My XML file is as it follows:

INSTRUCTIONS
Completed
TASK - task 1
TASK - task 2
TASK - task 3
Completed
INSTRUCTIONS
Back to top
View user's profile Send private message
tank_n_spank
PostPosted: Tue Sep 23, 2014 3:37 am    Post subject: Reply with quote

Apprentice

Joined: 02 Sep 2014
Posts: 37

Fixed it, thanks.
Back to top
View user's profile Send private message
tank_n_spank
PostPosted: Tue Sep 23, 2014 4:07 am    Post subject: Reply with quote

Apprentice

Joined: 02 Sep 2014
Posts: 37

Just a quick thing, if i wanna insert every task in each file, that will result in 4 tasks, do I need to use lastmove(declare task reference to inputroot***)?
Back to top
View user's profile Send private message
tank_n_spank
PostPosted: Tue Sep 23, 2014 4:47 am    Post subject: Reply with quote

Apprentice

Joined: 02 Sep 2014
Posts: 37

Anyway, fixed that one as well, cheers.
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 » Inserting into SolidDB using ESQL
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.