Solved

Return value from a function

Posted on 2012-03-29
2
522 Views
Last Modified: 2012-04-11
I have written a function that returns the pipelined pkg
Now When I do an INSERT to TABLE 1 FROM TABLE O and one of the TABLE O column value being fetched from the function that returns the pipelined pkg  as below


CREATE OR REPLACE FUNCTION FNC_AGG_GET_BUCKET
    (
      pi_template_desc VARCHAR2,
      pi_as_of_date DATE,
      pi_cashflow_date DATE
      )
    RETURN PKG_PIPELINED_TENOR.piped_buckets PIPELINED

------

INSERT INTO TABLE1 (
column1,
column2,
column3,
column4) VALUES 
SELECT 
 O.COLUM1,
 O.COLUMN2,
[b] (SELECT A.COLUMN1 FROM TABLE(FNC_AGG_GET_BUCKET('4G',V_AS_OF_DATE,O.MATURITY_DATE))A),[/b]
O.COLUMN4
FROM TABLE O

Open in new window


Is there any better way of doing this ?
0
Comment
Question by:ronan_40060
2 Comments
 
LVL 16

Assisted Solution

by:Wasim Akram Shaik
Wasim Akram Shaik earned 150 total points
ID: 37781050
First of all.. the insert statement is not valid.. you cannot have the values clause when you are using select statement..!!


I think you have just pasted the definition of the function..!!

is column3 data type the same from the output of pipelined function???

if its same then its ok??


well, i don't see anything wrong in the approach .?? you can go ahead and use this

do you have any errors as such?, if yes then let us know..!!
0
 
LVL 27

Accepted Solution

by:
sujith80 earned 350 total points
ID: 37782820
You may not need a pipelined function here. You are getting a single row out of the function, that may as well be achieved with a normal function.

And if the logic of the function is not complex, you may as well get rid of the function and
- Convert is as join or
- Write it as a scalar subquery

that will certainly perform better.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PL/SQL LOOP CURSOR 3 58
Concat multi row values of a field in oracle 6 56
How to free up undo space? 3 29
Oracle - SQL Parse String 5 20
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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

867 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