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: 1281
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 Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm


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