Solved

Return value from a function

Posted on 2012-03-29
2
532 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

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.

Question has a verified solution.

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

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

831 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