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 » Accessing an sql database from ESQL

Post new topic  Reply to topic
 Accessing an sql database from ESQL « View previous topic :: View next topic » 
Author Message
cloucas
PostPosted: Tue Jan 09, 2007 2:05 am    Post subject: Accessing an sql database from ESQL Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

I am developing a message flow which is composed of an MQInput, Compute and MQOutput nodes.

The message coming into the MQInput Node is composed of just one string element, customerCode. Based on the value of the element I contsruct a host request in the Compute node and send it to the MQOutput node sucessfully.

I would now like to use the string value received in the input node to look up the customerName from a database table which I would then like to insert into my request message as well. I have an SQL 2005 Server database configured and given the broker user access to it. I have also created a DSN on the broker server and inserted the DSN name as the Data Source property of the compute node.

I then try to access the database like below:

SET OutputRoot.MRM.LAST_NAME = SELECT Name FROM ELSTestDB.CIFInquiries;

where ELSTestDB is the DSN name of the ODBC connection.

The ESQL editor gives me a warning "Identifier ELSTestDB cannot be resolved". I have also tried

SET OutputRoot.MRM.LAST_NAME = SELECT Name FROM Database.CIFInquiries;, but I get the warnng "Unresolvable database table reference Database.CIFInquiries.";

I also tried to create a database definition, schema and table, but no avail.

How should I correctly go about to set up the database connection and access it from ESQL? I have looked in manuals but found no clear procedure.

Thanks in advance

Chris
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jan 09, 2007 2:19 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Which version of MB? I found the section in the v6 Info Centre "Selecting data from database columns" informative in respect of your situation.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
cloucas
PostPosted: Tue Jan 09, 2007 2:37 am    Post subject: Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

We use 5.1

I looked a bit into that as well, but couldn't get to the cause of the problem with referencing the database from the esql.....unless I am missing something


Thanks

Chris
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Jan 09, 2007 2:38 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

THe warning you get is just that. It's a warning, and it only applies in the Toolkit.

You can ignore the warning.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
gregop
PostPosted: Tue Jan 09, 2007 2:41 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2006
Posts: 81

Quote:
SET OutputRoot.MRM.LAST_NAME = SELECT Name FROM Database.CIFInquiries;, but I get the warnng "Unresolvable database table reference Database.CIFInquiries.";


Try: SET OutputRoot.MRM.LAST_NAME = SELECT T.Name FROM Database.CIFInquiries AS T ;

Don't worry about the Unresolvable warning. You'll get that on DB selects unless you import the database definition (and I've never worked at a shop that does).
Back to top
View user's profile Send private message
cloucas
PostPosted: Tue Jan 09, 2007 11:50 pm    Post subject: Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

I have done the above and get the following error:

RecoverableException BIP2519E: (, 1.1) : Error executing SQL statement 'SELECT T.Name FROM CIFInquiries T WHERE (T.CIF)=(?)' against datasource 'ELSTestDB' with parameters ''01035355', '.
The following error occurred during execution of a database SQL statement against datasource 'ELSTestDB'. The SQL statement was 'SELECT T.Name FROM CIFInquiries T WHERE (T.CIF)=(?)'. The parameters passed were ''01035355', '.


2007-01-10 08:08:41.829364 2480 DatabaseException BIP2324E: Unsupported datatype '-9' fetched from database table column 'Name'.
A message flow node which performs a database fetch returned a datatype not supported by the message broker. The database table column 'Name' contain an unsupported datatype identified by '-9'.
Either update the message flow to eliminate the reference to the database column with the unsupported datatype, or modify the database schema to change the column to be of a type supported by the message broker.


I don't understand why the broker tries to pass 2 parameters to the query while the select statement only accepts one.....any ideas?
Back to top
View user's profile Send private message
gregop
PostPosted: Wed Jan 10, 2007 12:37 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2006
Posts: 81

What is the datatype of Name ?

You can see the supported data types by searching info center for:

'external source data types'
Back to top
View user's profile Send private message
cloucas
PostPosted: Wed Jan 10, 2007 1:55 am    Post subject: Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

thanks for this, i had to change type nvarchar as it is not supported....almost there as i am now reading the value from the database table. I now get the following error:

2007-01-10 11:45:35.005249 1824 ParserException BIP5339E: Mismatch between message tree and logical definition
While writing the message, the message tree did not match the logical structure of the message. The problem was encountered while attempting to write element 'Name' in message set 'A2GJ920002001'.
This problem is usually caused by a badly-structured input message. It can also be caused by a badly-structured output message tree. Check that the structure of the input message matches the logical structure of the message. Check that elements defined as simple elements do not have child elements. If necessary, check that elements occur in the correct sequence, and with the correct number of repeats. If you have modified the message set or message type property in your message flow, check that these are correct.


The field in the OutputRoot.MRM is defined as string.....any ideas?
Back to top
View user's profile Send private message
gregop
PostPosted: Wed Jan 10, 2007 2:27 am    Post subject: Reply with quote

Voyager

Joined: 24 Nov 2006
Posts: 81

Your MRM message is expecting some data in element Name that is not present in OutputRoot.MRM

If you can't see the problem in your esql place a Trace node with pattern ${Root} prior to your MQOutput node. Then run a user trace.
Back to top
View user's profile Send private message
cloucas
PostPosted: Wed Jan 10, 2007 4:05 am    Post subject: Reply with quote

Apprentice

Joined: 10 Mar 2006
Posts: 37

Finally got this to work....it appears that the returned object of the query was indeed a complex type and thus I needed to reference the Name element to get to my desired value.


Thanks a lot for your help!
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 » Accessing an sql database from 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.