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

Differance b/n COPY & INCLUDE, Nth Maximum SQL


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

PostPosted: Thu Mar 10, 2005 10:14 pm
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts VB to VB copy - Full length reached SYNCSORT 8
No new posts Need COBOL COPY Help in MVS Environment COBOL Programming 4
No new posts Issue after ISPF copy to Linklist Lib... TSO/ISPF 1
No new posts DB2 Table - Image copy unload IBM Tools 2
Search our Forums:

Back to Top