PL/SQL Pipelined Function to Compare *ANY* 2 tables
I am trying to create a pipelined function in 10g R1 that will take the name of two tables, compare the the tables using dynamic SQL and pipe out the resulting rows using the appropriate row type. The pipelined function will be used in a DML insert statement.
For example:
create table a (f1 number, f2, date, f3 varchar2);
create table b (f1 number, f2, date, f3 varchar2);
create table c (f1 number, f2, date, f3 varchar2);
create or replace TYPE AnyCollTyp IS TABLE OF ANYTYPE;
create or replace TYPE CRowType IS c%ROWTYPE;
create or replace TYPE CRowTabType IS table of CRowType;
CREATE OR REPLACE FUNCTION compareTables (p_source IN VARCHAR2, p_dest IN VARCHAR2)
RETURN AnyCollTyp PIPELINED
IS
CURSOR columnCur (p_tableName IN user_tab_columns.table_name%TYPE)
IS
SELECT column_name, column_id
FROM user_tab_columns
WHERE table_name = p_tableName
ORDER BY column_id;
l_cur sys_refcursor;
l_rec ANYTYPE;
l_stmt VARCHAR2 (32767);
BEGIN
l_stmt := 'select ';
FOR columnRec IN columnCur (p_dest)
LOOP
l_stmt := l_stmt || CASE
WHEN columnRec.column_id > 1
THEN ','
ELSE ''
END || columnRec.column_name;
END LOOP;
l_stmt := l_stmt || ' from ' || p_source;
l_stmt := l_stmt || ' minus ';
l_stmt := l_stmt || ' select ';
FOR columnRec IN columnCur (p_dest)
LOOP
l_stmt := l_stmt || CASE
WHEN columnRec.column_id > 1
THEN ','
ELSE ''
END || columnRec.column_name;
END LOOP;
l_stmt := l_stmt || ' from ' || p_dest;
OPEN l_cur FOR l_stmt;
LOOP
FETCH l_cur
INTO l_rec;
PIPE ROW (l_rec);
EXIT WHEN l_cur%NOTFOUND;
END LOOP;
CLOSE l_cur;
RETURN;
END compareTables;
The pipelined function gets created without error. However, the testCompare procedure gets an error:
SQL> create or replace procedure testCompare is
begin
insert into c
select *
from (TABLE(CAST(compareTables('a','b') as cRowTabType)));
dbms_output.put_line(SQL%ROWCOUNT || ' rows inserted into c.');
end;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TESTCOMPARE:
LINE/COL ERROR
3/4 PL/SQL: SQL Statement ignored
5/47 PL/SQL: ORA-22800: invalid user-defined type
Does anyone know what I am doing wrong? Is there a better way to compare any two tables and get the resulting rows?
904640 wrote:
Hi All,
Is it possible to post messages to weblogic JMS queue from pl/sql procedure/function?
From this Queue, message will be read by OSB interface.
Any help will be highly appreciated.
http://www.lmgtfy.com/?q=oracle+pl/sql+weblogic+jms+queue
Similar Messages
-
How to Passing clob to PL/SQL pipeline function
I have a PL/SQL stored function which takes clob as input parameter and sends the results in a pipe line.
create or replace function GetIds(p_list clob, p_del varchar2 := ',') return ideset_t pipelined is
I am using ojdbc14.jar (Oracle 10g driver) with oracle 9i (9.2.0.1.0).
I want to use the following SQL Query select * from table(GetIds(clob))
Now the question is how can I pass the clob from JDBC?
Here is my client code
PreparedStatement stmt = con.prepareStatement("SELECT COLUMN_VALUE FROM TABLE(GETIDS(?, ','))");
stmt.setCharacterStream(1, new StringReader(str), str.length());
stmt.executeQuery();
I get the following error when I try to run the program. The same thing works fine if the chracter lenght is less than some chaaracters.
java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2960)
at Test.main(Test.java:42)
Exception in thread "main"
The setChracterStream works for any insert/update clob. Example when I tried the query (INSERT INTO CLOB_TEST VALUES(?)) setCharacterStream just works fine.
Please any one can help me how to solve this.
Thanks in advance.Hóla LuÃs,
when you pick the PL/SQL function body returning a boolean, it implicitly means that TRUE means OK, while FALSE means error, always.
In order to associate such error to a given form field, you have to go back to the page definiton / validations and specify the name of the item in the corresponding field.
When you first create the validation rule, this value is not present even if you ask for the error message inline with the field.
The error message text can be specified in the validation definition, if I am not wrong.
When you need to return special error messages, including dynamic content for instance, you can use the Function Returning Error Message type, which reports an error when the string returned by the function is not null. This comes in handy when you want to display an item's code, for example, rather than generic text.
Even in this case, you must go back to the validation and specify the name of the field if you want to see it inline.
Hope it helps,
Flavio -
PipeLine Function Taking time to return Table record
Hi,
I want to use a function in join clause. so i go for pipelined function(using for loop to get record & 1 more loop to fetch in table type variable). i achieved what i required. but problem is it takes much time to fetch data. is there any other approach which returns table records without pipelined function.
please suggest me a better approach as soon as possible.Hi,
Thanks all for the quick response.
I am using oracle 10g
this is the table details & the entire function.
Create object & table type to use in the function
CREATE OR REPLACE TYPE SYSADM.STR_TYPE AS OBJECT(COLUMNVALUE VARCHAR2(8),FromNo Int,ToNo Int)
CREATE OR REPLACE TYPE SYSADM.STR_ARRAY AS TABLE OF STR_TYPE
table involved
View : VesselType
column : Code varchar2(5)
Table : T065_SHIP
column : SKIPS_KODE varchar2(4)
CODE_SHIPTYPE varchar2(5)
Table : SelsKap
column : SELSKAPSKODE varchar2(4)
Table : t041_shiptypeusers
column : Code_ShipType varchar2(5)
USERID varchar2(8)
View : PositionBook
column : VesselCode varchar2(8)
VoyageNo integer
Company varchar2(4)
Table : T62_BRUKER_SELSKAP
column : SELSKAPSKODE varchar2(4)
BRUKER varchar2(8)
Pipelined function
CREATE OR REPLACE FUNCTION SYSADM.TF_ShiporShipTypeByUser
In_UserName IN VARCHAR2,
In_Type IN VARCHAR2,
In_VesselCode IN VARCHAR2,
In_CompanyHistory IN NUMBER DEFAULT 0
RETURN str_array PIPELINED AS
l_ShipTypeUser NUMBER(10,0);
l_CompanyUser NUMBER(10,0);
l_UseCompanyHistory NUMBER(1,0);
l_Snicsacct NUMBER(1,0);
BEGIN
BEGIN
SELECT shiptype_user,
company_user
INTO l_ShipTypeUser,
l_CompanyUser
FROM User_Segregation;
EXCEPTION
WHEN OTHERS THEN
l_ShipTypeUser := NULL;
l_CompanyUser := NULL;
END;
BEGIN
SELECT 1 INTO l_Snicsacct
FROM DUAL
WHERE NOT EXISTS ( SELECT 1 FROM sn_user_cfg WHERE UserID='SNICS' and CfgID='ACCTSYS');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
IF In_CompanyHistory = 1
THEN
BEGIN
SELECT CfgData
INTO l_UseCompanyHistory
FROM SN_User_Cfg
WHERE CfgID = 'USE COMPANY HISTORY'
AND UserID = 'SNICS';
EXCEPTION
WHEN OTHERS THEN
l_UseCompanyHistory := 0;
END;
END IF;
IF In_UserName = 'SYSADM' OR (l_CompanyUser = 0 AND l_ShipTypeUser = 0)
OR (l_CompanyUser = 1 and l_Snicsacct =1 ) or (In_CompanyHistory = 0 and l_CompanyUser = 1 and In_Type ='ShipType')
OR (l_ShipTypeUser = 1 and In_Type = 'Company')
THEN
BEGIN
IF In_Type = 'ShipType'
THEN
BEGIN
FOR cur IN (SELECT Code ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM VesselType )
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
ELSIF In_Type = 'Ship'
THEN
BEGIN
FOR cur IN (SELECT SKIPS_KODE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP
WHERE SKIPS_KODE = NVL(In_VesselCode,SKIPS_KODE ))
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
ELSIF In_Type = 'Company'
THEN
BEGIN
FOR cur IN (SELECT SELSKAPSKODE ShipCode
, NULL VoyageFrom
, NULL VoyageTo
FROM SelsKap)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
END IF;
END;
ELSE
IF In_Type = 'Ship'
THEN
BEGIN
IF l_ShipTypeUser =1
THEN
BEGIN
FOR cur IN (SELECT S.SKIPS_KODE ShipCode
, 1 FromVoyage
, 999999999 ToVoyage
FROM T065_SHIP S
JOIN t041_shiptypeusers U
ON S.CODE_SHIPTYPE = U.Code_ShipType
AND USERID = In_UserName
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
GROUP BY S.SKIPS_KODE)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.FromVoyage,cur.ToVoyage));
END LOOP;
RETURN;
END;
ELSIF l_CompanyUser = 1
THEN
BEGIN
IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
THEN
FOR cur IN (SELECT a.VesselCode ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
JOIN T62_BRUKER_SELSKAP b
ON a.Company = b.SELSKAPSKODE
AND b.BRUKER = In_UserName
WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
UNION
SELECT a.VesselCode ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.company = b.SELSKAPSKODE
WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
AND b.SELSKAPSKODE IS NULL
GROUP BY a.VesselCode,
a.VoyageNo,
a.VoyageNo)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
ELSE
FOR cur IN (SELECT a.SKIPS_KODE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP a
JOIN T62_BRUKER_SELSKAP b
ON a.Company = b.SELSKAPSKODE
AND b.BRUKER = In_UserName
WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
AND NVL(l_UseCompanyHistory,0) = 0
UNION
SELECT a.SKIPS_KODE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.company = b.SELSKAPSKODE
WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
AND b.SELSKAPSKODE IS NULL
GROUP BY a.SKIPS_KODE)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END IF;
END;
END IF;
END;
ELSIF In_Type = 'ShipType'
THEN
IF l_ShipTypeUser = 1
THEN
BEGIN
FOR cur IN (SELECT S.CODE_SHIPTYPE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP S
JOIN t041_shiptypeusers U
ON S.CODE_SHIPTYPE = U.Code_ShipType
AND USERID = In_UserName
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
GROUP BY S.CODE_SHIPTYPE)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
ELSIF l_CompanyUser = 1
THEN
IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
THEN
BEGIN
FOR cur IN (SELECT a.VesselType ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
JOIN T62_BRUKER_SELSKAP b
ON a.COMPANY = b.SELSKAPSKODE
AND b.BRUKER = In_UserName
WHERE a.VesselCode = NVL(In_VesselCode,a.VesselCode)
UNION
SELECT a.VesselType ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.company = b.SELSKAPSKODE
WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
AND b.SELSKAPSKODE IS NULL
GROUP BY a.VesselType,
a.VoyageNo,
a.VoyageNo)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
ELSE
BEGIN
FOR cur IN (SELECT S.CODE_SHIPTYPE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP S
JOIN T62_BRUKER_SELSKAP b
ON S.company = b.SELSKAPSKODE
AND B.BRUKER = In_UserName
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
AND NVL(l_UseCompanyHistory,0) = 0
UNION
SELECT S.CODE_SHIPTYPE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP S
LEFT JOIN T62_BRUKER_SELSKAP b
ON S.company = b.SELSKAPSKODE
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
AND b.SELSKAPSKODE IS NULL)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
END IF;
END IF;
ELSIF In_Type = 'Company'
THEN
BEGIN
FOR cur IN (SELECT a.SELSKAPSKODE ShipCode
, NULL VoyageFrom
, NULL VoyageTo
FROM Selskap a
JOIN T62_BRUKER_SELSKAP b
ON a.SELSKAPSKODE = b.SELSKAPSKODE
WHERE b.BRUKER = In_UserName
Union All
Select a.SELSKAPSKODE ShipCode
, NULL VoyageFrom
, NULL VoyageTo
From Selskap a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.SELSKAPSKODE = b.SELSKAPSKODE
Where b.SELSKAPSKODE IS NULL
GROUP BY a.SELSKAPSKODE)
LOOP
PIPE ROW(str_type(cur.ShipCode,cur.VoyageFrom,cur.VoyageTo));
END LOOP;
RETURN;
END;
END IF;
END IF;
END;
select statement which i call the function it takes minimum 6 seconds to execute. It gives 8339 records
WITH deftbl AS ( SELECT /*+ CACHE(deftbl) */
/*+ result_cache */
a.VesselCode,
a.VoyageNo,
CASE a.BallastLeg When 0
THEN MIN(a.ArrivalDate)
ELSE NVL(( SELECT MAX(DepartureDate)
FROM PositionBook b
WHERE b.VesselCode = a.VesselCode
AND b.VoyageNo = (Select MAX(VoyageNo) From PositionBook c Where c.VesselCode = a.VesselCode and c.VoyageNo<a.VoyageNo)
),MIN(a.ArrivalDate))
END AS StartOfVoyage,
MAX(DepartureDate) EndOfVoyage
FROM PositionBook a
JOIN TABLE(*TF_ShiporShipTypeByUser*('BKA', 'Ship', NULL, 1)) D /*Calling the function*/
ON D.ColumnValue = a.VesselCode
AND a.VoyageNo BETWEEN D.FromVoyageNo AND D.ToVoyageNo
GROUP BY VesselCode,VoyageNo,a.BallastLeg )
SELECT /*+ result_cache */
ROW_NUMBER() OVER(PARTITION BY a.VesselCode ORDER BY a.VoyageNo DESC) as "Row"
,a.VesselCode
,v.Name AS VesselName
,a.VoyageNo
,c.StartOfVoyage AS FromPort
,c.EndOfVoyage AS ToPort
/*,a.FROMPORT
,a.TOPORT*/
, CASE
WHEN ( SELECT PortName
FROM PositionBook b
WHERE b.VesselCode = a.VesselCode
AND b.VoyageNo = a.VoyageNo
AND SYSDATE BETWEEN ArrivalDate AND DepartureDate ) IS NOT NULL
THEN ( SELECT FIRST_VALUE(PortName) OVER(PARTITION BY b.vesselcode,b.VoyageNo ORDER BY b.vesselcode,b.VoyageNo,b.ArrivalDate,b.secondarytime)
FROM PositionBook b
WHERE b.VesselCode = a.VesselCode
AND b.VoyageNo = a.VoyageNo
AND SYSDATE BETWEEN ArrivalDate AND DepartureDate
AND ROWNUM=1
WHEN SYSDATE BETWEEN c.StartOfVoyage AND c.EndOfVoyage
THEN ( SELECT 'Steam From '||FIRST_VALUE(UPPER(PortName)) OVER(PARTITION BY b.vesselcode,b.VoyageNo ORDER BY b.vesselcode,b.VoyageNo,b.ArrivalDate desc,b.secondarytime desc)
FROM POSITIONBOOK b
WHERE b.VesselCode = a.VesselCode AND b.VoyageNo = a.VoyageNo
AND b.ArrivalDate<SYSDATE
AND ROWNUM=1
WHEN (c.StartOfVoyage-SYSDATE)>0
THEN 'Voyage Not Started'
WHEN (c.EndOfVoyage-SYSDATE)<0
THEN 'Voyage Completed'
ELSE Null
END "Location"
,( SELECT MIN(b.PortName) KEEP(DENSE_RANK FIRST ORDER BY b.ArrivalDate,b.secondarytime) OVER(PARTITION BY b.VesselCode,b.VoyageNo)
FROM POSITIONBOOK b
WHERE b.VesselCode = a.VesselCode AND b.VoyageNo = a.VoyageNo
AND b.ArrivalDate>SYSDATE
AND ROWNUM=1
) AS NextPort
, ( SELECT MIN(b.ArrivalDate) KEEP(DENSE_RANK FIRST ORDER BY b.ArrivalDate,b.secondarytime) OVER(PARTITION BY b.VesselCode,b.VoyageNo)
FROM POSITIONBOOK b
where b.VesselCode = a.VesselCode AND b.VoyageNo = a.VoyageNo
AND b.ArrivalDate>SYSDATE
AND ROWNUM=1
) AS NextETA
,a.STATUS VoyageStatus
,a.Trade
,UFN_MyVoyConcatinate_Values('FIXNOTE', a.VesselCode, a.VoyageNo) FixNote
,UFN_MyVoyConcatinate_Values('CHARTERER', a.VesselCode, a.VoyageNo) Charterer
,CASE WHEN st.CurrentStatus=0
THEN 1
WHEN st.CurrentStatus=1
THEN 0
ELSE st.CurrentStatus
END AS CurrentStatus
FROM Positionbook a
JOIN deftbl c
ON a.VesselCode = c.VesselCode
AND a.VoyageNo = c.VoyageNo
JOIN Vessel v
ON v.Code = c.VesselCode
LEFT JOIN GTT_VOYAGESTATUS st
ON st.VesselCode = c.Vesselcode
AND st.VoyageNo = c.VoyageNo
GROUP BY a.VesselCode
, v.Name
, a.VoyageNo
, c.StartOfVoyage
, c.EndOfVoyage
/*, a.FROMPORT
, a.TOPORT*/
, a.Status
, a.Trade
, st.CurrentStatus;
Note:
i changed the function without pipelined also. but it doesnt show much difference
non pipelined function
CREATE OR REPLACE FUNCTION TF_ShiporShipTypeByUser_nonp
In_UserName IN VARCHAR2,
In_Type IN VARCHAR2,
In_VesselCode IN VARCHAR2,
In_CompanyHistory IN NUMBER DEFAULT 0
RETURN str_array AS
l_ShipTypeUser NUMBER(10,0);
l_CompanyUser NUMBER(10,0);
l_UseCompanyHistory NUMBER(1,0);
l_Snicsacct NUMBER(1,0);
l_str_array str_array:=str_array();
BEGIN
BEGIN
SELECT shiptype_user,
company_user
INTO l_ShipTypeUser,
l_CompanyUser
FROM User_Segregation;
EXCEPTION
WHEN OTHERS THEN
l_ShipTypeUser := NULL;
l_CompanyUser := NULL;
END;
BEGIN
SELECT 1 INTO l_Snicsacct
FROM DUAL
WHERE NOT EXISTS ( SELECT 1 FROM sn_user_cfg WHERE UserID='SNICS' and CfgID='ACCTSYS');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
IF In_CompanyHistory = 1
THEN
BEGIN
SELECT CfgData
INTO l_UseCompanyHistory
FROM SN_User_Cfg
WHERE CfgID = 'USE COMPANY HISTORY'
AND UserID = 'SNICS';
EXCEPTION
WHEN OTHERS THEN
l_UseCompanyHistory := 0;
END;
END IF;
IF In_UserName = 'SYSADM' OR (l_CompanyUser = 0 AND l_ShipTypeUser = 0)
OR (l_CompanyUser = 1 and l_Snicsacct =1 ) or (In_CompanyHistory = 0 and l_CompanyUser = 1 and In_Type ='ShipType')
OR (l_ShipTypeUser = 1 and In_Type = 'Company')
THEN
BEGIN
IF In_Type = 'ShipType'
THEN
BEGIN
SELECT STR_TYPE(Code,1,999999999)
BULK COLLECT INTO l_str_array
FROM VesselType;
RETURN l_str_array;
END;
ELSIF In_Type = 'Ship'
THEN
BEGIN
SELECT STR_TYPE(SKIPS_KODE,1,999999999)
BULK COLLECT INTO l_str_array
FROM T065_SHIP
WHERE SKIPS_KODE = NVL(In_VesselCode,SKIPS_KODE);
RETURN l_str_array;
END;
ELSIF In_Type = 'Company'
THEN
BEGIN
SELECT STR_TYPE(SELSKAPSKODE,NULL,NULL)
BULK COLLECT INTO l_str_array
FROM SelsKap;
RETURN l_str_array;
END;
END IF;
END;
ELSE
IF In_Type = 'Ship'
THEN
BEGIN
IF l_ShipTypeUser =1
THEN
BEGIN
SELECT STR_TYPE(S.SKIPS_KODE,1,999999999)
BULK COLLECT INTO l_str_array
FROM T065_SHIP S
JOIN t041_shiptypeusers U
ON S.CODE_SHIPTYPE = U.Code_ShipType
AND USERID = In_UserName
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
GROUP BY S.SKIPS_KODE;
RETURN l_str_array;
END;
ELSIF l_CompanyUser = 1
THEN
BEGIN
IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
THEN
SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
BULK COLLECT INTO l_str_array
FROM ( SELECT a.VesselCode ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
JOIN T62_BRUKER_SELSKAP b
ON a.Company = b.SELSKAPSKODE
AND b.BRUKER = In_UserName
WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
UNION
SELECT a.VesselCode ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.company = b.SELSKAPSKODE
WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
AND b.SELSKAPSKODE IS NULL
GROUP BY a.VesselCode,
a.VoyageNo,
a.VoyageNo);
RETURN l_str_array;
ELSE
SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
BULK COLLECT INTO l_str_array
FROM (SELECT a.SKIPS_KODE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP a
JOIN T62_BRUKER_SELSKAP b
ON a.Company = b.SELSKAPSKODE
AND b.BRUKER = In_UserName
WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
AND NVL(l_UseCompanyHistory,0) = 0
UNION
SELECT a.SKIPS_KODE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.company = b.SELSKAPSKODE
WHERE a.SKIPS_KODE = NVL(In_VesselCode, a.SKIPS_KODE)
AND b.SELSKAPSKODE IS NULL
GROUP BY a.SKIPS_KODE);
RETURN l_str_array;
END IF;
END;
END IF;
END;
ELSIF In_Type = 'ShipType'
THEN
IF l_ShipTypeUser = 1
THEN
BEGIN
SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
BULK COLLECT INTO l_str_array
FROM (SELECT S.CODE_SHIPTYPE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP S
JOIN t041_shiptypeusers U
ON S.CODE_SHIPTYPE = U.Code_ShipType
AND USERID = In_UserName
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
GROUP BY S.CODE_SHIPTYPE);
RETURN l_str_array;
END;
ELSIF l_CompanyUser = 1
THEN
IF l_UseCompanyHistory = 1 AND In_CompanyHistory = 1
THEN
BEGIN
SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
BULK COLLECT INTO l_str_array
FROM ( SELECT a.VesselType ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
JOIN T62_BRUKER_SELSKAP b
ON a.COMPANY = b.SELSKAPSKODE
AND b.BRUKER = In_UserName
WHERE a.VesselCode = NVL(In_VesselCode,a.VesselCode)
UNION
SELECT a.VesselType ShipCode
, a.VoyageNo VoyageFrom
, a.VoyageNo VoyageTo
FROM PositionBook a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.company = b.SELSKAPSKODE
WHERE a.VesselCode = NVL(In_VesselCode, a.VesselCode)
AND b.SELSKAPSKODE IS NULL
GROUP BY a.VesselType,
a.VoyageNo,
a.VoyageNo);
RETURN l_str_array;
END;
ELSE
BEGIN
SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
BULK COLLECT INTO l_str_array
FROM ( SELECT S.CODE_SHIPTYPE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP S
JOIN T62_BRUKER_SELSKAP b
ON S.company = b.SELSKAPSKODE
AND B.BRUKER = In_UserName
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
AND NVL(l_UseCompanyHistory,0) = 0
UNION
SELECT S.CODE_SHIPTYPE ShipCode
, 1 VoyageFrom
, 999999999 VoyageTo
FROM T065_SHIP S
LEFT JOIN T62_BRUKER_SELSKAP b
ON S.company = b.SELSKAPSKODE
WHERE S.SKIPS_KODE = NVL(In_VesselCode, S.SKIPS_KODE)
AND b.SELSKAPSKODE IS NULL);
RETURN l_str_array;
END;
END IF;
END IF;
ELSIF In_Type = 'Company'
THEN
BEGIN
SELECT STR_TYPE(ShipCode,VoyageFrom,VoyageTo)
BULK COLLECT INTO l_str_array
FROM ( SELECT a.SELSKAPSKODE ShipCode
, NULL VoyageFrom
, NULL VoyageTo
FROM Selskap a
JOIN T62_BRUKER_SELSKAP b
ON a.SELSKAPSKODE = b.SELSKAPSKODE
WHERE b.BRUKER = In_UserName
Union All
Select a.SELSKAPSKODE ShipCode
, NULL VoyageFrom
, NULL VoyageTo
From Selskap a
LEFT JOIN T62_BRUKER_SELSKAP b
ON a.SELSKAPSKODE = b.SELSKAPSKODE
Where b.SELSKAPSKODE IS NULL
GROUP BY a.SELSKAPSKODE);
RETURN l_str_array;
END;
END IF;
END IF;
END;please kindly provide me your valuable suggestions
Edited by: ganex27lin on Mar 16, 2011 1:54 AM -
Help with creating a sql file that will capture any database table changes.
We are in the process of creating DROP/Create tables, and using exp/imp data into the tables (the data is in flat files).
Our client is bit curious to work with. They do the alterations to their database (change the layout, change the datatype, drops tables) without our knowing. This has created a hell lot of issues with us.
Is there a way that we can create a sql script which can capture any table changes on the database, so that when the client trys to execute imp batch file, the sql file should first check to see if any changes are made. If made, then it should stop execution and give an error message.
Any help/suggestions would be highly appreciable.
Thanks,Just to clarify...
1. DDL commands are like CREATE, DROP, ALTER. (These are different than DML commands - INSERT, UPDATE, DELETE).
2. The DDL trigger is created at the database level, not on each table. You only need one DDL trigger.
3. You can choose the DDL commands for which you want the trigger to fire (probably, you'll want CREATE, DROP, ALTER, at a minimum).
4. The DDL trigger only fires when one of these DDL commands is run.
Whether you have 50 tables or 50,000 tables is not significant to performance in this context.
What's signficant is how often you'll be executing the DDL commands on which the trigger is set to fire and whether the DDL commands execute in acceptable time with the trigger in place. -
Hi ,
I test the routines found in http://sheikyerbouti.developpez.com/recordset/record_set.htm
I have a problem in the sample routine in Forms10g regarding pipelined function.
Whereas , the whole routine database part and client side in SQL*PLUS works fine.... the client side on Forms10g does not.......
I used two versions in when-button-pressed trigger:
1)Declare
cur SYS_REFCURSOR ;
begin
Open cur for SELECT * FROM TABLE(Pkg_Cur_.Get_Raws2(CURSOR(SELECT * FROM EMP WHERE DEPTNO = 10)));
end;
The error message in compilation time is..
Error 606: The subquery cursor is invalid in the client side
and the second version is:
2)Declare
tab Pkg_Cur_.REC_EMP_;
begin
tab:=Pkg_Cur_.GET_RAWS2('SELECT * FROM EMP WHERE DEPTNO = 10');
end;whereas the database package is defined as:
CREATE OR REPLACE PACKAGE Pkg_Cur_
IS
TYPE REC_EMP_ IS TABLE OF EMP%ROWTYPE INDEX BY BINARY_INTEGER ;
FUNCTION Get_Raws RETURN REC_EMP_ ;
FUNCTION Get_Raws2 ( cur_lig IN SYS_REFCURSOR )
RETURN TYPE_TAB_REC_EMP_ PIPELINED ;
END Pkg_Cur_ ;and the database package body is as follows:
CREATE OR REPLACE PACKAGE BODY Pkg_Cur_
IS
FUNCTION Get_Raws RETURN REC_EMP_
IS
TAB REC_EMP_;
BEGIN
SELECT * BULK COLLECT INTO TAB FROM EMP ;
RETURN TAB ;
END ;
FUNCTION Get_Raws2 ( cur_lig IN SYS_REFCURSOR )
RETURN TYPE_TAB_REC_EMP_ PIPELINED
IS
Trec TYPE_REC_EMP_ := TYPE_REC_EMP_(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL ) ;
Remp EMP%ROWTYPE ;
BEGIN
LOOP
FETCH cur_lig INTO Remp ;
EXIT WHEN cur_lig%NOTFOUND ;
-- Handling datas --
Trec.EMPNO := Remp.EMPNO ;
Trec.ENAME := Remp.ENAME ;
Trec.JOB := Remp.JOB ;
Trec.MGR := Remp.MGR ;
Trec.HIREDATE := Remp.HIREDATE ;
Trec.SAL := Remp.SAL * 1.1 ;
Trec.COMM := Remp.COMM ;
Trec.DEPTNO := Remp.DEPTNO ;
-- Return value --
PIPE ROW( Trec ) ;
END LOOP ;
RETURN ;
END ;
END Pkg_Cur_ ;
So , how the form trigger should be written...????
If somebody could help me i would be grateful...!!!!
Thanks a lot
SimonIn the second anonymous block you're trying to populate a record with a table. You would need to select from the function and either bulk collect into a table variable or fetch into a record variable in a loop. Bulk collect is also not supported on the client side.
I've been looking at pipelined function possibilities in another thread:
table functions
The problem you have is actually with the Cursor functions, not the Pipelined functions. -
SQL Function to compare 2 strings
Hi All
Is there any SQL function to compare 2 strings?If you are looking for a character by character comparison then you would have to do something like...
SQL> ed
Wrote file afiedt.buf
1 WITH T AS (select 'THIS IS MY 1ST STRING' string1, 'THIS IS MY 2ND String Bob' string2 from dual)
2 --
3 select s1ch, s2ch, decode(s1ch,s2ch,'Match','Mismatch') as compare
4 from (
5 select rn, substr(string1,rn,1) as s1ch, substr(string2,rn,1) as s2ch
6 from t, (select rownum rn from t connect by rownum <= greatest(length(string1), length(string2)))
7 )
8* order by rn
SQL> /
S S COMPARE
T T Match
H H Match
I I Match
S S Match
Match
I I Match
S S Match
Match
M M Match
Y Y Match
Match
1 2 Mismatch
S N Mismatch
T D Mismatch
Match
S S Match
T t Mismatch
R r Mismatch
I i Mismatch
N n Mismatch
G g Mismatch
Mismatch
B Mismatch
o Mismatch
b Mismatch
25 rows selected.
SQL> -
Is there any way to pass through PIPELINED function
Hello,
For clarity of my code I would like to move some part of my PIPELINED function out to sub-function. It there any way to call one PIPELINED function from other PIPELINED function a way to union their results?
I can try to use temporary table to emulate such behavior, but it won't be exactly the same...
RegardsYes, you can. The only thing you need to remember is pipelined function can be salled from SQL only. So your functions will look like:
Pipelined function 1:
create or replace
function pipelined_function1(...)
return ...
pipelined
is
begin
pipe row(...);
end;
/Pipelined function 2:
create or replace
function pipelined_function2(...)
return ...
pipelined
is
begin
for v_rec in (select * from table(pipelined_function1(...))) loop
pipe row(...);
end loop;
pipe row(...);
end;
/SY. -
Turning sql string (with dynamic columns) into a pipelined function
Hi guys,
I was working on an apex report the other day, and wrote the sql below (for those who don't know apex well, in an apex report you can define the columns at runtime.) When I was finished, I said to myself: "It would be great to have a pipeline function with this capability." So, the idea would be to have a sql string where the columns are created dynamically, depending on input parameters - and then be able to use this sql everywhere (oracle reports, sqlplus) through a pipelined function.
Here's the sql (simplified, of course, the data itself is actually not important - the LOOP is the key)
declare
v_sql varchar2(4000);
begin
v_sql := 'select client, ';
for i in (select employee from company_employees_view where condition = pi_parameter order by 1) loop
v_sql := v_sql || sum(decode(employee,''' || i.employee || ''', total)) "' || i.employee || '"';
end loop;
v_sql := v_sql || ', sum(total) "Total"';
v_sql := v_sql || ' from company_employees_view group by client';
end;
This sql would result in a final product like:
select client
, sum(decode(employee,'John',total) "John"
, sum(decode(employee,'Paul',total) "Paul"
, sum(decode(employee,'George',total) "George"
(and so on... this sql could have more or less columns depending on the input parameters of the function)
from company_employees_view
group by client;
I have tried feeding this sql into a ref cursor and an object, but always received an "inconsistent datatypes" message.
The object would be something like:
create or replace object rt_employee as (total number);
create or replace tt_employee as table of rt_employee;
create or replace object rt_client as (
client varchar2(100),
employee tt_employee);
create or replace tt_client as table of rt_client;
(I am not paying too much attention to syntax here.)
By the way, no hurry whatsoever, this is just for fun, take your time. I am using database XE with apex 2.1 and sql developer 1.2.
Thanks, RogerThis is the only solution I've ever seen to dynamic pipelined columns...
How to pipeline a function with a dynamic number of columns? -
Function to compare particular value with LOV Additional Description column
Hi,
Is there an existing function that compares a value with the "Additional Description" of a particular LOV ?
Can the comparison be done by "Adminstration - Personalization"?Sorry & thanks sathish,
Now i got the result.
SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE BETWEEN TO_DATE ('31.01.2007 00:00:00', 'DD.MM.YYYY HH24:MI:SS') AND TO_DATE ('31.01.2007 23:59:59', 'DD.MM.YYYY HH24:MI:SS')
2 and application_id=2007010028552;
DECISIONED_STAGE_ID DECISIONED_STAG
2006060113 SYSTEM
================================
But one doubt,
When i created the column with the date datatype how it gets the time value,
And in one environment db i got the result but in another environment i dont get,
Shall i want to change any session status of date? -
PL/SQL-find out extra rows present in table by comparing 2 similar tables
Hi, can any one give me an idea to find out the extra rows present in table by comparing 2 similar tables using pl/sql.
REQUIREMENT::i am working on the upgrade environment.my previous database has some tables and having data.Now functional folks are adding some new data to the existing tables for the upgrade database.I need to identify that new rows which are added by them.
for this , i created name table with 2 columns n,n1 which contains the table names.
Table Name:Name
columns:n n1
a ax
b bx
c cx
a,b c........are the table names which are in the previous database environment.(approx >1500 tables)These tables having data.
ax,bx,cx..........table names which are in the upgrade environment contains the extra data which is added by the functional folks.
a&ax,b&bx.................(approx 1500 tables) are having same structure except some of them.
Now i want to write a pl/sql program that reads both table names a&ax from name table and then by comparing the rows of a&ax ,i need to find out the extra rows present in the ax table to store that in different place.
Example:
a table
id name
1 co
2 wi
3 il
ax table
id name
1 co
2 wi
3 il
4 va
5 ca
Here i need to find out the difference b/n the 2 tables ,the extra rows id 4,5 and place it some where.this is just for demo, is this you mean?
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e full outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7934 MILLER 10 10 ACCOUNTING
7839 KING 10 10 ACCOUNTING
7782 CLARK 10 10 ACCOUNTING
snipp........
7521 WARD 30 30 SALES
7499 ALLEN 30 30 SALES
156 1
12 1
40 OPERATIONS
90 LOGISTIC
18 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e left outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7934 MILLER 10 10 ACCOUNTING
7839 KING 10 10 ACCOUNTING
7782 CLARK 10 10 ACCOUNTING
7902 FORD 20 20 RESEARCH
snipp..................
7654 MARTIN 30 30 SALES
7521 WARD 30 30 SALES
7499 ALLEN 30 30 SALES
156 1
12 1
16 rows selected.
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,ename,e.DEPTNO emp_deptno, d.deptno dept_deptno,d.DNAME
2 FROM EMP e[b] right outer join DEPT d
3* on d.DEPTNO= e.DEPTNO
SQL> /
EMPNO ENAME EMP_DEPTNO DEPT_DEPTNO DNAME
7369 SMITH 20 20 RESEARCH
7499 ALLEN 30 30 SALES
7521 WARD 30 30 SALES
7566 JONES 20 20 RESEARCH
snipp......................
7902 FORD 20 20 RESEARCH
7934 MILLER 10 10 ACCOUNTING
40 OPERATIONS
90 LOGISTIC
16 rows selected. -
Pipelined function, select from table t1 or t2 depending on user's choise
Hi all,
My need is to select data from table t1 or t2 depending on user's choise using pipelined function. You can find my first guess below. Maybe someone can help me to save some code, I mean getting the same result without writing "PIPE ROW" twice.
FUNCTION fn_indicators (p_datbeg date, p_datend date, p_indicatorid number) return cl_risk_act pipelined IS
v_obj cl_user_type;
BEGIN
case when p_indicatorid = 1 then
FOR e IN (
select trunc(sysdate-1) as adate, 0 as cid, 0 as indicatorid, '0' as code, '0' as indicatorname, 0 as value, 0 as cnt, '0' as cname from dual
LOOP
v_obj.adate := e.adate;
v_obj.cid := e.cid;
v_obj.indicatorid := e.indicatorid;
v_obj.code := e.code;
v_obj.indicatorname := e.indicatorname;
v_obj.value := e.value;
v_obj.cnt := e.cnt;
v_obj.cname := e.cname;
PIPE ROW (v_obj);
END LOOP;
when p_indicatorid = 2 then
FOR e IN (
select trunc(sysdate-2) as adate, 1 as cid, 1 as indicatorid, '1' as code, '1' as indicatorname, 1 as value, 1 as cnt, '1' as cname from dual
LOOP
v_obj.adate := e.adate;
v_obj.cid := e.cid;
v_obj.indicatorid := e.indicatorid;
v_obj.code := e.code;
v_obj.indicatorname := e.indicatorname;
v_obj.value := e.value;
v_obj.cnt := e.cnt;
v_obj.cname := e.cname;
PIPE ROW (v_obj);
END LOOP;
end case;
RETURN;
end;marco wrote:
Justin,
In my real code table real_t1 or pipelinedfn_t2 is joined to other tables, so surely real code is bigger than sample one. It is not wise to keep code twise with only one table name changed. I think about dynamic sql to choose from two tables:
with t1 as
(select * from real_t1
t2 as
(select * from pipelinedfn_t2
t3 as (
[dynamic selection of t1 or t2 depending on user's choise]
select * from t3, t... where...I don't know correct syntax.
Any ideas?
>Justin,
In my real code table real_t1 or pipelinedfn_t2 is joined to other tables, so surely real code is bigger than sample one. It is not wise to keep code twise with only one table name changed. I think about dynamic sql to choose from two tables:
with t1 as
(select * from real_t1
t2 as
(select * from pipelinedfn_t2
t3 as (
[dynamic selection of t1 or t2 depending on user's choise]
select * from t3, t... where...I don't know correct syntax.
Any ideas?
Dynamic code does NOT scale.
Making the tradeoff of smaller code size for reduced performance is not one that I would make. -
Record vs object vs globle table in pipelined function
i want to make pipeline function , i show it can be made in following ways
please suggest which one is better in performance and maintenance.
1)
create type my_tab_type is object
(prodid number, a varchar2(1), b varchar2(1),
c varchar2(1), d varchar2(1), e varchar2(1))
create type my_tab_type_coll is table of my_tab_type;
create or replace function get_some_data (p_val in number)
return my_tab_type_coll pipelined is
begin
FOR i in (select * from my_table where prodid=p_val) loop
pipe row(my_tab_type(i.prodid,i.a,i.b,i.c,i.d,i.e));
end loop;
return;
end;
SELECT * FROM table(get_Some_Data(3));
2)
one can create globle tem table "Tlb_3". then can make a package like fllowing
create or replace
PACKAGE pk1
AS
TYPE T_type IS TABLE OF Tlb_3%ROWTYPE;
END;
and rest of the thing will be same like first one.
3)
TYPE outrec_typ IS RECORD (
var_num NUMBER(6),
var_char1 VARCHAR2(30),
var_char2 VARCHAR2(30)
TYPE outrecset IS TABLE OF outrec_typ;
and rest of the thing will be same like first one
so main question is relating to declaretion of TABLE which is returned.
yours sincerely
Edited by: 944768 on Jan 2, 2013 4:23 AMDUPLICATE THREAD!
How many times do you intend to ask this question?
This is the same question that you ask, and got answered, six months ago in this thread?
how to write Function returing table or set of rows.
And you ask it again a week ago in this thread
object vs record in pipelined function.
Have you forgotten those answers already? Why didn't you take the advice given there and perform some tests?
And you don't seem to acknowledge any of the help you get to your questions by marking them ANSWERED when they have been.
Please revisit this 32 questions and mark them ANSWERED as appropriate - Total Questions: 73 (32 unresolved)
>
i want to make pipeline function , i show it can be made in following ways
please suggest which one is better in performance and maintenance.
>
Why didn't you take the advice given there and perform some tests?
Option #1, using SQL types is better, especially for maintenance. Also SQL types are required if the function is going to be called from SQL. You can define PL/SQL or %ROWTYPE package variables and use them but Oracle will silently create 'hidden' (in 11g) SQL types and use those.
See Solomon's explanation and sample code in this recent thread
Re: Pipe line function
There certainly isn't any need to create a global temp table just so you can create the %ROWTYPE variable; you can create one of those based on a CURSOR. -
Hi,
Can any one please provide me a good example to try out pipelined function in oracle pl/sql ?
ThanksI'm curious. In your biography you state "I am a software programmer working in IT field from last 7-8 years. I am a OCP in Application Development Track"
So how come that you are not familiar with Oracle Documentation and it's full text search capability, which would have given you a reference, such as this?
C. -
Select remote pipelined function
System: AIX 5.1L
Oracle: 9.2.0.5.0 64 Bit
If I have a package, created in schema 'exceed', on 1 instance which has a pipelined function. I then grant execute to this package for another user, called 'nav'. On another instance, that has a database link (testtrjo) to the instance with the package above using the 'nav' user account to connect, I get error: ORA-30626: function/procedure parameters of remote object types are not supported. Here is is how I am executing this table funtion across the link:
select * from table(exceed.UP_EXCEED.UF_GetOpenEvent@testtrjo('locationsexport'));
When I execute this function as the 'nav' user on the instance that contains the package, it works fine. Like this:
select * from table(exceed.UP_EXCEED.UF_GetOpenEvent('locationsexport'));
Anyone know why this is happening? In the Oracle docs it states:
"Syntax for SQL Calling a PL/SQL Function
Use the following syntax to reference a PL/SQL function from SQL:
[[schema.]package.]function_name[@dblink][(param_1...param_n)]
For example, to reference a function you created that is called My_func, in the
My_funcs_pkg package, in the Scott schema, that takes two numeric parameters,
you could call the following:
SELECT Scott.My_funcs_pkg.My_func(10,20) FROM dual;"
Any help would be appreciated.Thanks for the reply. I did see that before I posted and tried it also but here is what happens:
create synonym Trjo_Exceed for UP_EXCEED@TestTrjo;
select * from table(Trjo_Exceed.UF_GetOpenEvent('locationsexport'));
ORA-00904: "TRJO_EXCEED"."UF_GETOPENEVENT": invalid identifier -
Pipelined function running fast but making the sp slow when used in it.
i have a sp which is running slow because of (pipelined) function
but function it self is fast.
is there any remedy.
select uno.a, uno.b, uno.c, uno1.c from
abc a
left join
TABLE(udf_fn(a, 'h',b,c,d)) uno
ON a.a.a= uno.a
AND a.b= uno.b
AND a.c= uno.c
AND a.d= uno.d
left join
TABLE(udf_fn(a, 'j',b,c,d)) uno1
ON a.a.a= uno1.a
AND a.b= uno1.b
AND a.c= uno1.c
AND a.d= uno1.dyours sincerely
Edited by: 944768 on Apr 30, 2013 11:56 PM
Edited by: 944768 on May 1, 2013 2:01 AMHi,
Please read SQL and PL/SQL FAQ
If you have a performance issue have a look at SQL and PL/SQL FAQ
When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
After 331 messages you should know how to post questions. Your code is unformatted and you did not provide the source of function udf_fn. How do you pretend us to answer?
Regards.
Al
Maybe you are looking for
-
Excise duty @10% not displaying in printpreview----SAP INVOICE
Dear experts, Here in Sap invoice Excise duty @10% is not displaying in the printpreview. I tried debugging in Report program, but couldn't able to find the solution. so please give me the solution with step by step, Because am new to this one. Thank
-
Can FI-CAx be used for making outgoing payments to business partners
Hi All, Can we use the installment plan in FI-CA for the outgoing payments to business partners. Our company has lot of lease contracts and these contracts have payments due to be paid on a monthly, quarterly, semi-annual, and annual basis. All these
-
Hi Experts, I am using GUI_DOWNLOAD to download a file on my local server, In debugging the file seems to be having perfect data but once the file gets downloaded it shows certain junk characters in the file.
-
How to run report on web in forms 10g
dear all, i have a form which call a report in form 6i i used the run_object(); how to run the report on web in forms 10g? is there any html settings? thanks Muhammad Nadeem
-
the specs say mid 2011. Will the imac 11.3 work for mirroring