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
 

 

Differance b/n COPY & INCLUDE, Nth Maximum SQL

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

New User


Joined: 10 Mar 2005
Posts: 33
Location: Lewiston

PostPosted: Thu Mar 10, 2005 3:26 pm    Post subject: Differance b/n COPY & INCLUDE, Nth Maximum SQL
Reply with quote

Hi! ALL,
1 CAN ANY ONE EXPLAIN THE DEFERACE BETBEEN KEYWORD 'COPY' & 'INCLUDE' ?
2> WRITE A SQL QUERY TO GET Nth Largest value of a column from a DB2 table ? n > 15.
THANKS IN ADVANCE
Back to top
View user's profile Send private message

serious_mainframes

New User


Joined: 10 Mar 2005
Posts: 2

PostPosted: Thu Mar 10, 2005 5:13 pm    Post subject: Re: differance b/n COPY & INCLUDE
Reply with quote

copy used in cobol for copying some data what we want from ps or pds

include is used in db2 to include a communication areas and any dclgen members
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Thu Mar 10, 2005 5:21 pm    Post subject:
Reply with quote

Hi Dharmendra,

COPY is used to copy the contents of a Copy book ( which contains COBOL statements) into athe COBOL program.

INCLUDE is used to copy the contents of a COPYBOOK generated by DCLGEN for host variable declarations.

SELECT MAX(COLUMN) FROM TAB A WHERE 15=(SELECT COUNT(*) FROM TAB B WHERE A.COL<=B.COL);


Please search the FORUM before posting, Avoid posting the same ques twice.

Bye,
Reddy.
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1203
Location: India

PostPosted: Thu Mar 10, 2005 10:14 pm    Post subject:
Reply with quote

You are right Reddy, But a small correction, if you don't mind!

'COPY' and 'INCLUDE' (I believe it's not JCL Include) do the same function. You can Copy any set of statements using this statements.

But COPY Statement is honored by the Cobol Compiler while INCLUDE statement is identified by the DB2 PreCompiler.

You can use INCLUDE statement to copy the statements, not generated by DCLGEN also.
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Fri Mar 11, 2005 10:47 am    Post subject:
Reply with quote

Hi McMillan,

I agree with you. Thanks for correction

Thanks,
Reddy
Back to top
View user's profile Send private message
kiranchinthapalli

New User


Joined: 13 Mar 2005
Posts: 1

PostPosted: Sun Mar 13, 2005 11:19 pm    Post subject:
Reply with quote

Hi,
the main difference between INCLUDE and COPY is that they perform the same operation but

INCLUDE------> It will expand only at the time of DB2 pre-compilation &


COPY----------->It will expand only at the time of COBOL compilation



bye.
kiran.
Back to top
View user's profile Send private message
dharmendra_kp

New User


Joined: 10 Mar 2005
Posts: 33
Location: Lewiston

PostPosted: Mon Mar 14, 2005 10:00 am    Post subject: correction to the DB2 Q Nth largest value of a col frm TAB
Reply with quote

hi! ALL,
thanks guys for answering about COPY & INCLUDE!
I would like to thank REDDY & KIRAN particularly for Answering both the questions.

I would like to MAKE A CORRECTION TO THE ANSWERE OF THE 2ND QUESTION ie. which i got after working on your code.
TO GET THE NTH LARGEST VALUE OF A COLUMN FROM A DB2 TABLE, where n > 15 ( becouse there can be a max of 15 level of non co-related subquery.

for if there is redundancy in the column that is if the column has more than one value which is equal to the nth largest THE MODIFIED CODE SHULD BE SOMETHING LIKE THIS:

Code:
SELECT * FORM (SELECT DISTINCT col1, col2, ... colx FROM TAB)A WHERE (SELECT COUNT(*) FROM ( SELECT DISTINCT col1, col2, ...colx FROM TAB)B WHERE A.col1 <= B.col1) =n;



But still I am very sceptical abt its performance issues. ANY ONE HAVING ANY BETTER METHOD PLZ SHARE.
Thank u.
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Sat Mar 19, 2005 11:02 am    Post subject:
Reply with quote

hi dharmendra,

can you please explain the query how it works?

thanx in advance.

pavan

work is worship & duty is god
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 SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts HALDB data refresh/copy from producti... vineetanand2007 IMS DB/DC 1 Mon Jan 02, 2017 11:16 am
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


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