Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Difference between CURSOR and Select *

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

New User


Joined: 10 Mar 2005
Posts: 5
Location: bangalore

PostPosted: Wed Jun 08, 2005 3:04 pm    Post subject: Difference between CURSOR and Select *
Reply with quote

we will use cursor to fetch more than one single row, then what is select * from table name.. what is the difference b/n these two
Back to top
View user's profile Send private message

ssowjanya

New User


Joined: 29 Apr 2005
Posts: 13

PostPosted: Wed Jun 08, 2005 4:23 pm    Post subject:
Reply with quote

Hi murleedhar,
While programming in db2-cobol multiple rows cannot be retrieved at a time. so we use cursors to retrieve multiple rows.
Back to top
View user's profile Send private message
murleedhar

New User


Joined: 10 Mar 2005
Posts: 5
Location: bangalore

PostPosted: Wed Jun 08, 2005 4:39 pm    Post subject: Re: db2
Reply with quote

hi, yes u r right. then wht does select * do??
Back to top
View user's profile Send private message
Deepa.m
Warnings : 1

New User


Joined: 28 Apr 2005
Posts: 99

PostPosted: Wed Jun 08, 2005 5:51 pm    Post subject:
Reply with quote

Select * displays the rows matching the condition but can't be used in programs to process the records.

but if you want to fetch each row in the application program you have to use cursor and process records one by one.
Back to top
View user's profile Send private message
Pushpak

New User


Joined: 06 May 2005
Posts: 18

PostPosted: Thu Jun 09, 2005 1:48 pm    Post subject: Re: Difference between CURSOR and Select *
Reply with quote

Hi

# SELECT * - will return results as a SET, if it finds more than one row in a table.

If your requirement is to get only one row no matter how may row SELECT * returning, then in that case you may use SELECT * & handle sql code -811 in your application program. But if you want to process all the records then you have to use CURSOR in your application program.

CURSOR is not any sql/query. SELECT * will return all the records & CURSOR will put all these records in a buffer & will make available to the application program one by one.
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Fri Jun 10, 2005 11:34 am    Post subject: Re: Difference between CURSOR and Select *
Reply with quote

We cannot given Select * in Embedded sql ie. Within Exec SQL and End SQL. In embedded sql which is written within COBOL-DB2 program, SELECT statement can retrieve only one row at a time. So inorder to multiple rows we make use of cursor which retrieves multiple rows from a table. Select * can be given in SPUFI to retrieve all the rows in the table. If this is wrong, please correct me.
Back to top
View user's profile Send private message
Pushpak

New User


Joined: 06 May 2005
Posts: 18

PostPosted: Fri Jun 10, 2005 2:43 pm    Post subject: Re: Difference between CURSOR and Select *
Reply with quote

Hi Prameela,

I am using DB2 Version V7, I have tested SELECT * query (EXEC SQL - END-EXEC) in Cobol-DB2 application program & it is working fine.

I am not sure whether it works with prior versions of DB2 or not, but DB2 Ver 7 & onwards, it is working fine.

Pushpak.
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Mon Jun 13, 2005 10:44 am    Post subject: Re: Difference between CURSOR and Select *
Reply with quote

Hi Pushpak,

Select * in Embedded SQl can be given but I have a doubt whether it retrieves multiple rows or it retrieves single row at a time based on the condition. Please clarify my doubt. When you give Select * from table where <condition> will retrieve all the rows whichever satisfies the condition in SPUFI. But same way, in Embedded SQL using CURSOR you can retrieve multiple rows and can access the record one by one using Select * in embedded sql. Please tell me whether i am correct or wrong.
Back to top
View user's profile Send private message
j_prameela2000

New User


Joined: 01 Jun 2005
Posts: 28
Location: Chennai

PostPosted: Mon Jun 13, 2005 2:14 pm    Post subject: Re: Difference between CURSOR and Select *
Reply with quote

Hi,

Select * means retrieving all the fields in a table. Where as Cursor selects only selected fields from a table. I hope this is correct. If wrong please correct me.
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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Difference in SORT & ICETOOL Mohan Kothakota DFSORT/ICETOOL 5 Fri Sep 22, 2017 4:56 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us