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
 

 

use of join in declare cursor

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: use of join in declare cursor
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

Site Director


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

PostPosted: Fri Mar 26, 2010 7:22 pm    Post subject:
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: 2150
Location: At my coffee table

PostPosted: Fri Mar 26, 2010 7:35 pm    Post subject:
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: 1278
Location: Belgium

PostPosted: Fri Mar 26, 2010 8:21 pm    Post subject:
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    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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
No new posts Updating Cursor row withour using FOR... chandan.inst DB2 15 Tue Nov 08, 2016 11:17 am
No new posts How can we have the varying lenth of ... Gunapala CN DFSORT/ICETOOL 6 Fri Oct 14, 2016 7:31 pm
No new posts Variable for cursor names ravikumar15 DB2 5 Sun Jul 17, 2016 7:08 am
No new posts Join key - Populate Zeros when Unpair... rexx77 DFSORT/ICETOOL 6 Thu May 12, 2016 12:22 am


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