Solved

rowtype pl/sql function in a view

Posted on 2011-02-16
6
747 Views
Last Modified: 2013-12-19
I am trying to use a function I have built inside a view and I want to pass the whoel row into the function.

create or replace view Mac_Commis_Rev_Dtl_ial as
select
 x.cest_customer_no
,JA_TEST.Commission_Zip   (u.* ,x.* ) Zip_code
from mac_commission_revenue_tab x
,mac_commission_product_group u
where u.product_group_code = x.cest_product_group_code
WITH   read only;

my function works inside a normal pl/sql block, but I want to generaically pass the row to the function. This will help me with maintanence.

I dont want to list out each column name from the table, just want to pass the row

Currently I get a ORA-01747 error
0
Comment
Question by:jhacharya
  • 4
6 Comments
 
LVL 28

Assisted Solution

by:Naveen Kumar
Naveen Kumar earned 250 total points
ID: 34914900
I don't think there is a direct way out to do that.

0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 34914913
but i think it can work if you have created a type as a database object and used this type in your table and you have created the function to receive this type object and then internally in your function code you can access each member ( basically each column ) of this type object accordingly.

0
 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 34914925
using * to refer to all the fields may be simple and help at some times but beware of the other side as well like ( what happens to your function if one existing column is dropped from the table or a new column is added to the table or some column is renamed to some other name i,e your function has to be written in a generic fashion to take care of all these cases )
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 28

Expert Comment

by:Naveen Kumar
ID: 34914945
" my function works inside a normal pl/sql block " --> what does this mean ? Can you give sample code here to understand this.
0
 
LVL 73

Accepted Solution

by:
sdstuber earned 250 total points
ID: 34915405
You can't pass a rowtype in sql.

if you use object type, you'll need to pass invoke a constructor to assemble the type from the columns.

I recommend overloading your function,  keep the version you have that accepts a rowtype variable.

but create another one that accepts every column and then simply invokes the other one.
0
 
LVL 2

Author Closing Comment

by:jhacharya
ID: 34916790
it cant be done !!!!! oh well hope oracle an come up with an improvement in their SQL to handle this ...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now