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

use of join in declare cursor


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Mar 26, 2010 11:55 am
Reply with quote

I have 2 tables . SUPPLY and PART TABLES . Both have City field as common . I have to fetch details from both tables for matching cities using embeddded sql. Can i declare a cursor as below :

EXEC SQL
DECLARE C1 CURSOR FOR SELECT * FROM S.SUPPLY , P.PART WHERE S.CITY = P.CITY
END-EXEC.

Is this syntax for declare cursor allowed in embedded sql ? If yes i am getting SQLCODE 20O while running thw pgm . Please let me know what it indicates.

Thanks
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 26, 2010 7:22 pm
Reply with quote

Hello,

Lose the "select *". .

Is that the exact sql executed or just something similar?

There was more info presented than "200". You need to post the rest as well.

At the top of the page is a link to "IBM Manuals". Suggest you look up your return info in the db2 messages documentation.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Fri Mar 26, 2010 7:35 pm
Reply with quote

Quote:
i am getting SQLCODE 20O
Is this actually a -206 column-name IS NOT A COLUMN OF AN INSERTED TABLE, UPDATED TABLE, OR ANY TABLE IDENTIFIED IN A FROM CLAUSE, OR IS NOT A COLUMN OF THE TRIGGERING TABLE OF A TRIGGER
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Mar 26, 2010 8:21 pm
Reply with quote

I assume that S.SUPPLY and P.PART are really existing tables .

SELECT * FROM S.SUPPLY A , P.PART B WHERE A.CITY = B.CITY
or
SELECT * FROM S.SUPPLY , P.PART WHERE S.SUPPLY.CITY = P.PART.CITY
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 Join multiple records using splice DFSORT/ICETOOL 5
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Join files where value in one is betw... DFSORT/ICETOOL 6
No new posts Is the Output of Sort/Join dependent ... DFSORT/ICETOOL 2
Search our Forums:

Back to Top