Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

EQUALS option available in Unload datacard of BMC utility?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
dsivapradeep

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Mon Feb 03, 2014 10:21 am    Post subject: EQUALS option available in Unload datacard of BMC utility?
Reply with quote

Hi,

In unload datacard of BMC utility (PGM=ADUUMAIN), how to select only the first record out of multiple rows ?

For ex: primary key is (Branch + Account + Date). I want to retrive all the records of the table but only of latest date records for an unique (Branch + Account) combination. To get latest date i wrote ORDER BY branch asc, account asc, date desc.
But don't know how to select only the first record for a unique combination of Branch + Account.

Something like EQUALS option in DFSORT i was searching.

Any pointers on this would be helpful.
Back to top
View user's profile Send private message

harithb

New User


Joined: 08 Jun 2009
Posts: 15
Location: Bangalore

PostPosted: Mon Feb 03, 2014 6:37 pm    Post subject:
Reply with quote

Hi,

Can you try combining your query with FETCH FIRST ROW ONLY and see if it works..

Cheers,
Haritha
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Tue Feb 04, 2014 5:39 am    Post subject:
Reply with quote

Did you try with Group by and MAX combination? could you please provide sample data ?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Feb 04, 2014 12:32 pm    Post subject:
Reply with quote

Try something like this,

Code:
select a.branch, a.account, a.date
from table a
where a.date = ( select max(date) from table
               where account = a.account
          and   branch = a.branch)
order by a.branch, a.account

Regards,
Sushanth
Back to top
View user's profile Send private message
sandip_mainframe
Warnings : 2

New User


Joined: 20 Sep 2006
Posts: 61
Location: pune

PostPosted: Tue Feb 04, 2014 12:44 pm    Post subject: Reply to: EQUALS option available in Unload datacard of BMC
Reply with quote

Hi,

You can use below query as FETCH FIRST ROWS clause works in BMC utility -

Code:
 SELECT BRANCH, ACCOUNT, DATE
 FROM XYZ
 ORDER BY DATE
 FETCH FIRST 1 ROWS ONLY


Thanks,
Sandip Walsinge
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Feb 04, 2014 12:51 pm    Post subject:
Reply with quote

In BMC Unload if you give DIRECT NO, you can give all valid SELECT statements as they will be executed as dynamic queries.
Back to top
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Tue Feb 04, 2014 12:52 pm    Post subject:
Reply with quote

Sandip,
Your query will return only one record of any account number, which has smallest date.

But the requirement is to get all the account number's first records.

Sushanth query will work as expected.

dsivapradeep, have you tried ?
Back to top
View user's profile Send private message
dsivapradeep

New User


Joined: 06 Jul 2012
Posts: 43
Location: INDIA

PostPosted: Wed Feb 05, 2014 12:33 pm    Post subject:
Reply with quote

Hey all,

Thanks for all your suggestions. I was not expecting any WHERE clauses in my UNLOAD DATACARD. icon_rolleyes.gif We're supposed to reduce DBA effort, so simple SELECT operation i'll be using

It's easy to get answer for my question using a WHERE clause but I was searching for some specific CONTROL PARAMETERs by avoiding WHERE clause.

I'll use a DFSORT step and removes extra records that came out of this unload file.


Sandip, I think your query may not give my desired output. icon_smile.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Feb 05, 2014 1:21 pm    Post subject:
Reply with quote

If you could have mentioned this clearly in the question then someone could have given better solution and can save time as well.
however we are glad you found something useful.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1610
Location: NY,USA

PostPosted: Wed Feb 05, 2014 1:45 pm    Post subject:
Reply with quote

DIRECT YES: UNLOAD PLUS reads data directly from the table space data set or image copy data sets to unload the data, using a SELECT-like syntaxfor data selection. SELECT functionality is a limited subset of thefunctionality that is normally available in DB2 SQL. The benefit of the DIRECT YES mode is maximum performance when unloading large volumes of data.

DIRECT NO: UNLOAD PLUS processes the SELECT statement and reads the data usingDB2 dynamic SQL. This mode is not a high-performance solution for unloading large volumes of data. The benefit of the DIRECT NO mode is a full range of DB2 SQL SELECTfunctionality, including joined tables, subqueries, and so on. This functionality includes many of the features that are availablein UNLOAD PLUS including DB2 parallelism, data type conversions, output formatting

This might be helpful to you. If you have proper indexing then with above options and suggested query this should not be a performance issue. Let us know the volume of the underlying data here or MIPS which might get used in this process.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts TAPE VERIFY utility?? MrExtraordinare JCL & VSAM 3 Fri Dec 09, 2016 10:57 pm
No new posts BWO option in VSAM blayek CICS 3 Sat Nov 05, 2016 10:47 am
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Best IMS DB Unload Utility jjabez10 IMS DB/DC 12 Thu Sep 22, 2016 11:15 pm
No new posts Any docs / links for isub- cobol comp... SRICOBSAS COBOL Programming 4 Fri Aug 26, 2016 2:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us