PL/SQL function body return query sql, no problem found data
Hi allWe are trying to build a dynamic report based on the selection of the item by the user. We use the SQL query (body of function from PL/SQL returning SQL query). However when a user change the item and submit the page. The following error is displayed.
ORA-01403: no data is found.
our request is simple
declare
l_query varchar2 (30000) default 'select id from chw.
Start
if(:P11_PARA=1) then
l_query: = "select name from chw.
end if;
Return l_query;
end;
any quick help please.
Hello
I managed to recreate the error
To remove the error to change the area and choose "use generic Column Names (analysis of query runtime only).
Concerning
Paul
Tags: Database
Similar Questions
-
How to get the query of the region "PL/SQL function body returns the query string"?
Hello
is it possible to get the query string from the region of type "PL/SQL function body returns the query string"?
I can get the definition of the region as a PL/SQL procedure, but I am interested in the returned query. I tried to write something like
< pre > v_return_query: = «...» » ;
: P49_QUERY: = v_return_query;
Return v_return_query; < / pre >
to save the return on hidden item P49_QUERY string, but it does not work. I get the error message: ERR-1002 cannot find the item for the "P49_QUERY" element ID in the application '4000 '.
Kind regards
PrzemekIf you need to make reference to a page element in the block then you can use this type of control to avoid having to use generic column names:
if apex_application.get_current_flow_sgid(:APP_ID) = apex_application.get_sgid then-- runtime :P9_SQL := vSQL;else-- design time null;end if;
But if all you want to do is capture the SQL debugging you can take all the references element in the block and use the insert statement (in a debug table) as I showed earlier.
Scott
-
Oracle <>- MS SQL server, problem with DATE
HS current options are:
HS_FDS_TRACE_LEVEL = 255
HS_FDS_SHAREABLE_NAME=/usr/lib64/libodbc.so
HS_FDS_FETCH_ROWS = 1
HS_FDS_SQLLEN_INTERPRETATION = 32
The following image contains 2 screenshots.
http://maslovd.no-IP.org/public/doc/date_problem.PNG
1. selection of table of MS SQL server.
2 selection in Oracle DB link.
Any suggestions?
I asked here, that is why the DateForm column are returned as data type-(9)
SQL_WVARCHAR).
Could you please post the SQL Server table definition?
What's the FreeTDS version and on which platform did you configure DG4ODBC?
- Klaus
-
Dynamic region of the body of the function return query did not work
APEX 4.1
Oracle 11g
I have a report of dynamic fields according to the value of the different type of zone set element is body of pl/sql function, return query, see the source code of the region below.
declare
v_sql varchar2 (2000);
Start
IF: P2_BY = 'MONTH' THEN
v_sql: = 'SELECT ' | : P2_TYPE | ', SUM (JAN) JAN, SUM (FEB) FEB, SUM (MAR) MAR, SUM (APR) APR, SUM (MAY) MAY, SUM (JUN) JUN, SUM (JUL) JUL, SUM (AUG) AUG, SUM (SEP) SEP, SUM (OCT) OCT, SUM (NOV) NOV, SUM (DEC) DEC OF THE RPT_HOTEL GROUP BY ' | : P2_TYPE;
ON THE OTHER
v_sql: = 'SELECT ' | : P2_TYPE | ', SUM (Y2011) 2011, SUM (Y2012) Y2012, SUM (Y2013) Y2013, SUM (Y2014) 2014 RPT_HOTEL GROUP BY ' | : P2_TYPE;
Return v_sql;
end;
But "Missing expression" error when Save source in the region.
I checked the sql statement is valid in the sql command, and: P2_TYPE get the correct value.
If the generic column name 'use' then get the correct report, but the column name is random.
Please help solve.
Thank you so mcuh
Hi fac586,
I couldn't thank you more. Of course, read you my code and found that the design of table is not reasonable. in fact I just design for the demonstration of the prototype, so do not consider architecture.
I mean, it is that the problem has disappeared when I create a new page like this one, don't know how it happened. in any case what I need has been achieved, thank you very much for what you have done.
Here I paste my code for reference, that someone might need.
declare v_sql varchar2(2000); v_time varchar2(50); v_for varchar2(30); begin IF :P4_TIME='MONTH' THEN v_time := 'to_char(lodging_date,''MM'') MONTH'; v_for := 'to_char(lodging_date,''MM'')'; ELSE v_time := 'to_char(lodging_date,''YYYY'') YEAR'; v_for := 'to_char(lodging_date,''YYYY'')'; END IF; IF :P4_MEASURE='NIGHTS' THEN v_sql := 'SELECT * from (SELECT ' || :P4_BY || ',VENDOR_NAME,' || v_time || ',count(entry_legacy_key) ROOM_NIGHTS FROM HOTEL_EXPENSE GROUP BY ' || :P4_BY || ',VENDOR_NAME,' || v_for || ') PIVOT (SUM(ROOM_NIGHTS) FOR '; ELSE v_sql := 'SELECT * from (SELECT ' || :P4_BY || ',VENDOR_NAME,' || v_time || ',SUM(APPROVED_AMOUNT) SPENDING FROM HOTEL_EXPENSE GROUP BY ' || :P4_BY || ',VENDOR_NAME,' || v_for || ') PIVOT (SUM(SPENDING) FOR '; END IF; IF :P4_TIME='MONTH' THEN v_sql := v_sql || ' MONTH IN (''01'',''02'',''03'',''04'',''05'',''06'',''07'',''08'',''09'',''10'',''11'',''12''))'; ELSE v_sql := v_sql || ' YEAR IN (''2011'',''2012'',''2013'',''2014''))'; END IF; return v_sql; end;
and checked
'Use generic column names (analysis of query during execution only)'
column of the report used PL/QL name
declare v_sql varchar2(2000); begin v_sql := :P4_BY || ':VENDOR_NAME'; IF :P4_TIME='MONTH' THEN v_sql := v_sql || ' :Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec'; ELSE v_sql := v_sql || ':2011:2012:2013:2014'; END IF; return v_sql; end;
-
assign a value to a text element using the PL/SQL function body
Hello
I want to assign a value to a text element using PL/SQL function body option in the Source elements. But the below error when I try to apply it.
Source code:
declare
name varchar2 (100);
Start
If v ("P3_CREHIDD") = 'Edit' then
Select ename in the name of cpy_emp where empno = v('P3_EMPNO2');
end if;
end;
ERR-1904 unable to calculate the default item: type = computation_type = function body declare name varchar2 (100); so start v ('P3_CREHIDD') = 'Edit' and then select ename in the name of cpy_emp where empno = v('P3_EMPNO2'); end if; end;.
Thank you
David.Hello
Your body of the function doesn't return anything.
Maybe it worksdeclare l_name varchar2(100); begin if v('P3_CREHIDD') = 'Edit' then select ename into l_name from cpy_emp where empno = v('P3_EMPNO2'); end if; RETURN l_name; end;
BR, Jari
-
function to_numer returns the error in pl/sql
Hello
I don't have a prob when executing select double to_number('1234.56'), the numer contains decimal numbers
But this stm return number not valid error in the procedure, except if I use to_number('1234.56','9999999.99')
Please help me.
I need to set parameter in DB?
BTW: my NLS_NUMERIC_CHARACTER has the value '.,'
Thank you.function to_numer returns the error in pl/sql
hlthanh wrote:
Hello
I don't have a prob when executing select double to_number('1234.56'), the numer contains decimal numbers
But this stm return number not valid error in the procedure, except if I use to_number('1234.56','9999999.99')
Please help me.
I need to set parameter in DB?
BTW: my NLS_NUMERIC_CHARACTER has the value '.,'
Thank you.Handle: hlthanh
Status level: Beginner
Join date: March 7, 1999
Messages total: 94
Total Questions: 60 (38 pending)
many questions and so few answers.
How SAD! -
Is it possible to make the condition depending on the sql statements in the data models
Hi all
Is it possible to include the condition based on sql statements in the data models.
For example
Is something like this? Also, the good doc is available for ' how to take full advantage of the "data models" in BI Publisher?if (some parameter is not null) <sqlstatement name="STATEMENT_1"> ... </sqlstatement> else <sqlstatement name="STATEMENT_2"> ... </sqlstatement>
Thank you
-SookieHello Sookie,
I couldn't find the time to get a data model of demonstration of work for you, but I'll try to explain.First, write a PL/SQL package. Make sure that you set all the parameters of model of data such as a global variable in the default PL/SQL package.
CREATE OR REPLACE
package as employee
function BeforeReportTrigger return Boolean;
query_text varchar (2000);
number of p_DEPTNO;
END;
/CREATE OR REPLACE
package as body employee
function BeforeReportTrigger return Boolean IS
StartIF (p_DEPTNO = 10) THEN
query_text: = select col1, col2, col3 from HR.
elsif (p_DEPTNO = 20) THEN
query_text: = select col1, col2, col3 hr_history.
on the other
query_text: = select col1, col2, col3 hr_history1.
end if;
Returns true;
end;
/Use this package in the default package in your data model. Check the "defaultPackage ="employee"in the following data model header.
Sample data model
------------------------------
--
--
--
--
Before running the query SQL, data engine reads the "before the release of the report" and all the texte_requete argument based on the p_DeptNo value. When executing the Q1, engine sqlQuery analyze the query ' & quert_text and replace it with the actual value. For example if the p_deptno = 10, the query will be "select col1, col2, col3 from HR.
Try it...
-
Create the view and by using the function that returns a type oracle
Following is possible?
A function returns an ORACLE object Type, and I want to use this feature, in my opinion, it is possible to access each field of the type once the function is executed and make a column in the view?
Now, I want to use the function according to me - if the underlying query of the view follows-create or replace TYPE SOME_INFO AS OBJECT ( CHARGE FLOAT, SOME_DATE DATE, SOME_VAL VARCHAR(50) ); CREATE OR REPLACE FUNCTION CALCULATE_INFO ( p_chargeId NUMBER) RETURN SOME_INFO AS v_some_info SOME_INFO := new SOME_INFO(0, null, null); BEGIN -- function body populates the v_some_info return v_some_info; END calculate_info;
How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val? I can put them as columns in the view?select c.*, calculate_info(c.charge_id) as someInfo from some_charge;
If you use only functions that return a single value in a view?
Thank you
Mustapha
Published by: Tina Giri on April 16, 2009 05:47How to recover someInfo.CHARGE, someInfo.some_date, someInfo.some_val?
SQL> create or replace type some_info as object (charge float, some_date date, some_val varchar (50)); / Type created. SQL> create or replace function calculate_info (p_chargeid number) return some_info as v_some_info some_info := new some_info (0, null, null); begin -- function body populates the v_some_info return v_some_info; end calculate_info; / Function created. SQL> select your_view.someinfo.charge, your_view.someinfo.some_date, your_view.someinfo.some_val from (select c.*, calculate_info (c.empno) as someinfo from emp c) your_view where rownum <= 3 SOMEINFO.CHARGE SOMEINFO SOMEINFO.SOME_VAL --------------- -------- -------------------------------------------------- 0 0 0 3 rows selected.
-
REP-0737: must be a function of return type 'ref cursor.
Hi all
I have create a ref cursor query in reports 10 g. But it is giving error REP-0737: must be a function of return type 'ref cursor.
Here is my code
function QR_1RefCurDS return sys_refcursor is My_Cur Sys_Refcursor; begin Open My_Cur for select * from scott.emp order by deptno; return My_Cur end;
fate of the screen.
Oracle Forms/Reports has a complete PL/SQL engine and (only) the SQL parser.
However, the engine of forms/States PL / SQL and SQL Analyzer are at a level that was in the Oracle 8.0 database.
So, in the forms/States functions/procedures and forms/States triggers, you can not use SQL commands that did not exist in the 8.0 database.
The predefined SYS_REFCURSOR type is introduced in Oracle 9i.
Use this:
PACKAGE test_rc IS
TYPE of rc_type IS REF CURSOR RETURN emp % ROWTYPE;
END;
FUNCTION RETURN QR_1RefCurDS Test_rc.rc_type IS
test_rc.rc_type RC;
BEGIN
OPEN the RC to SELECT * FROM emp;
RETURN rc;
END;
Kind regards
Zlatko
-
Create the object type with a member function that returns an array of the object type
Hello
Is possible to compile code like this in Oracle SQL?
CREATE OR REPLACE TYPE type_obj IS OBJECT ( MEMBER FUNCTION f RETURN table_obj ); CREATE OR REPLACE TYPE table_obj AS TABLE OF type_obj;
In Java, it would be possible.
Thanks in advance
Circular dependencies must be resolved by means of REF pointers and incomplete type definition.
See: Oracle objects management
CREATE or REPLACE TYPE type_obj;
/
CREATE or REPLACE TYPE table_obj AS TABLE OF ref type_obj;
/
CREATE or REPLACE TYPE type_obj () IS OBJECT
fake number
Table_obj RETURN of the FUNCTION MEMBER f
);
/
Now, it must implement the body of type.
Note that a table of the REFs is not very useful in the plain of PL/SQL, the underlying data must be stored in a nested table if you want to use.
-
Calling a function multiple return values...
Hello
I wrote a simple function 2 return values. It comes to my own understanding.
create or replace function func1 (empid number)
Return number
is
number of SAL;
number of deptID;
Start
Select the wage in sal of employees where employee_id = empid;
Select department_id from deptid from employees where employee_id = empid;
return of sal;
deptid return;
end;
I tried to call the function like below: -.
declare
number of performance(1);
Result2 number;
Start
performance(1): = func1 (101);
Result2: = func2 (101);
dbms_output.put_line(result ||) '' || Result2);
end;
output:-1700 1700
the salary was posted twice.
I understand that the second query has not been taken into account.
Please let me know how this can be achieved.
Thanks and greetings
Here is an example of functions Oracle return multiple values - dBforums:
CREATE or REPLACE TYPE pmc_tab AS TABLE OF NUMBER;
CREATE TABLE v_stats_daily (start_date date, number of Field1, Field2 number, field3 number);
INSERT INTO v_stats_daily VALUES('08-OCT-2003',10,20,30);
INSERT INTO v_stats_daily VALUES('08-OCT-2003',40,50,60);
INSERT INTO v_stats_daily VALUES('08-OCT-2003',70,80,90);
CREATE OR REPLACE FUNCTION PMC_STATS
(pStatDate Date) IS BACK pmc_tab
MyArray pmc_tab;
NUMBER of vstat1;
NUMBER of vstat2;
NUMBER of vstat3;
BEGIN
MyArray: = pmc_tab();
SELECT sum (Field1), sum (field2), sum (field3)
IN vstat1, vstat2, vstat3
OF v_stats_daily
WHERE the arguments start_date = pStatDate;
MyArray.EXTEND;
MyArray (1): = vstat1;
MyArray.EXTEND;
MyArray (2): = vstat2;
MyArray.EXTEND;
MyArray (3): = vstat3;
RETURN MyArray;
END;
/
Set serveroutput ON
DECLARE
MyDate DATE;
MyArray pmc_tab;
I have SEVERAL;
numOut NUMBER;
BEGIN
MyArray: = pmc_stats('08-OCT-2003');
dbms_output.put_line (' number of Table: ' | to_char (myArray.Count));
FOR i IN 1.MyArray.last LOOP
numOut: = MyArray (i);
-If numOut is null then
dbms_output.put_line (' value: ' | to_char (numOut));
-end if;
END LOOP;
END;
/
/
Table number: 3
Value: 120
Value: 150
Value: 180
PL/SQL procedure successfully completed.
/
Post edited by: Elya
-
Using the function PLSQL return Record Type Index of Tables in ADF
I have a PLSQL function, a return type. My ultimate goal is to take this binary integer index Table and print it on the screen...
CREATE OR REPLACE PACKAGE my_pkg IS
TYPE t_col IS RECORD(
i NUMBER,
n VARCHAR2(30));
TYPE t_nested_table IS TABLE OF t_col;
FUNCTION return_table RETURN t_nested_table ;
END my_pkg;OPTION 1:
1) has anyone got best practices to accept plsql RECORDS returned by a function?
Here is an example.
http://adfpractice-Fedor.blogspot.SG/2013/01/working-with-PLSQL-procedures-in-ADF-BC.html
But it will be a lot of work... first of all accept the results in a loop... then store in a temporary storage can be a few VO or global temporary table and then display them on the page
OPTION 2:
Using the functions PIPLELINED and use in the select statement. While I can use this select statement in the SQL query to create VO... and drag and drop the VO...
CREATE OR REPLACE PACKAGE my_pkg IS
TYPE t_col IS RECORD(
i NUMBER,
n VARCHAR2(30));
TYPE t_nested_table IS TABLE OF t_col;
FUNCTION return_table RETURN t_nested_table PIPELINED;
END my_pkg;select * from table(my_pkg.return_table);
Wow... I'm so smart! .. really possible? who is the best/possible/recommended option?
I'm sure that will be the question most read by many who wants to use PLSQL instead of JAVA to the treatment and CHOSEN to use only to display the output of the PLSQL functions or procedures.
Thank you
Rahul
Dario
Do you mean the scope of the defined Type pkg will be finished?
I created guy outside the pkg as 'Create Type' if it works in this case?
Yes, level objects schema (created with "create or replace type...") can be used in java and this can work.
I think that then the scope of this TYPE will remain until the user session passes.
Object definitions is not worn, but have their bodies.
So, if you instantiate the data level object type schema in a plsql function, scope of this object is this function.
Of course, if you instantiate the object as a variable package, then life of this object is equal to the lifetime of the package (which usually equals life of session db).
Dario
-
function not returning object table properly
Rather than return a table, my function returns this:
SCHEMA_OWNER. TBL_SUMS ([SCHEMA_OWNER. SUMS_OBJ])
Did anyone see a syntax error in my function or the DOF of my table and object types?
It is a stripped down, simplified version of my function:
create or replace FUNCTION "F_TEST" (number of p_skey, p_start_date date, p_end_date date)
RETURN tbl_sums
IS
tmp_A NUMBER;
tmp_B NUMBER;
l_tbl tbl_sums: = tbl_sums();
BEGIN
SELECT SUM (FieldA), SUM (FieldB)
in tmpA, tmpB
FROM MaTable where SKEY = p_skey
and DATE_VALUE > = p_start_date
and DATE_VALUE < p_end_date;.
l_tbl.extend;
l_tbl (l_tbl. (Count()): = sums_obj (p_start_date, p_end_date, p_skey, tmpA, tmpB);
Return l_tbl;
END;
My models are:
create or replace type sums_obj is object (DATE start_date, end_date DATE, skey NUMBER, SumA, SumB NUMBER);
create or replace type tbl_sums is table of the sums_obj;
Thank you!>
RETURN tbl_kpi
>
What is 'tbl_kpi '? Which is not defined anywhere. Your original post said:
>
RETURN tbl_sums
>
We cannot help you if you don't publish what you actually use. Cut & paste is ok, but you have to paste the correct code.Your function returns a TABLE, but it is NOT in the PIPELINE. For example, if you query the DOUBLE function you will get a DATASET as a result.
If you query the function AS A TABLE, you will get the "content" of the table.
If you make your function a PIPELINED function then you use PIPE ROW to return each line but the function is always declared to return a TABLE. This is perhaps what is confusing you.
Try the following code to see what the difference is.
Here are two SQL types based on the EMP table in the scott schema.
-- type to match emp record create or replace type emp_scalar_type as object (EMPNO NUMBER(4) , ENAME VARCHAR2(10), JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE, SAL NUMBER(7, 2), COMM NUMBER(7, 2), DEPTNO NUMBER(2) ) / -- table of emp records create or replace type emp_table_type as table of emp_scalar_type /
Now - here's a function (similar to yours) that returns him EMP_TABLE_TYPE. NOTE: the function IS NOT PIPELINED
CREATE OR REPLACE function SCOTT.get_emp1( p_deptno in number ) return emp_table_type as tb emp_table_type; BEGIN select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno) bulk collect into tb from emp where deptno = p_deptno; return tb; end; /
If I simply select the function itself twice I get this:
select get_emp1(20) from dual GET_EMP1(20) (DATASET)
I can use TOAD or sql developer to examine this dataset and see the documents.
But I can actually query the records by using the TABLE function:
select * from table(get_emp1(20)) EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 SMITH CLERK 7902 12/17/1980 800 20 7566 JONES MANAGER 7839 4/2/1981 2975 20 7788 SCOTT ANALYST 7566 4/19/1987 3000 20 7876 ADAMS CLERK 7788 5/23/1987 1100 20 7902 FORD ANALYST 7566 12/3/1981 3000 20
This is a similar function. It returns the same EMP_TABLE_TYPE, but it is a PIPELINED function.
-- pipelined function create or replace function get_emp( p_deptno in number ) return emp_table_type PIPELINED as TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE; emp_cv EmpCurTyp; l_rec emp%rowtype; begin open emp_cv for select * from emp where deptno = p_deptno; loop fetch emp_cv into l_rec; exit when (emp_cv%notfound); pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename), l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) ); end loop; return; end; /
The ONLY way I can query this function is using the TABLE function:
select * from table(get_emp(20)) EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO 7369 smith CLERK 7902 12/17/1980 800 20 7566 jones MANAGER 7839 4/2/1981 2975 20 7788 scott ANALYST 7566 4/19/1987 3000 20 7876 adams CLERK 7788 5/23/1987 1100 20 7902 ford ANALYST 7566 12/3/1981 3000 20
The query of the PIPELINED function is the same and the result set is the same.
The difference is that the PIPELINED function returns ONE LINE at a time and does NOT need to accumulate a large amount of data in a collection before returning. This collection uses the memory of expensive PGA and the more data you have the more memory it uses.
Your function (and my only similar) return NO data until it has produced ALL of this. And he uses this expensive PGA memory. What is the point to create your collection at a time line and wait until you have everything before send it back you?
You can easily modify your function and add PIPELINED to the declaration. Then, use the PIPE ROW clause to return each row that it is produced. Which will eliminate the need of collecting (and memory) within the service.
You can also then follow up calls to function if you need to.
See 'Use of functions Table in pipeline and parallel' in the data cartridge Developer Guide
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28425/pipe_paral_tbl.htmThere is little use for your function that is not in the pipeline, but returns a type of table, unless you used to store the array type in a column of an object table.
There are many uses for PIPELINED functions.
-
a function that returns the type with a table joint!
Good day to all,
I have a function that returns a type.
so I select it as:
Select * from table (function (param1, param2))
now I want to combine this with a table so that the settings for the service we get from the join table. Is this possible? And how?
I tried different options without success.
something like:
Select *.
table table (function (b.column1, b.columnb) x), tablea b
where x.a = b.col
Is this possible?
Thanks in advance?user564819 wrote:
something like:
Select *.
table table (function (b.column1, b.columnb) x), tablea b
where x.a = b.colIs this possible?
Somehow...
SQL> create or replace type TIntegers is table of integer; 2 / Type created. SQL> SQL> --// our sample pipeline simply spews 2 numbers for eevry number input - simple SQL> --// to use for the testcase below SQL> create or replace function FooPipe( n number ) return TIntegers pipelined is 2 begin 3 pipe row( trunc(n) ); 4 pipe row( trunc(n)*-1 ); 5 return; 6 end; 7 / Function created. SQL> SQL> with dataset( n ) as( 2 --// ignore this part as it only builts a base table 3 --// for us to use to select values for input to 4 --// to the pipeline - in "real world" use this table 5 --// will already exist 6 select 7 level 8 from dual 9 connect by level <= 10 10 ), 11 pipe_line( n, array ) as( 12 --// we run the pipeline as a nested table column 13 --// in the SQL projection - the CAST is important 14 --// in order to establish the nested table type 15 select 16 d.n, 17 cast( 18 FooPipe(d.n) as TIntegers 19 ) 20 from dataset d 21 ) 22 --// we now use a standard query to unnest the nested table column 23 select 24 p.n, 25 pipe_val.* 26 from pipe_line p, TABLE(p.array) pipe_val 27 / N COLUMN_VALUE ---------- ------------ 1 1 1 -1 2 2 2 -2 3 3 3 -3 4 4 4 -4 5 5 5 -5 6 6 6 -6 7 7 7 -7 8 8 8 -8 9 9 9 -9 10 10 10 -10 20 rows selected. SQL>
Not sure I like it. What is the real problem that this method (driving a pipeline with input of a base table rows) is supposed to address? There may be a simpler and more elegant approach...
-
table font PL/SQL: ORA-00902: invalid data type
I m is
PL/SQL: ORA-00902: invalid data type
error in
OPEN FOR PPymtCur
SELECT *.
TABLE (CAST (up_gap_tra_reports.myArray AS traArray));
in my up_gap_tra_reports package.
CREATE OR REPLACE PACKAGE GAPSDVEL.up_gap_tra_reports
AS
TraRecord RECORD TYPE IS
(
group1StudEnrol NUMBER (6.1).
group2StudEnrol NUMBER (6.1).
pymtAmt gap_payment.NET_AMT%TYPE
);
TYPE traArray IS TABLE OF THE traRecord;
myArray traArray: = traArray();
END up_gap_tra_reports;
I have alreay hv declared of type traArray.
pls help me solve this problem.Meghna wrote:
is it possible to use the collection pl/sql in SQL or refcur without creating it because I'm not able to create the type of database.The only way I know is function in pipeline:
create or replace package pkg1 is type traRecord is record( ename emp.ename%type, sal emp.sal%type ); TYPE traArray IS TABLE OF traRecord; function f1 return traArray pipelined; end; / create or replace package body pkg1 is function f1 return traArray pipelined is v_rec traRecord; begin v_rec.ename := 'Sam'; v_rec.sal := 1000; pipe row(v_rec); v_rec.ename := 'John'; v_rec.sal := 1500; pipe row(v_rec); v_rec.ename := 'Mary'; v_rec.sal := 2000; pipe row(v_rec); return; end; end; /
Now, you can:
SQL> select * from table(pkg1.f1) 2 / ENAME SAL ---------- ---------- Sam 1000 John 1500 Mary 2000 SQL>
Don't forget, it will create the generated system types:
SQL> select type_name from user_types 2 / TYPE_NAME ------------------------------ SYS_PLSQL_73305_9_1 SYS_PLSQL_73305_DUMMY_1 SYS_PLSQL_73305_34_1 SQL> desc SYS_PLSQL_73305_9_1 Name Null? Type ----------------------------------------- -------- ---------------------------- ENAME VARCHAR2(10) SAL NUMBER(7,2) SQL> desc SYS_PLSQL_73305_DUMMY_1 SYS_PLSQL_73305_DUMMY_1 TABLE OF NUMBER SQL> desc SYS_PLSQL_73305_34_1 SYS_PLSQL_73305_34_1 TABLE OF SYS_PLSQL_73305_9_1 Name Null? Type ----------------------------------------- -------- ---------------------------- ENAME VARCHAR2(10) SAL NUMBER(7,2) SQL>
SY.
Maybe you are looking for
-
Hey everybody, I have a particular problem regarding the logging of data after a certain trigger condition has been met. My task is to save some data based on a particular trigger condition, data to be connected must be previous data (e.g. 1 sec prio
-
The 32-bit drivers will work on 64-bit so dual boot to 32 bit?
Hello I use my laptop for recording audio. It came standard with Windows Vista 64-bit. I recently got a piece of hardware (a mixing table) has currently no 64-bit drivers. I was wondering if I put my computer to dual boot saying Windows Xp 32 bit if
-
How to center an image in a Web page?
Hello I want to center an image which is the menu on the Web site. The site was designed by a developer, and I'm trying to center the image of myself. The site has lots of CSS files and also if someone could explain to me how I could integrate the HT
-
Maximum size of hard drive DC5700
Hello I currently intend to spend with a new hard drive in my computer format microtour DC5700 now quite old. Unfortunately I have no idea if there is a limit on the size of the hard drive can be. How will I know if my computer can handle a 2 TB HDD?
-
How to export to PDF with crop marks * and * an image high resolution?
HI - firstly, apologies - I have another query here and this is a related issue. Because I have been unable to solve this problem, which is with InDesign CS5, I downloaded the demo of InDesign CC, as I work at a date limit.OK, so I'm used to be able