Solved

rowtype pl/sql function in a view

Posted on 2011-02-16
6
752 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to recover a database from a user managed backup

729 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