Re: Simple PL/SQL Query

From: David Rackley <drack_at_sbctri.sbc.com>
Date: 1996/01/23
Message-ID: <DRACK.96Jan23140017_at_diablo>#1/1


In article <4df5c5$2df_at_nuscc.nus.sg> ccev38_at_leonis.nus.sg (Computer Centre Visitor) writes:

> Hi everybody
 

> Here is a simple PL/SQL problem
 

> How do I select rowid and all the columns from a table in PL/SQL block. The
> declaration "%ROWTYPE" will not hold any rowid data type so the following
> code will be incorrect.
 

> declare
> x emp%rowtype;
> begin
> select rowid, emp.* into x from emp where empno=1003;
> dbms_output.put_line(x.rowid || ' '||to_char(x.empno));
> end;
> /

 Try a cursor loop. The selected columns in the cursor can be addressed with dot syntax, eg.

declare
  cursor cursor_name is select rowid,col1,col2 from your_table;

  junk char(60); /* large enough to hold rowid */   junk2 number; /* same data type as col1 */

begin
  for rec in cursor_name loop
    junk := rec.rowid;
    junk2 := rec.col1;
  end loop;
end;

Hope this helps.

--

  +----------------------+----------------------------------------------+
  | David Rackley        | email: drack_at_tri.sbc.com                     |
  | Southwestern Bell    |   tel: (512) 372-5516  FAX: (512) 372-5591   |
  | Technology Resources |  http://www.tri.sbc.com/                     |
  | 9505 Arboretum Blvd  +----------------------------------------------+
  | Austin, TX 78759     | It's OK to be a martyr, as long as you don't |
  |                      | bring your own firewood.  -- Dr. Jim Rigby   |
  +----------------------+----------------------------------------------+   
Received on Tue Jan 23 1996 - 00:00:00 CET

Original text of this message