|
|
| Author |
Message |
murleedhar
New User
Joined: 10 Mar 2005 Posts: 5 Location: bangalore
|
|
|
|
| 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 |
|
 |
References
|
|
 |
ssowjanya
New User
Joined: 29 Apr 2005 Posts: 13
|
|
|
|
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 |
|
 |
murleedhar
New User
Joined: 10 Mar 2005 Posts: 5 Location: bangalore
|
|
|
|
| hi, yes u r right. then wht does select * do?? |
|
| Back to top |
|
 |
Deepa.m Warnings : 1 Active User
Joined: 28 Apr 2005 Posts: 88
|
|
|
|
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 |
|
 |
Pushpak
New User
Joined: 06 May 2005 Posts: 22
|
|
|
|
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 |
|
 |
j_prameela2000
New User
Joined: 01 Jun 2005 Posts: 29 Location: Chennai
|
|
|
|
| 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 |
|
 |
Pushpak
New User
Joined: 06 May 2005 Posts: 22
|
|
|
|
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 |
|
 |
j_prameela2000
New User
Joined: 01 Jun 2005 Posts: 29 Location: Chennai
|
|
|
|
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 |
|
 |
j_prameela2000
New User
Joined: 01 Jun 2005 Posts: 29 Location: Chennai
|
|
|
|
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 |
|
 |
|
|