Home » SQL & PL/SQL » SQL & PL/SQL » Create Record Type with rowtype + one field (Oracle Database 11g Enterprise Edition Release 11.2.0.3.0)
Create Record Type with rowtype + one field [message #568432] Thu, 11 October 2012 09:26 Go to next message
athensromania
Messages: 43
Registered: July 2007
Location: Valencia,Spain
Member
Hi all,

using as template this table:

create table t1 (c1 number,c2 number);

CREATE OR REPLACE 
TYPE REC IS RECORD (
R1 T1%ROWTYPE,
R2 NUMBER
);



I'm trying to create one RECORD type with all the columns from table T1 + one new field R2.
But gives me an error.

The point to use T1%ROWTYPE and not to hardcode the columns from T1, is due to if we add
a new column to T1, is created when is executed again RECORD definition and not to add
the column.

Is it possible?

Thanks.






Re: Create Record Type with rowtype + one field [message #568439 is a reply to message #568432] Thu, 11 October 2012 10:17 Go to previous messageGo to next message
Michel Cadot
Messages: 57613
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You cannot create a SQL type (using CREATE TYPE) referencing the PL/SQL property ROWTYPE.

Regards
Michel
Re: Create Record Type with rowtype + one field [message #568443 is a reply to message #568432] Thu, 11 October 2012 10:21 Go to previous messageGo to next message
Solomon Yakobson
Messages: 1797
Registered: January 2010
Senior Member
CREATE TYPE is SQL command and only understands SQL types. RECORD is PL/SQL type. Therefore you can't use RECORD in CREATE TYPE statement.

SY.
Re: Create Record Type with rowtype + one field [message #568737 is a reply to message #568443] Tue, 16 October 2012 03:22 Go to previous message
athensromania
Messages: 43
Registered: July 2007
Location: Valencia,Spain
Member
ok thank you very much.

I was too much focus in the solution and I hadn't noticed that ROWTYPE is PL/SQL and not SQL type.

Previous Topic: Generate dynamic Unpivot
Next Topic: pre requisit question
Goto Forum:
  


Current Time: Mon Apr 21 00:22:29 CDT 2014

Total time taken to generate the page: 0.08369 seconds