?
Solved

rowtype pl/sql function in a view

Posted on 2011-02-16
6
Medium Priority
?
758 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 1000 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 74

Accepted Solution

by:
sdstuber earned 1000 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Suggested Courses

862 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