PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
HelloHaving a little trouble with the following code example provided to http://www.dba-oracle.com/plsql/t_plsql_cursor_variables.htm:
1 DECLARE
2 TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
3 c_cursor t_ref_cursor;
4 l_row NUMBER;
5 BEGIN
6 DBMS_OUTPUT.put_line('Strongly typed REF CURSOR using SCALAR type. Expect an error!');
7 OPEN c_cursor FOR
8 SELECT COUNT(*) cnt
9 FROM cursor_variable_test;
10 LOOP
11 FETCH c_cursor
12 INTO l_row;
13 EXIT WHEN c_cursor%NOTFOUND;
14 DBMS_OUTPUT.put_line(l_row);
15 END LOOP;
16 CLOSE c_cursor;
17* END;
18 /
TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
*
ERROR at line 2:
ORA-06550: line 2, column 24:
PLS-00362: invalid cursor return type; 'NUMBER' must be a record type
ORA-06550: line 2, column 3:
PL/SQL: Item ignored
In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.Why can't return a value in a column of a row in a NUMBER?
How can I change the SQL code so that I can do this?
Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
Thank you very much
Jason
>
TYPE t_ref_cursor IS REF CURSOR RETURN NUMBER;
*
ERROR on line 2:
ORA-06550: line 2, column 24:
PLS-00362: Invalid cursor return type; 'NUMBER' must be a record type
ORA-06550: line 2, column 3:
PL/SQL: Ignored Element
In the code above, SELECT COUNT (*)... returns a NUMBER. I know it's an aggregation function, but it returns a single value.
Why can't return a value in a column of a row in a NUMBER?
How can I change the SQL code so that I can do this?
>
The exception is in line 2: your cursor statement. And the answer is in the text that you access
>
The return value of a strongly typed REF CURSOR must be a folder that can be defined using % TYPE % ROWTYPE attributes or record structure.
>
You said the CURSOR to return a NUMBER. And as the text says, he must be a 'record '.
>
Furthermore, I wonder about the use of FETCH with a count (*)... FETCH is supposed to fetch the next row... How it works when you select an aggregate as County?
>
As you said already FETCH retrieves the next line, if any. A query is a request is a request. It returns a result set. A query that uses aggregates returns a result set. A query that does not aggregate returns a result set.
Your simple COUNT (*) SELECT query returns a result set that consists of a LINE and a line a ONE COLUMN of type NUMBER. Although there is only one column in the result set, what is returned is a RECORD or a LINE. That's why you have to report your data cursor return type a document using the % ROWTYPE or % TYPE attributes or a record structure.
Tags: Database
Similar Questions
-
PLS-00630: pipeline functions must have a collection of supported return type
Hello, I created a TYPE of OBJECT and function PLSQL as shown below, but the function compile errors with that follows. Don't know where is the problem?
It's about Oracle 10 g r2PLS-00630: pipelined functions must have a supported collection return type
and here are the APICREATE OR REPLACE TYPE cxs_plsql_profiler_object_type AS OBJECT ( cxs_object_name VARCHAR2 (128), cxs_object_type VARCHAR2 (19), cxs_object_status VARCHAR2 (7), cxs_read_execution NUMBER, cxs_buffer_gets NUMBER, cxs_disk_reads NUMBER, cxs_executions NUMBER, cxs_sorts NUMBER, cxs_sharable_mem NUMBER, cxs_address NUMBER, cxs_hashvalue NUMBER, cxs_osuser VARCHAR2 (30), cxs_username VARCHAR2 (30), cxs_module VARCHAR2 (48), cxs_machine VARCHAR2 (64), cxs_status VARCHAR2 (8), cxs_terminal VARCHAR2 (16), cxs_percentconsume NUMBER, cxs_percentrepeat NUMBER, cxs_plan VARCHAR2 (120), target_name VARCHAR2 (200), referenced_name VARCHAR2 (200), referenced_type VARCHAR2 (200), targetowner VARCHAR2 (200), refowner VARCHAR2 (200) )
and here's tradtional types of tables that are used in the code above.FUNCTION CXS_GENERATE_PLSQL_PROFILER RETURN cxs_plsql_profiler_object_type PIPELINED IS out_rec cxs_plsql_profiler_object_type ; plsbatch plsql_batch; skount integer; dpendrec depend_tab; dkount integer; CURSOR objects IS SELECT object_name, object_type FROM dba_objects WHERE status = 'VALID' AND owner NOT IN ('SYS', 'SYSTEM') AND object_type IN ('PACKAGE', 'PROCEDURE', 'FUNCTION'); CURSOR apis (p_object dba_objects.object_name%TYPE) IS SELECT DISTINCT * FROM (SELECT SUBSTR (a.sql_text, 1, 50) sql_text, TRUNC ( a.disk_reads / DECODE (a.executions, 0, 1, a.executions ) ) reads_per_execution, a.buffer_gets, a.disk_reads, a.executions, a.sorts, a.sharable_mem, a.address, a.hash_value, b.osuser, b.username, b.module, b.machine, b.status, b.terminal, ROUND (cxs_db_info.kompute_percentofsql (a.sharable_mem), 5 ) percentkonsume, cxs_db_info.kount_repeat (b.osuser, b.terminal ) percentr, c.operation explainplan FROM v$sqlarea a, v$session b, v$sql_plan c WHERE b.sql_hash_value = a.hash_value AND b.sql_address = a.address AND a.hash_value = c.hash_value AND a.address = c.address AND b.status = 'ACTIVE' AND UPPER (a.sql_text) LIKE '%' || p_object || '%' AND c.ID = 0 ORDER BY 2 DESC) WHERE ROWNUM <= 50; --profile option BEGIN skount := 0; dkount := 0; FOR i IN objects LOOP FOR j IN apis (i.object_name) LOOP skount := skount + 1; plsbatch(skount).cxs_object_name := i.object_name; plsbatch(skount).cxs_object_type := i.object_type; plsbatch(skount).cxs_object_status := i.object_status; plsbatch(skount).cxs_read_execution := j.reads_per_execution; plsbatch(skount).cxs_buffer_gets := j.buffer_gets; plsbatch(skount).cxs_disk_reads := j.disk_reads; plsbatch(skount).cxs_executions := j.executions; plsbatch(skount).cxs_sorts := j.sorts; plsbatch(skount).cxs_sharable_mem := j.sharable_mem; plsbatch(skount).cxs_address := j.address; plsbatch(skount).cxs_hashvalue := j.hashvalue; plsbatch(skount).cxs_osuser := j.osuser; plsbatch(skount).cxs_username := j.username; plsbatch(skount).cxs_module := j.module; plsbatch(skount).cxs_machine := j.machine; plsbatch(skount).cxs_status := j.status; plsbatch(skount).cxs_terminal := j.terminal; plsbatch(skount).cxs_percentconsume := j.percentconsume; plsbatch(skount).cxs_percentrepeat := j.percentrepeat; plsbatch(skount).cxs_plan := j.explainplan; END LOOP; FOR dd IN dpend (i.object_name) LOOP dkount := dkount + 1; dependrec (dkount).target_name := dd.NAME; dependrec (dkount).refname := dd.referenced_name; dependrec (dkount).reftype := dd.referenced_type; dependrec (dkount).target_owner := dd.owner; dependrec (dkount).refowner := dd.referenced_owner; END LOOP; END LOOP; for a in 1..skount loop out_rec.cxs_object_type := plsbatch(a).object_type; out_rec.cxs_object_status := plsbatch(a).object_status; out_rec.cxs_read_execution := plsbatch(a).reads_per_execution; out_rec.cxs_buffer_gets := plsbatch(a).buffer_gets; out_rec.cxs_disk_reads := plsbatch(a).disk_reads; out_rec.cxs_executions := plsbatch(a).executions; out_rec.cxs_sorts := plsbatch(a).sorts; out_rec.cxs_sharable_mem := plsbatch(a).sharable_mem; out_rec.cxs_address := plsbatch(a).address; out_rec.cxs_hashvalue := plsbatch(a).hashvalue; out_rec.cxs_osuser := plsbatch(a).osuser; out_rec.cxs_username := plsbatch(a).username; out_rec.cxs_module := plsbatch(a).module; out_rec.cxs_machine := plsbatch(a).machine; out_rec.cxs_status := plsbatch(a).status; out_rec.cxs_terminal := plsbatch(a).terminal; out_rec.cxs_percentconsume := plsbatch(a).percentconsume; out_rec.cxs_percentrepeat := plsbatch(a).percentrepeat; out_rec.cxs_plan := plsbatch(a).explainplan; PIPE ROW(out_rec); end loop; for b in 1..dkount loop out_rec.target_name := dd.NAME; out_rec.refname := dependrec (b).referenced_name; out_rec.reftype := dependrec (b).referenced_type; out_rec.target_owner := dependrec (b).owner; out_rec.refowner := dependrec (b).referenced_owner; PIPE ROW(out_rec); end loop; RETURN; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.format_error_backtrace); DBMS_OUTPUT.PUT_LINE(SQLCODE); DBMS_OUTPUT.PUT_LINE(SQLERRM); END;
Thank you for your time in reading this postTYPE type_plsql_rec IS RECORD ( cxs_object_name VARCHAR2 (128), cxs_object_type VARCHAR2 (19), cxs_object_status VARCHAR2 (7), cxs_read_execution NUMBER, cxs_buffer_gets NUMBER, cxs_disk_reads NUMBER, cxs_executions NUMBER, cxs_sorts NUMBER, cxs_sharable_mem NUMBER, cxs_address NUMBER, cxs_hashvalue NUMBER, cxs_osuser VARCHAR2 (30), cxs_username VARCHAR2 (30), cxs_module VARCHAR2 (48), cxs_machine VARCHAR2 (64), cxs_status VARCHAR2 (8), cxs_terminal VARCHAR2 (16), cxs_percentconsume NUMBER, cxs_percentrepeat NUMBER, cxs_plan VARCHAR2 (120) ); TYPE plsql_batch IS TABLE OF type_plsql_rec INDEX BY BINARY_INTEGER; TYPE type_depend_tab IS RECORD ( target_name dba_dependencies.NAME%TYPE, refname dba_dependencies.referenced_name%TYPE, reftype dba_dependencies.referenced_type%TYPE, target_owner dba_dependencies.owner%TYPE, refowner dba_dependencies.referenced_owner%TYPE ); TYPE depend_tab IS TABLE OF type_depend_tab INDEX BY BINARY_INTEGER;
RJohan says:
Sorry!.
Actually, I meant
I thought as well.
Typos can be expensive however. As a probe of NASA Mars in 99, which was lost due to a simple mathematical error - a confusion between English and metric units. ;-)
Or screw up a server in reason to use a Unix fork() where the client process think that it is the parent and the beginning more children who believe they are also parents of spawning... (one of my mistakes of kewlest never) :-)
-
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
-
How to read my ref cursor return user defined cursor type
Hello
I have the types defined as follows:
It is used as a return type in a stored procedure.TYPE MY_RECORD IS RECORD ( COL1 TABLE1.COL1%TYPE, COL2 TABLE1.COL2%TYPE ); TYPE MY_CURSOR IS REF CURSOR RETURN MY_RECORD;
I have a pl/sql block, where I make a call to MS that returns this cursor.
How to read individual values for SP?SQL> create or replace package pkg as type my_record is record (col1 emp.empno%type, col2 emp.ename%type); type my_cursor is ref cursor return my_record; procedure p (cur out my_cursor); end pkg; / Package created. SQL> create or replace package body pkg as procedure p (cur out my_cursor) as begin open cur for select empno, ename from emp where rownum <= 2; end p; end pkg; / Package body created. SQL> declare cur pkg.my_cursor; e_rec pkg.my_record; begin pkg.p (cur); loop fetch cur into e_rec; exit when cur%notfound; dbms_output.put ('Empno: ' || e_rec.col1); dbms_output.put_line ('; Ename: ' || e_rec.col2); end loop; close cur; end; / Empno: 7369; Ename: SMITH Empno: 7499; Ename: ALLEN PL/SQL procedure successfully completed.
-
Hi all
What is the problem in this function?
SQL > create or replace function Emp_Search (number v_empno)
2 return a Boolean value
3 is
4 cursor c_emp is Empno select from Emp;
5. start
6 for emp_r looping c_emp
7 if v_empno = emp_r.empno then
8 dbms_output. Put_line (v_empno |) 'lies');
9 return true;
10 end if;
11 end of loop;
12 end c_emp;
13 dbms_output. Put_line (v_empno |) ("' is not found");
14 return false;
End 15 Emp_Search;
16.
WARNING: Function created with compilation errors.
SQL > show error
Errors for the EMP_SEARCH FUNCTION:
LINE/COL ERROR
-------- -----------------------------------------------------------------
12/7 PLS-00113: identifier 'C_EMP' of the END must match 'EMP_SEARCH' on line
1, column 10
13/2 PLS-00103: encountered the symbol "DBMS_OUTPUT.
13/49 PLS-00103: encountered the symbol ";" when expecting one of the
Next:
. (, * % & -+ / at rem rest mod < an ID >)
< between double quote delimited identifiers of > < an exhibitor > (*) as
go to | bulk of type multiset
I hope it's just exploring things...
FUNCTION to CREATE or REPLACE emp_search (in_empno IN emp.empno%TYPE)
RETURN NUMBER
IS
CURSOR c_emp (cp_empno IN emp.empno%TYPE)
IS COUNT (*) SELECT
WCP
WHERE empno = cp_empno;
l_row_cntr PLS_INTEGER;
BEGIN
OPEN c_emp (cp_empno-online in_empno).
extraction INTO l_row_cntr c_emp;
close c_emp;
IF l_row_cntr > 0
THEN
SYS. Dbms_output.put_line (in_empno |) "lies");
ON THE OTHER
SYS. Dbms_output.put_line (in_empno |) 'is not found");
end if;RETURN l_row_cntr;
END emp_search;
/HTH
-
Binding type variable of function return type?
Hi, is it possible to bind a type variable to a function return type, so that changes in type of variable according to the function return type definition?
Something like what is happening with TYPE and % ROWTYPE.
Thank youVeverke wrote:
Hi, is it possible to bind a type variable to a function return type, so that changes in type of variable according to the function return type definition?Well, not directly. However, if the function returns SQL declared of type you could:
1. create a dummy cursor that selects the function of double
2. create a dummy record variable dummy cursor %
3. create your variable or dummy record attribute type:SQL> desc f1 FUNCTION f1 RETURNS VARCHAR2 Argument Name Type In/Out Default? ------------------------------ ----------------------- ------ -------- P_NUM NUMBER IN SQL> declare 2 desired_variable f1%type; 3 begin 4 desired_variable := 1; 5 end; 6 / desired_variable f1%type; * ERROR at line 2: ORA-06550: line 2, column 22: PLS-00206: %TYPE must be applied to a variable, column, field or attribute, not to "F1" ORA-06550: line 2, column 22: PL/SQL: Item ignored ORA-06550: line 4, column 5: PLS-00320: the declaration of the type of this expression is incomplete or malformed ORA-06550: line 4, column 5: PL/SQL: Statement ignored SQL> declare 2 cursor dummy_cursor is select f1(1) f1 from dual; 3 dummy_record dummy_cursor%rowtype; 4 desired_variable dummy_record.f1%type; 5 begin 6 desired_variable := 1; 7 end; 8 / PL/SQL procedure successfully completed. SQL>
SY.
-
Invalid cursor within the service in pipeline
The simple example following illustrates a mistake that I am experiencing with development code more complex.
I try to reuse a complex procedure that I do not have duplication of code and business logic.
It runs correctly.
exec PKG_TEST.complex_proc(:p_cursor);
This property returns an error:
exec PKG_TEST.select_rows(:p_cursor);
The error is ORA-01001: Invalid cursor.
I checked and the cursor is opened and % notfound is false.
Any ideas?
Thank you in advance for your help!
create the table employees
(
primary key ID number,
name varchar2 (100)
);
insert into employee values (1, 'Joe');
insert into employee values (2, 'Bob');
insert into employee values (3, 'Peter');
create table contractor
(
primary key ID number,
name varchar2 (100)
);
insert into a values (4, 'Henry') contractor;
insert into contractor values (5, 'William');
create or replace package PKG_TEST
is
type t_rec is rendered
(
Identification number,
name varchar (100)
);
type t_tab is table of the t_rec;
procedure complex_proc (p_cursor to sys_refcursor);
function select_fn (p_cursor sys_refcursor)
return PKG_TEST.t_tab in pipeline;
select_rows (p_cursor to sys_refcursor) procedure;
end pkg_test;
create or replace package PKG_TEST body
is
procedure complex_proc (out p_cursor sys_refcursor)
is
Start
Open the p_cursor for
Select *.
the employee;
end complex_proc;
function select_fn (p_cursor sys_refcursor)
return PKG_TEST.t_tab pipeline
is
v_tab PKG_TEST.t_tab;
v_rec PKG_TEST.t_rec;
Start
loop
collect the fetch p_cursor in bulk in the v_tab limit 100;
because me in 1... v_tab. Count
loop
v_rec: = v_tab (i);
pipe row (v_rec);
end loop;
When the output p_cursor % NOTFOUND;
end loop;
return;
end select_fn;
select_rows (exit p_cursor sys_refcursor) procedure
is
v_cursor sys_refcursor;
Start
PKG_TEST.complex_proc (v_cursor);
Open the p_cursor for
Select *.
table (PKG_TEST.select_fn (v_cursor))
Union of all the
Select *.
contractor;
select_rows end;
end pkg_test;
Problem is that your variable v_cursor in SELECT_ROWS is out of scope when the procedure ends.
So the ref cursor returned by this method cannot be referenced it more.
If you are on 11g and beyond, a workaround is to declare v_cursor DBMS_SQL cursor (for example an INTEGER data type) and use DBMS_SQL.to_cursor_number / DBMS_SQL.to_refcursor to convert between the two.
In this way, the query pointed to by the final Ref cursor will always have a valid binding variable when the procedure ends.
function select_fn( p_cursor in integer ) return PKG_TEST.t_tab pipelined is v_tab PKG_TEST.t_tab; v_rec PKG_TEST.t_rec; v_cursor_num integer := p_cursor; v_cursor sys_refcursor := dbms_sql.to_refcursor(v_cursor_num); begin loop fetch v_cursor bulk collect into v_tab limit 100; --exit when p_cursor%NOTFOUND; exit when v_tab.count = 0; for i in 1 .. v_tab.count loop v_rec := v_tab(i); pipe row(v_rec); end loop; end loop; close v_cursor; return; end select_fn;
procedure select_rows ( p_cursor out sys_refcursor ) is v_cursor sys_refcursor; v_cursor2 integer; begin PKG_TEST.complex_proc(v_cursor); v_cursor2 := dbms_sql.to_cursor_number(v_cursor); open p_cursor for select * from TABLE(PKG_TEST.select_fn(v_cursor2)) union all select * from contractor; end select_rows;
-
Hello
I read conflicting information about the return type that has a table function must or may use.
First, I am a student of a book that says:
Function in pipeline returns the data types:
The main constraint for the pipeline functions, it is the return type must be a collection type autonomous which can be used in SQL - i.e. a VARRAY or table nested.
and then in the next sentence...
More precisely a pipeline function can return the following:
A stand-alone nested table or VARRAY, defined at the schema level.
A nested table or VARRAY that has been declared in a package type.
This seems to go against the first quoted sentence.
Now, before reading the above text I had done just my own test to see if a packed type would work because I thought I had read somewhere that it would not, and he does not (the test code and this output is at the end of this question). When I arrived in the text above, after my test, so I was naturally confused.
So, I'm going to PL/SQL reference that says:
RETURN data type
The data type of the value returned by a function table in pipeline must be a type collection defined either at the level of schema or within a package (therefore, it cannot be a type of associative array).
I tried to call a function that returns a collection of VARRAY type packaged in both SQL and PL/SQL (of course below is SQL all in any case) and no work.
Now I'm wondering what is a TABLE function must use a schema type and a function table in pipeline can use a packaged type? I see that I created and called a function table but examples of Oracle see the creation and use of a function table in pipeline.
Edit: I should add that I read the following sentence in the SF book on p609 in * table functions: "this type of nested table must be defined as an element of level diagram, because the SQL engine must be able to resolve a reference to a collection of this kind."
So that it begins to resemble table functions should return a schema type and pipelined table functions, perhaps because that they don't in fact return a collection, rather they return (RowSource) content, can use the schema types or types of packages. Is this correct?
Can someone clarify this for me please?
Thank you in advance,
J
CREATE OR REPLACE PACKAGE PKGP28M
VAT-type is varray (5) number;
END;
/
DISPLAY ERRORS
create or replace type VAT is varray (5) number;
/
display errors
create or replace function tabfunc1 return pkgp28m.vat as
numtab pkgp28m.vat:=pkgp28m.vat();
Start
numtab.extend (5);
because loop me in 1.5
numtab (i): = trunc (dbms_random. Value (1.5));
end loop;
Return numtab;
end;
/
display errors
create or replace function tabfunc2 as return VAT
numtab vat:=vat().
Start
numtab.extend (5);
because loop me in 1.5
numtab (i): = trunc (dbms_random. Value (1.5));
end loop;
Return numtab;
end;
/
display errors
exec dbms_output.put_line (' call tabfunc1 (returns the packaged type) :');)
Select * from table (tabfunc1)
/
exec dbms_output.put_line (' call tabfunc2 (returns the type of schema) :');)
Select * from table (tabfunc2)
/
declare
RC sys_refcursor;
number of v;
Start
dbms_output.put_line (' in anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type) :');)
Open rc to select table column_value (tabfunc1);
loop
extract the rc in v;
When the output rc % notfound;
dbms_output.put_line (' > ' | to_char (v));
end loop;
close the rc;
end;
/
declare
RC sys_refcursor;
number of v;
Start
dbms_output.put_line (' in anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema) :');)
Open rc to select table column_value (tabfunc2);
loop
extract the rc in v;
When the output rc % notfound;
dbms_output.put_line (' > ' | to_char (v));
end loop;
close the rc;
end;
/
Scott@ORCL > @C:\Users\J\Documents\SQL\test29.sql
Package created.
No errors.
Type of creation.
No errors.
The function is created.
No errors.
The function is created.
No errors.
the call of tabfunc1 (returns the packaged type):
PL/SQL procedure successfully completed.
Select * from table (tabfunc1)
*
ERROR on line 1:
ORA-00902: invalid data type
the call of tabfunc2 (returns the type of schema):
PL/SQL procedure successfully completed.
COLUMN_VALUE
------------
1
4
1
1
3
In anonymous block1 - open rc to select in the table (tabfunc1) (returns the packaged type):
declare
*
ERROR on line 1:
ORA-00902: invalid data type
ORA-06512: at line 6
In anonymous block2 - open rc to select in the table (tabfunc2) (returns the type of schema):
> 1
> 2
> 4
> 2
> 3
PL/SQL procedure successfully completed.
Post edited by: Jason_942375
But the compilation of the PIPELINED WILL CREATE the schematic function types automatically. And the TABLE function, applied to the PIPELINED function, use these types of hidden patterns.
-
Return type of dataframe string identifier
Hello
If I have to return a dataframe of rqScript which contains the string, how am I suppose to mention it in the return type of rqTableEval.
For example, if the return value of rqScript isdata.frame (c (1), c("Name"))
, which is a number and the other string
Then in the rqTableEval, identify the return values
'select ID, 1 '1' chain of double'
1 works as an identifier for the numbers but '1' doesn't work, '1' as an invalid identifier for the return string
I tried with the host of permutations "-* ','. '. "\ *", "a" etc., none seems not to work
Can I please get help on which must be specified as an identifier for the string type?
Published by: Kedar Gupte on May 21, 2013 01:52Kedar,
The string must be long enough to accommodate the output. For example, for a maximum length of 10 characters, you can do "Lucy" or cast ('a' as varchar2 (10)). You must also use single quotes instead of double quotes. In SQL double quotes are used to specify the identifiers (such as table names, column names, etc.). In your example, '1' is an unknown identifier. What you need is a string literal.
Denis
-
INVALID CURSOR - block anonymous component the cursor in function
I get an error when you try to call my cursor.CREATE OR REPLACE PACKAGE tax_update AS TYPE gencur IS ref cursor; FUNCTION tax_sf ( p_state IN bb_tax.state%type, p_thecursor IN OUT gencur ) RETURN NUMBER; END; / CREATE OR REPLACE PACKAGE BODY tax_update AS FUNCTION tax_sf ( p_state IN bb_tax.state%type, p_thecursor IN OUT gencur ) RETURN NUMBER IS lv_taxrate NUMBER; BEGIN OPEN p_thecursor FOR SELECT taxrate FROM bb_tax WHERE state = p_state; RETURN lv_taxrate; END; END; /
DECLARE tax_cur tax_update.gencur; rec_tax bb_tax%rowtype; BEGIN LOOP FETCH tax_cur INTO rec_tax; EXIT WHEN tax_cur%NOTFOUND; DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate); END LOOP; END;
Mission is to create a package that will contain the rate of taxation by the State in a packed slider. The package contains a function that can receive a State of 2 character abbreviated as an argument and finds a match in the cursor and return the tax rates for tha tstate. An anonymous block will test the function with the State of North Carolina.DECLARE * ERROR at line 1: ORA-01001: invalid cursor ORA-06512: at line 6
If anyone can help?user13842802 wrote:
Have tried a few ways to call but always error on TAX_SF.SET SERVEROUTPUT ON DECLARE tax_cur tax_update.gencur; rec_tax bb_tax%rowtype; BEGIN tax_cur := tax_update.tax_sf('NC'); LOOP FETCH tax_cur INTO rec_tax; EXIT WHEN tax_cur%NOTFOUND; DBMS_OUTPUT.PUT_LINE(rec_tax.taxrate); END LOOP; END; /
SY.
-
Initialize the Ref Cursor to avoid ORA-01001: Invalid cursor
Hello
I write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.
Any help is greatly appreciated...
Thank you
Christinecad0227 wrote:
HelloI write a stored procedure that returns a REF CURSOR. However, there are times when the cursor is not open if certain conditions are not met, so I wonder if there is a way to initialize the REF CURSOR so that the appellant does not receive the "ORA-01001: Invalid cursor" error when you try to work with the cursor, if it has not been opened.
Any help is greatly appreciated...
Thank you
ChristineThe most appropriate way would be the caller to handle the situation. The caller must capture the exception of INVALID_CURSOR and do what is necessary.
Other suggestions like having a separate Pavilion or a model select all will lead the appellant to act to the particular situation, that slider is not being opened. What is the case with the exception of INVALID_CURSOR raised by oracle.
All the need for the appellant to do is manage the exception of INVALID_CURSOR and you should be good. And also INVALID_CURSOR is not a mistake, it's an exception that has a special meaning for her. In the case you sense it takes the condition when not together to return a cursor.
-
When I try to run the following pl/sql code, I get error of invalid cursor. Can someone please explain to me where I am doing wrong.
Thanks in advance!DECLARE CURSOR C1 IS SELECT employee_id,last_name,salary FROM employees; EMP_REC C1%ROWTYPE; BEGIN FOR REC IN C1 LOOP FETCH C1 INTO EMP_REC; EXIT WHEN C1%NOTFOUND; DBMS_OUTPUT.PUT_LINE('Employee Number '||REC.employee_id); DBMS_OUTPUT.PUT_LINE('Employee Name '||REC.last_name); DBMS_OUTPUT.PUT_LINE('JOB '||REC.salary); END LOOP; END;
You must decide if you want to open the cursor implicit or explicit:
You can use:
Variant1
DECLARE CURSOR C1 IS SELECT employee_id,last_name,salary FROM employees; BEGIN FOR REC IN C1 LOOP DBMS_OUTPUT.PUT_LINE('Employee Number '||REC.employee_id); DBMS_OUTPUT.PUT_LINE('Employee Name '||REC.last_name); DBMS_OUTPUT.PUT_LINE('JOB '||REC.salary); END LOOP; END;
Variant2:
DECLARE CURSOR C1 IS SELECT id employee_id, name last_name, id salary FROM arzt where rownum<10; EMP_REC C1%ROWTYPE; BEGIN open c1; loop FETCH C1 INTO EMP_REC; EXIT WHEN C1%NOTFOUND; DBMS_OUTPUT.PUT_LINE('Employee Number '||emp_REC.employee_id); DBMS_OUTPUT.PUT_LINE('Employee Name '||emp_REC.last_name); DBMS_OUTPUT.PUT_LINE('JOB '||emp_REC.salary); END LOOP; END;
Published by: hm on 01.08.2011 00:12
-
Doubt about the return type of function
Hello
Can a function returns a Boolean value in a select query.
Suppose m creating a function... so can we have a return type of Boolean as...?
If so... THN please give an exampleCan a function returns a Boolean value in a select query
The answer is no. a Boolean is not a SQL data type and may not be used in the SELECT query.
For the user-defined function to be called in a SQL statement, see http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_packages.htm#ADFNS00908
Note especially these lines"Its formal parameters and its return value (if any) must have built-in data types (for example, CHAR, DATE or NUMBER) Oracle, not types (such as BOOLEAN, RECORD or TABLE) PL/SQL data.
"There is an exception to this rule: a formal parameter can have a PL/SQL data type, if the corresponding actual parameter is implicitly converted to the data type of the formal parameter" >
Published by: Johan August 3, 2010 03:48
-
getAttribute: Incorrect return Type
I use JDeveloper 10.1.3.3 with ADF/BC.
I get a strange error, because getAttribute returns a number, not an object. Is this a known bug? Or what I am doing wrong?
In my Module of Application I am retrieving the value of an attribute of a display object:
Number of numWeight = null;
String strWeight = "";
Double retrievedWeight = 0.00;
ViewObject reportVo = getMyReportView();
Line currRow = reportVo.next ();
This gives a runtime error. When debugging, I find that getAttribute returns a number, which is the data type of this attribute.
Hiowever, the documentation of the api says it must return an object.
retrievedWeight currRow.getAttrbite("Weight") = (Double);
So I try this and it give a compilation error:
numWeight = currRow.getAttribute ("Weight");
I need to do it for the
strWeight = currRow.getAttribute("Weight").toString ();
retrievedWeight = Double.parseDouble (strWeight);
private ViewObject getOnlineReportView (String which) {}
If (which.equalsIgnoreCase ("ABC")) {}
Return getOnlineReport_ABC();
} else {}
Return getOnlineReport_XYZ();
}
}
public OnlineReport_ABCImpl getOnlineReport_ABC() {}
return (OnlineReport_ABCImpl) findViewObject ("OnlineReport_ABC");
}
public OnlineReport_ABCImpl getOnlineReport_XYZ() {}
return (OnlineReport_XYZImpl) findViewObject ("OnlineReport_XYZ");
}
Thank you
JohnHello
oracle.jbo.domain.Number is an object as anything in Java which is not a literal is an object. It returns an object, which means it doesn't have a typed value of return, telling you that you must first convert it to oracle.jbo.domain.Number.
Frank
-
What are the causes of the log of user account on missing cursor in Windows XP? I have two trays of office that they have this same problem. If you restart them the cursor returns?
Hi DaddyJeff,
1. don't you make changes before the show?
2. are you referring to the cursor in the area of user password on the login screen of Windows?
3. when the cursor goes missing, the mouse pointer works on screen?It is difficult to say what is causing this problem. If the mouse pointer freezes or stops working, then we recommend you to reinstall the mouse. To do this, try the following steps:
a. sign in to Windows.
b. Click Start, click Run, type devmgmt.msc, and then click ok.
c. in the list of objects, expand mice and other pointing devices.
d. right click on the sub element and click on uninstall.
e. unplug the mouse and plug it back.
f. the Device Manager, select an item in the list, click the Action menu, click scan for hardware changes.
g. check if the mouse is detected, if so, then install it.See mouse USB which is connected to a USB 2.0 hub is not detected by Windows XP
Note: if the problem persists, restore the computer to an earlier time. See How to restore Windows XP to a previous stateVisit our Microsoft answers feedback Forum and let us know what you think.
Maybe you are looking for
-
Carplay music app is unresponsive
Hello I have a new VW Golf 7 (2016) with media Composition and AppConnect and use for music from Apple. Always well worked, connected with USB, drama pressed in music app and it works. But the application of music on my car radio suddenly became unre
-
LV OOP for an alternative to clusters?
I change the code with a large number of Boolean flags, each of them flashes when data is not valid. I need to eliminate the flashing lights. I am facing make a lot of changes to the existing property nodes, changing "Flashing" to "colors []". I don'
-
Microsoft or windows never contact you by phone about problems, that I get these calls very frustrating!
-
OfficeJet 5610xi: upgrade Windows 10 problems
Old workhorse of a printer works very well in wired mode on computer DELL laptop Windows 8.1. I have problems when I jump for Windows 10 next month? Also old MAC Mini running OS 10.4 via a wired connection. It will take new drivers?
-
Hi, I bought mid-February a 3252 Dell which is part of the range smaller slim. He had 10 Windows and Office 365 top when I got it. I had all sorts of problems with it, and Microsoft technicians finally told me that there is a conflict between these t