Home » SQL & PL/SQL » SQL & PL/SQL » define view column as a PL/SQL functon
define view column as a PL/SQL functon [message #39057] Mon, 10 June 2002 22:10 Go to next message
Tony Wei
Messages: 1
Registered: June 2002
Junior Member
Is it possiable to define a column of a view as a PL/SQL funciton on Oracle 8i.
If possiable, how to do it?

Thanks
Re: define view column as a PL/SQL functon [message #39064 is a reply to message #39057] Tue, 11 June 2002 10:51 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
When in doubt - try it. It does depend on what your function is trying to do though (see WNDS pragma directives - they still apply buy PL/SQL pretty much determines these automatically).

CREATE OR REPLACE FUNCTION f1
   RETURN NUMBER
IS
BEGIN
   RETURN 999;
END;
/

Function created

CREATE OR REPLACE FUNCTION f11
   RETURN NUMBER
IS
BEGIN
   insert into t1 values (1, 2, 3);
   RETURN 999;
END;
/

Function created

create or replace view v1 as
select 1 Num, 'hello world' msg, f1 func1
from dual;

View created

create or replace view v11 as
select 1 Num, 'hello world' msg, f11 func1
from dual;

View created

select * from v1;

NUM                                     MSG         FUNC1                                  
--------------------------------------- ----------- ---------------------------------------
1                                       hello world 999                                    
1 row selected

select * from v11;

ORA-14551: cannot perform a DML operation inside a query 
ORA-06512: at "SCOTT.F11", line 5
ORA-06512: at line 1
Previous Topic: Re: What is wrong with my logic?
Next Topic: Re: define view column as a PL/SQL functon
Goto Forum:
  


Current Time: Wed Apr 24 23:12:39 CDT 2024