|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
SELECT Function |
« View previous topic :: View next topic » |
Author |
Message
|
arunkumar1989 |
Posted: Thu Dec 06, 2012 10:20 pm Post subject: SELECT Function |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Hi All,
I need to get lat five transaction of customer in bank db
Table Structures
--------------------
CUSTOMER
-------------
CUSTOMERID,CUSTOMERNAME,ACCOUNTNO........
TRANSACTION
-----------------
TRANSACTIONID,TRANSACTIONDATE,CUSTOMERID......................
this is my query
------------------
SELECT C.*,T.* FROM Database.CUSTOMER AS C,Database.TRANSACTION AS T WHERE C.CUSTOMERNAME=name and C.DOB=dob;
how can i get max recent five transactions from table,
please help me....!!!!!
 |
|
Back to top |
|
 |
arunkumar1989 |
Posted: Thu Dec 06, 2012 11:51 pm Post subject: Done |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Hi all,
I have done this following code.
SET Recs.CustomerDetails[]=PASSTHRU('select * from customer as c,customertransaction as t where c.customerid=t.customerid and c.customername= ? and c.dob= ? order by transactiondate desc fetch first 5 rows only' TO Database.bank VALUES (name, dob));
I have one more doubts here...
if Result set returns zero rows mean .... how i can check this.. |
|
Back to top |
|
 |
mqsiuser |
Posted: Fri Dec 07, 2012 1:49 am Post subject: Re: Done |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
arunkumar1989 wrote: |
if Result set returns zero rows mean .... how i can check this.. |
IF CARDINALITY(Recs.CustomerDetails[]) = 0 THEN ... (that is the naive way)
... or you just step into the FIRSTCHILD (with a reference) and then check "IF LASTMOVE" is TRUE
probably the best thing is that you use EXISTS _________________ Just use REFERENCEs |
|
Back to top |
|
 |
arunkumar1989 |
Posted: Fri Dec 07, 2012 2:04 am Post subject: Sorry its throwing Error |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
this is my code :
==========
SET Rec.CustomerInfo=PASSTHRU('select * from customer as c where c.customername= ? and c.dob= ?' TO Database.bank VALUES (name, dob));
IF Rec.CustomerInfo <> 0 THEN
SET Recs.CustomerDetails[]=PASSTHRU('select * from customer as c,customertransaction as t where c.customerid=t.customerid and c.customername= ? and c.dob= ? order by transactiondate desc fetch first 5 rows only' TO Database.bank VALUES (name, dob));
IF Recs.CustomerDetails[] <> 0 THEN
........................................
Error :
--------
BIP2420E: (.InquiryServicesFlow_Compute.Main, 14.30) : Invalid or incompatible data types for '<>' operator. |
|
Back to top |
|
 |
kash3338 |
Posted: Fri Dec 07, 2012 3:13 am Post subject: Re: Sorry its throwing Error |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
arunkumar1989 wrote: |
IF Recs.CustomerDetails[] <> 0 THEN
Error :
--------
BIP2420E: (.InquiryServicesFlow_Compute.Main, 14.30) : Invalid or incompatible data types for '<>' operator. |
You were given the code already by mqsiuser.
mqsiuser wrote: |
IF CARDINALITY(Recs.CustomerDetails[]) = 0 THEN ... (that is the naive way)
... or you just step into the FIRSTCHILD (with a reference) and then check "IF LASTMOVE" is TRUE
probably the best thing is that you use EXISTS |
|
|
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
|
|
|
|