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 Eval & Concatenation

Post new topic  Reply to topic Goto page 1, 2  Next
 ESQL Eval & Concatenation « View previous topic :: View next topic » 
Author Message
mqhelpless
PostPosted: Wed Jul 13, 2005 10:46 pm    Post subject: ESQL Eval & Concatenation Reply with quote

Apprentice

Joined: 13 Jul 2005
Posts: 33

I am trying to achieve reading data from different tables based on some variable value. Thus I have the following statement:

Eval('Set INT_X = THE (Select Count(*) FROM Database.MQSI.' || TableZ || ' AS T WHERE T.Field1 = ' || INT_A || ')');

where INT_X, INT_A, TableZ are variables, and TableZ will give me the correct table from which I should read my data.

However, the above syntax keeps giving me problem. I tried doing away with the EVAL, i.e.
Set INT_X = THE (Select Count(*) FROM Database.MQSI.TableZ AS T WHERE T.Field1 = INT_A)
and it works fine. Can anyone give me a pointer? Thanks.
Back to top
View user's profile Send private message
mgk
PostPosted: Thu Jul 14, 2005 3:27 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

I would suggest you do not use EVAL for this, look at using PASSTHRU for dynamic DB access. It is similar, but it works MUCH faster.

Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jul 14, 2005 3:37 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I wouldn't use Passthrough either.

I'd use the { }.

something like
Code:
 Set INT_{variable} = THE (SELECT Count(*) from Database.MQSI.{TableZ} as T where T.Field1 = INT_A;

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mgk
PostPosted: Thu Jul 14, 2005 12:25 pm    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

If that were possible I would have suggested it, but unfortunately it is not. You cannot use { ... } on part of a variable name, only on an element name in a field reference.

You also cannot use { ... } to dynamically specify a database table name in V5.

Hence, passthru being the easiest / fastest way to achieve this result.

Cheers,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jul 14, 2005 1:07 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Ah, well. I'm out of practice.


_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
mqhelpless
PostPosted: Thu Jul 14, 2005 5:03 pm    Post subject: Reply with quote

Apprentice

Joined: 13 Jul 2005
Posts: 33

Hi, thanks for the pointers. I will try it out.
Back to top
View user's profile Send private message
mqhelpless
PostPosted: Thu Jul 14, 2005 9:39 pm    Post subject: Reply with quote

Apprentice

Joined: 13 Jul 2005
Posts: 33

Tried doing the following:

Set INT_X = PASSTHRU('Select Count(*) FROM Database.MQSI.' || TableZ || ' AS T WHERE T.Field1 = ?', INT_A);

but keep hitting error. It was ok for deployment, but when throw in a message, the event log complains :
" ...the parameters passed were ''123456',' .... "

There seems to be 2 values passed in (?). I also tried casting INT_A into character set but to no avail.
Back to top
View user's profile Send private message
kirani
PostPosted: Thu Jul 14, 2005 9:54 pm    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

not sure if this will work ..
Code:

Set INT_X = PASSTHRU('Select Count(*) FROM Database.MQSI.? AS T WHERE T.Field1 = ?', 'TableZ', INT_A);

_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
mqhelpless
PostPosted: Thu Jul 14, 2005 10:30 pm    Post subject: Reply with quote

Apprentice

Joined: 13 Jul 2005
Posts: 33

Nope. Doesn't seem to work. By the way, I'm using version 2.1.
Back to top
View user's profile Send private message
martinrydman
PostPosted: Fri Jul 15, 2005 12:55 am    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Hi,

You should drop the Database part of the table ref when using PASSTHRU

/Martin
Back to top
View user's profile Send private message
mqhelpless
PostPosted: Fri Jul 15, 2005 1:02 am    Post subject: Reply with quote

Apprentice

Joined: 13 Jul 2005
Posts: 33

Yup martin, tried that also. Somehow it keeps running into problem with Eval or Passthru. Specifically, it keeps giving "the data types of the opreands for the operation = are not compatible. SQLSTATE=42818".
Back to top
View user's profile Send private message
mgk
PostPosted: Fri Jul 15, 2005 1:28 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi.

You can't pass the table name in as a parameter marker, you have to do something like this:

Code:
Set INT_X = PASSTHRU('Select Count(*) FROM MQSI.' || TableZ || ' AS T WHERE T.Field1 = ?', INT_A);


And you must not use the Database correlation name in a passthru as already pointed out. If it helps, what you are doing with passthru is constructing a complete ODBC statement. It must be valid ODBC for your DB, and any parameter markers (?) must be matched by the same number of parameters following the string

Cheers,


MGK
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
fschofer
PostPosted: Fri Jul 15, 2005 2:13 am    Post subject: Reply with quote

Knight

Joined: 02 Jul 2001
Posts: 524
Location: Mainz, Germany

Hi,
there's also no MQSI.XYZ AS T in PASSTHRU, use MQSI.XYZ T instead.

Greetings
Frank
Back to top
View user's profile Send private message Send e-mail
mgk
PostPosted: Fri Jul 15, 2005 4:51 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

fschofer wrote:

Quote:
there's also no MQSI.XYZ AS T in PASSTHRU, use MQSI.XYZ T instead.


This is not quite correct the presence of the AS clause will actually be dependent on the type of database being invoked (DB2, Oracle etc), as some will allow the AS and some will not.

The key point is that the string you give to passthru MUST be acceptable to the DB you are passing it to. What is acceptable will vary from DB to DB, which is one of the reasons why is is better to use the Brokers ESQL DB functions and statements (SELECT, INSERT etc) where possible so the user does not have to care about the DB differences, the broker will take care of these differences itself.

In this case passthru is required to dynamically choose to the table to execute the query on.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
mqhelpless
PostPosted: Sun Jul 17, 2005 5:24 pm    Post subject: Reply with quote

Apprentice

Joined: 13 Jul 2005
Posts: 33

Hi Thanks for all your pointers. It finally works, by doing away with Database.MQSI.TableZ and using MQSI.TableZ instead.

I have another question. I'm wondering whether using Eval or Passthru is a better option. Can anyone provide any clues? Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » ESQL Eval & Concatenation
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.