IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

EQUALS option available in Unload datacard of BMC utility?


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Tue Feb 04, 2014 5:39 am
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: 1020
Location: India

PostPosted: Tue Feb 04, 2014 12:32 pm
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: 63
Location: pune

PostPosted: Tue Feb 04, 2014 12:44 pm
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: 1020
Location: India

PostPosted: Tue Feb 04, 2014 12:51 pm
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
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Feb 05, 2014 1:21 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Feb 05, 2014 1:45 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Load new table with Old unload - DB2 DB2 6
No new posts SCOPE PENDING option -check data DB2 2
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts REASON 00D70014 in load utility DB2 6
Search our Forums:

Back to Top