Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

how to select rowid with select * from table_name

mlov83Feb 13 2012 — edited Feb 13 2012
Hello guys i have a cursor like so.
  Cursor c1 IS SELECT * FROM FZRASST;
  
    
  -- Row of type FZRASST row
  fzrasst_row c1%ROWTYPE;
when i try to reference the row id like this
fzrasst_row.rowid;
i get an error invalid indentifier? how can i reference the row id without implicitely selecting rowid? is this possible or do i need to change my select statement to select every column on the table?
Any help would be greatly appreciated.
This post has been answered by Solomon Yakobson on Feb 13 2012
Jump to Answer

Comments

Solomon Yakobson
Answer
Use:
Cursor c1 IS SELECT rowid,a.* FROM FZRASST a;
SY.
Marked as Answer by mlov83 · Sep 27 2020
hm
Are you looking for something like this?

Cursor c1 IS SELECT F.*, F.rowid row_id FROM FZRASST F;
  
    
  -- Row of type FZRASST row
  fzrasst_row c1%ROWTYPE;



begin
 ...

 fzrasst_row.row_id
 ...
Frank Kulash
Hi,
mlov83 wrote:
Hello guys i have a cursor like so.
Cursor c1 IS SELECT * FROM FZRASST;


-- Row of type FZRASST row
fzrasst_row c1%ROWTYPE;
when i try to reference the row id like this
fzrasst_row.rowid;
i get an error invalid indentifier? how can i reference the row id without implicitely selecting rowid? is this possible or do i need to change my select statement to select every column on the table?
Fzrasst_row contains every column that is in the SELECT clause, and nothing more. If you want fzrasst_row to include pseudo-columns (such as ROWID) or anything else, then you have to include them in the SELECT clause.

To avoid naming every single column in hte table, you can do something like this:
Cursor c1 IS 
    SELECT  FZRASST.* 
    ,       ROWID   AS r_id
    FROM    FZRASST;
(assuming the table doesn't already have a column called r_id).

Edited by: Frank Kulash on Feb 13, 2012 3:29 PM
mlov83
Thanks frank for the explanation I appreciate that!
Frank Kulash
Hi,

I was editing my 1st message when you posted your 2nd. It now shows an easy way to include ROWID.
1 - 5
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 12 2012
Added on Feb 13 2012
5 comments
20,966 views