Ora-1460 during select using table(cast(type))
Hi all!
I've got a problem with a query that fails with a ora-1460 at random time intervals. This is a 10.2.0.3 version database running on a sun os.
We've managed to reproduce this error controlled when running an analyze on the table in question at the same time this query runs.
The error looks like this:
Unexpected system error, see server log for details. Root message is: org.apache.ojb.broker.PersistenceBrokerSQLException: * SQLException during execution of sql-statement: * sql statement was 'SELECT A0.ID,A0.LOCK_VERSION,A0.CLASS_NAME,A0.DESCRIPTION,A0.NAME,A0.EXTERNAL_ID,A0.ORDER_NUMBER,A0.LEVEL_ID,A0.ROOT_AH_ID,A0.DIFF_END_DATE,A0.DIFF_START_DATE,A0.SUPPORTED_BY_ASS_CAL,A0.CATEGORY_ROLE_ID FROM CATEGORY A0 WHERE A0.ID IN (select /*+ cardinality(1) */ * from table(cast( ems_string_to_table(?) as ems_table_of_number_type ))union select /*+ cardinality(1) */ * from table(cast( ems_string_to_table('') as ems_table_of_number_type)))' * Exception message is [ORA-01460: unimplemented or unreasonable conversion requested ] * Vendor error code [1460] * SQL state code [72000]
ems_string_to_table is a function thats populates a type with a unknown number of values. Though, the length of the string never exceeds 4k.
ems_table_of_number_type is a type define as "table of numbers".
Has anybody seen this error before, or have any idea why this should be?
Best regards,
Heyers
There is an IN clause constaraint i.e max number of characters you can pass from Oracle .Please check your select inner query which might be resulting to cross more than the boundary IN clause ,
Similar Messages
-
Special Grant to use "Select * from Table(cast..."??
Hi,
I've recently created the types and function to use the Table(Cast(funtion) as type)). It works fine, and gives me the correct result. I've granted execute on the types and on the function to a role that is enabled for a user, but when the user tries to use the "select * from table(cast(function) as type))", he gets a "ORA-01031: Insufficient Privileges" error message. Is there any other grant that must be given to the role, so that the user can execute the select?
Thanks in advance!
DanielHi Kamal,
I'm not sure what anonymous PL/SQL block means. When I (or the user) try to run the select, I enter all the information, i.e., the owners for the type and function: "select * from table(cast(a.my_function(my_argument) as a.my_type))". I'm trying to use SQLPlus at this time, and I have Oracle 8i.
I didn't to explicitly grant execute to the user because that would go against some rules I have to follow... I'll se if I give it a try though!
Thanks! -
Derive found flag in SQL with where clause using TABLE(CAST function
Dear All,
Stored procedure listEmployees
==========================
CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
empIdList STRING_ARRAY
countriesList STRING_ARRAY
SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
FROM EMPLOYEE WHERE
EMP_ID IN
(SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
AND EMP_COUNTRY IN
(SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
=================
I have a stored procedure which lists the employees using above simple query.
Here I am using table CAST function to find the list of employees in one go
instead of looping through each and every employee
Everything fine until requirements forced me to get the FOUND_FLAG as well.
Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
but I was not successful
Can you please suggest if there is any intelligent way to say weather the
row is found for given parameters in the where clause?
If not I may have to loop through each set of empIdList, countriesList
and find the values individually just to set a flag. In this approach I can’t use
the TABLE CAST function which is efficient I suppose.
Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
suppose to handle large sets of data.
Thanks In advance
Regards
Charan
Edited by: kmcharan on 03-Dec-2009 09:55
Edited by: kmcharan on 03-Dec-2009 09:55If your query returns results, you have found them... so your "FOUND" flag might be a constant,...
-
Hi,
i try to distribute SQL data objects - stored in a SQL data type TABLE OF <object-Type> - to multiple (parallel) instances of a table function,
by passing a CURSOR(...) to the table function, which selects from the SQL TABLE OF storage via "select * from TABLE(CAST(<storage> as <storage-type>)".
But oracle always only uses a single table function instance :-(
whatever hints i provide or setting i use for the parallel table function (parallel_enable ...)
Could it be, that this is due to the fact, that my data are not
globally available, but only in the main thread data?
Can someone confirm, that it's not possible to start multiple parallel table functions
for selecting on SQL data type TABLE OF <object>storages?
Here's an example sqlplus program to show the issue:
-------------------- snip ---------------------------------------------
set serveroutput on;
drop table test_table;
drop type ton_t;
drop type test_list;
drop type test_obj;
create table test_table
a number(19,0),
b timestamp with time zone,
c varchar2(256)
create or replace type test_obj as object(
a number(19,0),
b timestamp with time zone,
c varchar2(256)
create or replace type test_list as table of test_obj;
create or replace type ton_t as table of number;
create or replace package test_pkg
as
type test_rec is record (
a number(19,0),
b timestamp with time zone,
c varchar2(256)
type test_tab is table of test_rec;
type test_cur is ref cursor return test_rec;
function TF(mycur test_cur)
return test_list pipelined
parallel_enable(partition mycur by hash(a));
end;
create or replace package body test_pkg
as
function TF(mycur test_cur)
return test_list pipelined
parallel_enable(partition mycur by hash(a))
is
sid number;
counter number(19,0) := 0;
myrec test_rec;
mytab test_tab;
mytab2 test_list := test_list();
begin
select userenv('SID') into sid from dual;
dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): enter');
loop
fetch mycur into myRec;
exit when mycur%NOTFOUND;
mytab2.extend;
mytab2(mytab2.last) := test_obj(myRec.a, myRec.b, myRec.c);
end loop;
for i in mytab2.first..mytab2.last loop
-- attention: saves own SID in test_obj.a for indication to caller
-- how many sids have been involved
pipe row(test_obj(sid, mytab2(i).b, mytab2(i).c));
counter := counter + 1;
end loop;
dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): exit, piped #' || counter || ' records');
end;
end;
declare
myList test_list := test_list();
myList2 test_list := test_list();
sids ton_t := ton_t();
begin
for i in 1..10000 loop
myList.extend; myList(myList.last) := test_obj(i, sysdate, to_char(i+2));
end loop;
-- save into the real table
insert into test_table select * from table(cast (myList as test_list));
dbms_output.put_line(chr(10) || 'copy ''mylist'' to ''mylist2'' by streaming via table function...');
select test_obj(a, b, c) bulk collect into myList2
from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from table(cast (myList as test_list)) tab)));
dbms_output.put_line('... saved #' || myList2.count || ' records');
select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
dbms_output.put_line('worker thread''s sid list:');
for i in sids.first..sids.last loop
dbms_output.put_line('sid #' || sids(i));
end loop;
dbms_output.put_line(chr(10) || 'copy physical ''test_table'' to ''mylist2'' by streaming via table function:');
select test_obj(a, b, c) bulk collect into myList2
from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from test_table tab)));
dbms_output.put_line('... saved #' || myList2.count || ' records');
select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
dbms_output.put_line('worker thread''s sid list:');
for i in sids.first..sids.last loop
dbms_output.put_line('sid #' || sids(i));
end loop;
end;
-------------------- snap ---------------------------------------------
Here's the output:
-------------------- snip ---------------------------------------------
copy 'mylist' to 'mylist2' by streaming via table function...
test_pkg.TF( sid => '98' ): enter
test_pkg.TF( sid => '98' ): exit, piped #10000 records
... saved #10000 records
worker thread's sid list:
sid #98 -- ONLY A SINGLE SID HERE!
copy physical 'test_table' to 'mylist2' by streaming via table function:
... saved #10000 records
worker thread's sid list:
sid #128 -- A LIST OF SIDS HERE!
sid #141
sid #85
sid #125
sid #254
sid #101
sid #124
sid #109
sid #142
sid #92
PL/SQL procedure successfully completed.
-------------------- snap ---------------------------------------------
I posted it to newsgroup comp.databases.oracle.server.
(summary: "10g: parallel pipelined table functions with cursor selecting from table(cast(SQL collection)) doesn't work ")
But i didn't get a response.
There i also wrote some background information about my application:
-------------------- snip ---------------------------------------------
My application has a #2 steps/stages data selection.
A 1st select for minimal context base data
- mainly to evaluate for due driving data records.
And a 2nd select for all the "real" data to process a context
(joining much more other tables here, which i don't want to do for non-due records).
So it's doing stage #1 select first, then stage #2 select - based on stage #1 results - next.
The first implementation of the application did the stage #1 select in the main session of the pl/sql code.
And for the stage #2 select there was done a dispatch to multiple parallel table functions (in multiple worker sessions) for the "real work".
That worked.
However there was a flaw:
Between records from stage #1 selection and records from stage #2 selection there is a 1:n relation (via key / foreign key relation).
Means, for #1 resulting record from stage #1 selection, there are #x records from stage #2 selection.
That forced me to use "cluster curStage2 by (theKey)".
Because the worker sessions need to evaluate the all-over status for a context of #1 record from stage #1 and #x records from stage #2
(so it needs to have #x records of stage #2 together).
This then resulted in delay for starting up the worker sessions (i didn't find a way to get rid of this).
So i wanted to shift the invocation of the worker sessions to the stage #1 selection.
Then i don't need the "cluster curStage2 by (theKey)" anymore!
But: i also need to do an update of the primary driving data!
So the stage #1 select is a 'select ... for update ...'.
But you can't use such in CURSOR for table functions (which i can understand, why it's not possible).
So i have to do my stage #1 selection in two steps:
1. 'select for update' by main session and collect result in SQL collection.
2. pass collected data to parallel table functions
And for 2. i recognized, that it doesn't start up multiple parallel table function instances.
As a work-around
- if it's just not possible to start multiple parallel pipelined table functions for dispatching from 'select * from TABLE(CAST(... as ...))' -
i need to select again on the base tables - driven by the SQL collection data.
But before i do so, i wanted to verify, if it's really not possible.
Maybe i just miss a special oracle hint or whatever you can get "out of another box" :-)
-------------------- snap ---------------------------------------------
- many thanks!
rgds,
FrankHi,
i try to distribute SQL data objects - stored in a SQL data type TABLE OF <object-Type> - to multiple (parallel) instances of a table function,
by passing a CURSOR(...) to the table function, which selects from the SQL TABLE OF storage via "select * from TABLE(CAST(<storage> as <storage-type>)".
But oracle always only uses a single table function instance :-(
whatever hints i provide or setting i use for the parallel table function (parallel_enable ...)
Could it be, that this is due to the fact, that my data are not
globally available, but only in the main thread data?
Can someone confirm, that it's not possible to start multiple parallel table functions
for selecting on SQL data type TABLE OF <object>storages?
Here's an example sqlplus program to show the issue:
-------------------- snip ---------------------------------------------
set serveroutput on;
drop table test_table;
drop type ton_t;
drop type test_list;
drop type test_obj;
create table test_table
a number(19,0),
b timestamp with time zone,
c varchar2(256)
create or replace type test_obj as object(
a number(19,0),
b timestamp with time zone,
c varchar2(256)
create or replace type test_list as table of test_obj;
create or replace type ton_t as table of number;
create or replace package test_pkg
as
type test_rec is record (
a number(19,0),
b timestamp with time zone,
c varchar2(256)
type test_tab is table of test_rec;
type test_cur is ref cursor return test_rec;
function TF(mycur test_cur)
return test_list pipelined
parallel_enable(partition mycur by hash(a));
end;
create or replace package body test_pkg
as
function TF(mycur test_cur)
return test_list pipelined
parallel_enable(partition mycur by hash(a))
is
sid number;
counter number(19,0) := 0;
myrec test_rec;
mytab test_tab;
mytab2 test_list := test_list();
begin
select userenv('SID') into sid from dual;
dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): enter');
loop
fetch mycur into myRec;
exit when mycur%NOTFOUND;
mytab2.extend;
mytab2(mytab2.last) := test_obj(myRec.a, myRec.b, myRec.c);
end loop;
for i in mytab2.first..mytab2.last loop
-- attention: saves own SID in test_obj.a for indication to caller
-- how many sids have been involved
pipe row(test_obj(sid, mytab2(i).b, mytab2(i).c));
counter := counter + 1;
end loop;
dbms_output.put_line('test_pkg.TF( sid => '''|| sid || ''' ): exit, piped #' || counter || ' records');
end;
end;
declare
myList test_list := test_list();
myList2 test_list := test_list();
sids ton_t := ton_t();
begin
for i in 1..10000 loop
myList.extend; myList(myList.last) := test_obj(i, sysdate, to_char(i+2));
end loop;
-- save into the real table
insert into test_table select * from table(cast (myList as test_list));
dbms_output.put_line(chr(10) || 'copy ''mylist'' to ''mylist2'' by streaming via table function...');
select test_obj(a, b, c) bulk collect into myList2
from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from table(cast (myList as test_list)) tab)));
dbms_output.put_line('... saved #' || myList2.count || ' records');
select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
dbms_output.put_line('worker thread''s sid list:');
for i in sids.first..sids.last loop
dbms_output.put_line('sid #' || sids(i));
end loop;
dbms_output.put_line(chr(10) || 'copy physical ''test_table'' to ''mylist2'' by streaming via table function:');
select test_obj(a, b, c) bulk collect into myList2
from table(test_pkg.TF(CURSOR(select /*+ parallel(tab,10) */ * from test_table tab)));
dbms_output.put_line('... saved #' || myList2.count || ' records');
select distinct(tab.a) bulk collect into sids from table(cast (myList2 as test_list)) tab;
dbms_output.put_line('worker thread''s sid list:');
for i in sids.first..sids.last loop
dbms_output.put_line('sid #' || sids(i));
end loop;
end;
-------------------- snap ---------------------------------------------
Here's the output:
-------------------- snip ---------------------------------------------
copy 'mylist' to 'mylist2' by streaming via table function...
test_pkg.TF( sid => '98' ): enter
test_pkg.TF( sid => '98' ): exit, piped #10000 records
... saved #10000 records
worker thread's sid list:
sid #98 -- ONLY A SINGLE SID HERE!
copy physical 'test_table' to 'mylist2' by streaming via table function:
... saved #10000 records
worker thread's sid list:
sid #128 -- A LIST OF SIDS HERE!
sid #141
sid #85
sid #125
sid #254
sid #101
sid #124
sid #109
sid #142
sid #92
PL/SQL procedure successfully completed.
-------------------- snap ---------------------------------------------
I posted it to newsgroup comp.databases.oracle.server.
(summary: "10g: parallel pipelined table functions with cursor selecting from table(cast(SQL collection)) doesn't work ")
But i didn't get a response.
There i also wrote some background information about my application:
-------------------- snip ---------------------------------------------
My application has a #2 steps/stages data selection.
A 1st select for minimal context base data
- mainly to evaluate for due driving data records.
And a 2nd select for all the "real" data to process a context
(joining much more other tables here, which i don't want to do for non-due records).
So it's doing stage #1 select first, then stage #2 select - based on stage #1 results - next.
The first implementation of the application did the stage #1 select in the main session of the pl/sql code.
And for the stage #2 select there was done a dispatch to multiple parallel table functions (in multiple worker sessions) for the "real work".
That worked.
However there was a flaw:
Between records from stage #1 selection and records from stage #2 selection there is a 1:n relation (via key / foreign key relation).
Means, for #1 resulting record from stage #1 selection, there are #x records from stage #2 selection.
That forced me to use "cluster curStage2 by (theKey)".
Because the worker sessions need to evaluate the all-over status for a context of #1 record from stage #1 and #x records from stage #2
(so it needs to have #x records of stage #2 together).
This then resulted in delay for starting up the worker sessions (i didn't find a way to get rid of this).
So i wanted to shift the invocation of the worker sessions to the stage #1 selection.
Then i don't need the "cluster curStage2 by (theKey)" anymore!
But: i also need to do an update of the primary driving data!
So the stage #1 select is a 'select ... for update ...'.
But you can't use such in CURSOR for table functions (which i can understand, why it's not possible).
So i have to do my stage #1 selection in two steps:
1. 'select for update' by main session and collect result in SQL collection.
2. pass collected data to parallel table functions
And for 2. i recognized, that it doesn't start up multiple parallel table function instances.
As a work-around
- if it's just not possible to start multiple parallel pipelined table functions for dispatching from 'select * from TABLE(CAST(... as ...))' -
i need to select again on the base tables - driven by the SQL collection data.
But before i do so, i wanted to verify, if it's really not possible.
Maybe i just miss a special oracle hint or whatever you can get "out of another box" :-)
-------------------- snap ---------------------------------------------
- many thanks!
rgds,
Frank -
Expression Framework / SELECT * FROM TABLE(CAST(...
Hello!
Is it possible to build the following with Toplink Expression Framework?
Example:
CREATE TYPE TY_OB_TEST AS OBJECT
( SYSTOP_NR NUMBER(5,0)
SYS_NR NUMBER(5,0)
IM_SYS_NAME VARCHAR2(80) ) ;
CREATE TYPE TY_TB_TEST AS TABLE OF TY_OB_TEST;
Package1.FUNCTION1 returns Type TY_TB_TEST.
SQL:
select * from TABLE(CAST(PACKAGE1.FUNCTION1(42)) AS TY_TB_TEST ));
thank you!
Harald.Nope, just use SQL.
- Don -
Problems using table (cast as)
Hi
I have some code like this:
declare
TYPE t_forall_bags IS TABLE OF misbag.bags%ROWTYPE;
l_forall_bags t_forall_bags := t_forall_bags ();
begin
open c2;
FETCH c2 BULK COLLECT INTO l_forall_bags LIMIT v_array_size;
if l_forall_bags.COUNT > 0 then
begin
merge into misbag.bags dest
using (select col1,
col2,
colx
from TABLE( cast( l_forall_bags as t_forall_bags ) ) ) src
on (dest.bag_id = src.bag_id )
when matched then
--do update stuff
when not matched then
--do insert stuff;
end;
end if;
end;
on compilation I am getting an ora-00902 invalid datatype seemingly on the t_forall_bags in side the cast (as highlighted in bold)
I thought I had the syntax correct, but maybe not.
rgds
TonyBluShadow wrote:Why are you querying data from the database into a collection (in expensive PGA memory) to then pass that back down to the SQL engine to be treated as a table (and incidently one without any indexes or the other benefits of a database table).Well that is a very good question.
The task is to take a generally smaller number of very recent rows from one table and apply them to a similar table in another schema. This task will run very frequently (ie every second or two) so generally will have a smallish number fo rows (ie 100-200) each time it runs. Some rows are updates and some rows are inserts.
If there is a delay on running the task, we don't necessarily want to process all of the outstanding rows in one go, but to take them in chunks until is catches up.
One way to do this would be to perform multiple queries on the original data to check how many rows where outstanding, then to select which ones were to be merged, then go ahead and do the merge (with both main tables as you propose). This alternate idea (that I was looking at here) was to bulk collect the first n rows from the table into the array (up to the defined limit) and then to merge this list of rows into the destination table. The goal was to perform fewer data accesses and make the process least expensive in I/O. By bulk selecting up to N rows into the array, it was felt that there was less I/O on the source table, and probably the same amount of I/O on the destination table.
The very first method of writing was to bulk select the first N rows into an array, delete any that already existed in the dest table then to "forall" insert the array contents into the destination table. This seemed to work quite well, we wanted to compare the merge version and see how it compared in speed and I/O usage.
Tony
rgds
Tony -
Getting SqlException while using TABLE CAST but works fine with order by
I am using following query as sub-query with in a query which I have used in PL/SQL. This sub-query works fine If I add Order by x1,x2 at the end of the query. Otherwise it gives a SQLException.
SELECT x1,x2 FROM TABLE( CAST (somelist AS X_ARRAY ))Narendra,
If this question is related to HTML DB, please provide complete context, and show the exact text of error messages and the query itself.
Scott -
ORA-01555 during SELECT ??
I am running Oracle 9i on Solaris 9. I have a Stored Procedue that's essentially a huge SELECT (no insert, update, delete at all) statement joining many big tables. The query plan looks pretty good -- all index hits, no table scan. Now -- when I run it I get the infamous ORA-01555 error on UNDO segment -- saying its too small! What may be the reason (note that there are not many users on this system) and how to avoid it?
Thanks.Since you didn't provide any details we can redirect you in those following links ->
1. Error Reason ->
http://ora-01555.ora-code.com/
2. Popular Oracle Thread By Tom Kytes in this topic ->
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1441804355350
Regards.
Satyaki De. -
Table cast PL/SQL: ORA-00902: invalid datatype
I m getting
PL/SQL: ORA-00902: invalid datatype
error in
OPEN pPymtCur FOR
SELECT *
FROM TABLE(CAST( up_gap_tra_reports.myArray AS traArray));
in my package up_gap_tra_reports.
CREATE OR REPLACE PACKAGE GAPSDVEL.up_gap_tra_reports
AS
TYPE traRecord IS RECORD
group1StudEnrol NUMBER(6,1),
group2StudEnrol NUMBER(6,1),
pymtAmt gap_payment.NET_AMT%TYPE
TYPE traArray IS TABLE OF traRecord;
myArray traArray := traArray() ;
END up_gap_tra_reports;
I hv alreay declared traArray type.
pls help me to solve this.Meghna wrote:
is there any way to use pl/sql collection in SQL or refcur without creating it because i am not able to create type in database.The only way I am aware of is pipelined function:
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>Keep in mind, it will create system generated 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. -
Table(cast - invalid datatype problem
Hi All,
Basic scenario:
PACKAGE
create or replace
PACKAGE C2_PAYMENT_DOC IS
TYPE bin_array IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;
FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
PACKAGE_BODY
create or replace
package body C2_PAYMENT_DOC as
FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
l_gross bin_array;
begin
c2_purchase_invoice.get_inv_gross_amount(l_doc_id, l_gross(1));
return l_gross;
end;
END;
QUERY
select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
Result of the query is ORA-00902: invalid datatype
How can I make the select statement valid?
Thanks in advance,
BartekYou can not use local collection types in SQL. You must create type bin_array as SQL nested table type. Also, depending on version you might not need to cast:
SQL> CREATE OR REPLACE
2 TYPE bin_array
3 AS TABLE OF NUMBER
4 /
Type created.
SQL> create or replace
2 PACKAGE C2_PAYMENT_DOC IS
3 FUNCTION test_fun(l_doc_id IN integer) RETURN bin_array;
4 end;
5 /
Package created.
SQL> create or replace
2 package body C2_PAYMENT_DOC as
3
4 FUNCTION test_fun (l_doc_id IN integer) RETURN bin_array IS
5 l_gross bin_array := bin_array();
6 begin
7 l_gross.extend;
8 l_gross(1) := l_doc_id;
9 return l_gross;
10 end;
11 END;
12 /
Package body created.
SQL> select * from Table(Cast(c2_payment_doc.test_fun(1) As bin_array));
COLUMN_VALUE
1
SQL> select * from Table(c2_payment_doc.test_fun(1))
2 /
COLUMN_VALUE
1
SQL> SY. -
I am using TABLE(CAST()) operation in PL/SQL and it is returning me no data.
Here is what I have done:
1. Created Record type
CREATE OR REPLACE TYPE target_rec AS OBJECT
target__id NUMBER(10),
target_entity_id NUMBER(10),
dd CHAR(3),
fd CHAR(3),
code NUMBER(10),
target_pct NUMBER,
template_nm VARCHAR2(50),
p_symbol VARCHAR2(10),
pm_init VARCHAR2(3),
target_name VARCHAR2(20),
targe_type VARCHAR2(30),
target_caption VARCHAR2(30),
sort_order NUMBER (4)
2. Created Table type
CREATE OR REPLACE TYPE target_arr AS TABLE OF target_rec
3. Created Stored procedure which accepts parameter of type target_arr and runs the Table(Cast()) function on it.
Following is the simplified form of my procedure.
PROCEDURE get_target_weights
p_in_template_target IN target_arr,
p_out_count OUT NUMBER,
IS
BEGIN
SELECT count(*) into p_out_count
FROM TABLE(CAST(p_in_template_target AS target_arr)) arr;
END;
I am calling get_target_weights from my java code and passing p_in_template_target with 10140 records.
Scenario 1: If target_pct in the last record is 0, p_out_count returned from the procedure is 0.
Scenario 2: If target_pct in the last record is any other value(say 0.01), p_out_count returned from the procedure is 10140.
Please help me understand why the Table(Cast()) is not returning the correct results in Scenario 1. Also adding or deleting any record from the test data returns the correct results (i.e. if keep target_pct in the last record as 0 but add or delete any record).
Let me know how can I attach the test data I am using to help you debugging as I don’t see any Attach file button on Post Message screen on the forum.I am not able to reproduce this problem with a small data set. I can only reproduce with the data having 10140 records.
I am not sure if this is the memory issue as adding a new record also solves the problem.
This should not be the error because of wrong way of filling the records in java as for testing purpose I just saved the records which I am sending from java in a table. I updated the stored procedure as well to read the data from the table and then perform TABLE(CAST()) operation. I am still getting 0 as the output for scenario 1 mentioned in my last mail.
Here is what I have updated:
1. Created the table target_table
CREATE Table target_table
target_id NUMBER(10),
target_entity_id NUMBER(10),
dd CHAR(3),
fd CHAR(3),
code NUMBER(10),
target_pct NUMBER,
template_nm VARCHAR2(50),
p_symbol VARCHAR2(10),
pm_init VARCHAR2(3),
target_name VARCHAR2(20),
target_type VARCHAR2(30),
target_caption VARCHAR2(30),
sort_order NUMBER (4)
2. Inserted data into the table : The script has around 10140 rows. Pls let me know how can I send it to you
3. Updated procedure to read data from table and stored into variable of type target_arr. Run Table(cast()) operation on target_arr and get the count
PROCEDURE test_target_weights
IS
v_target_rec target_table%ROWTYPE;
CURSOR wt_cursor IS
Select * from target_table;
v_count NUMBER := 1;
v_target_arr cws_target_arr:= target_arr ();
v_target_arr_rec target_rec;
v_rec_count NUMBER;
BEGIN
OPEN wt_cursor;
loop
fetch wt_cursor into v_target_rec; -- fetch data from table into local record.
exit when wt_cursor%notfound;
--move data into target_arr
v_target_arr_rec := cws_curr_pair_entity_wt_rec(v_target_rec target_id,v_target_rec. target_entity_id,
v_target_rec.dd,v_target_rec.fd,v_target_rec.code,v_target_rec.target_pct,
v_target_rec.template_nm,v_target_rec.p_symbol,v_target_rec.pm_init,v_target_rec.template_name,
v_target_rec.template_type,v_target_rec.template_caption,v_target_rec.sort_order);
v_target_arr.extend();
v_target_arr(v_count) := v_target_arr_rec;
v_count := v_count + 1;
end loop;
close wt_cursor;
-- run table cast on target_arr
SELECT count(*) into v_rec_count
FROM TABLE(CAST(v_target_arr AS target_arr)) arr;
DBMS_OUTPUT.enable;
DBMS_OUTPUT.PUT_LINE('p_out_count ' || v_rec_count);
DBMS_OUTPUT.PUT_LINE('v_count ' || v_count);
END;
Output is
p_out_count 0
v_count 10140
Expected output
p_out_count 10140
v_count 10140 -
Internal Error while using Table Functions
Here is the query
select * from table (cast(sf_frontend.SF_STDDEV(2002,'Q','1',20,'N') as
NDeviation))
It gives this error
ORA-00600: internal error code, arguments: [17274], [4], [], [], [], [], [], []
Can anyone help me out... Any help will be appreciated
[email protected]1. Have the screen open where you have the Shift F2, you can manually run the query of the formatted search, it will sometimes give you more meaningful message.
Eg:
You have a formatted search query 'Query 1' which is saved in Tools> User Query> Query 1 attached to field DocTotal.
So, what you do is, instead of pressing Shift F2, you go to tools > User Query.> Query 1 to run it.
2. Another thing could be the field you used in the formula do not have the focus when you run it.
Eg: you use $[4.0.0] in the query.
When you press Shift F2, the field represents $[$4.0.0] do not have focus. -
I am using following objects.
CREATE OR REPLACE TYPE t_assoc_agents_address AS OBJECT
(V_CONTACT_NAME VARCHAR2(120),
V_ADDRTYPE VARCHAR2(80),
V_ADDRESS_LINE1 VARCHAR2(50),
V_ADDRESS_LINE2 VARCHAR2(50),
V_ADDRESS_LINE3 VARCHAR2(50),
V_CITY_STATE_ZIP VARCHAR2(100),
V_PHONE VARCHAR2(50),
V_ADDRESS_FAX VARCHAR2(30),
V_ADDRESS_EMAIL VARCHAR2(80)
CREATE OR REPLACE TYPE nt_assoc_agents_address AS TABLE OF t_assoc_agents_address;
Following SQL query is working fine.
Sql:
SELECT *
FROM
table(cast (lv_assoc_agents_add_out AS nt_assoc_agents_address));
But, following Sql query doesn't work.
SELECT V_ADDRESS_FAX,V_ADDRESS_EMAIL
FROM
table(cast (lv_assoc_agents_add_out AS nt_assoc_agents_address));
Oracle Error: 'V_ADDRESS_EMAIL' invalid identifier.
Would you please clarify this, and suggest appropriate solution to select specific columns instead of
selecting all columns in above SQL query.OK, I have found your code in your previous post.
It works in 9.2.0.1.0 and 8.1.7.0.0.
SQL> CREATE OR REPLACE TYPE t_assoc_agents_address AS OBJECT
2 (V_CONTACT_NAME VARCHAR2(120),
3 V_ADDRTYPE VARCHAR2(80),
4 V_ADDRESS_LINE1 VARCHAR2(50),
5 V_ADDRESS_LINE2 VARCHAR2(50),
6 V_ADDRESS_LINE3 VARCHAR2(50),
7 V_CITY_STATE_ZIP VARCHAR2(100),
8 V_PHONE VARCHAR2(50),
9 V_ADDRESS_FAX VARCHAR2(30),
10 V_ADDRESS_EMAIL VARCHAR2(80)
11 )
12 /
 
Type created.
 
SQL> CREATE OR REPLACE TYPE nt_assoc_agents_address AS TABLE OF t_assoc_agents_address
2 /
 
Type created.
 
SQL> var c refcursor
SQL> col v_address_fax format a15
SQL> col v_address_email format a15
SQL> declare
2 lv_assoc_agents_add_out nt_assoc_agents_address
3 := nt_assoc_agents_address(
4 t_assoc_agents_address(null,null,null,null,null,null,null,
5 'New Fax', 'New Mail')
6 );
7 begin
8 open :c for select V_ADDRESS_FAX,V_ADDRESS_EMAIL from
9 table(cast(lv_assoc_agents_add_out as nt_assoc_agents_address));
10 end;
11 /
 
PL/SQL procedure successfully completed.
 
SQL> print c
 
V_ADDRESS_FAX V_ADDRESS_EMAIL
New Fax New MailWhat is your Oracle release and how are you using ref cursor (if I interpret your example right) ?
Rgds. -
Problem with table(cast..)) clause - timeout
Hello,
I've in shared memory one query in multiple copies - one differences between copies is in arguments count given with in clause. For example, in shared memory i have:
select name from a where id in (?);
select name from a where id in (?,?);
select name from a where id in (?,?,?);
I try to minimize size of shared memory by change this query as in example:
select name from a where id in (select * from table(cast(? as seqintegertable)))
In this case my shared memory is ok, but I have problem with timeout exception:
- time of executing query without cast is about 250 ms
- with cast: about 10560 ms and sometimes I get ORA-01652
Why this time is so long? Can I reduce it? Maybe I should change something other?user13241971 wrote:
Why this time is so long? Can I reduce it? Maybe I should change something other?To know why your query takes so long: {thread:id=501834}
Likely it's because of wrong cardinalities, to which this excellent article gives possible solutions: http://www.oracle-developer.net/display.php?id=427
Regards,
Rob. -
Sqlldr: ORA-00928: missing SELECT keyword
Hi,
I am not able to make sqlldr work using very simple control file. Any hints appreciated
P..
<pre>
-bash-3.2$ cat /export/oracle/a.ctl
LOAD DATA
INTO TABLE utf8
fields terminated by ","
(char, x)
-bash-3.2$ cat /export/oracle/data.txt
a,b
c,d
-bash-3.2$ bin/sqlldr sysman/11amcoke control=/export/oracle/a.ctl data=/export/oracle/data.txt log=import
SQL*Loader: Release 11.2.0.1.0 - Production on Tue Oct 11 01:02:26 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
-bash-3.2$ cat import.log
SQL*Loader: Release 11.2.0.1.0 - Production on Tue Oct 11 01:02:26 2011
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Control File: /export/oracle/a.ctl
Data File: /export/oracle/data.txt
Bad File: /export/oracle/data.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table UTF8, loaded from every logical record.
Insert option in effect for this table: INSERT
Column Name Position Len Term Encl Datatype
CHAR FIRST * , CHARACTER
X NEXT * , CHARACTER
Record 1: Rejected - Error on table UTF8, column CHAR.
ORA-00928: missing SELECT keyword
Record 2: Rejected - Error on table UTF8, column CHAR.
ORA-00928: missing SELECT keyword
Table UTF8:
0 Rows successfully loaded.
2 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 33024 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 2
Total logical records rejected: 2
Total logical records discarded: 0
Run began on Tue Oct 11 01:02:26 2011
Run ended on Tue Oct 11 01:02:26 2011
Elapsed time was: 00:00:00.12
CPU time was: 00:00:00.04
</pre>
Should it matter, this is on Solaris 10u10, amd64 (VirtualBox) with 8GB RAM
Edited by: user13277775 on 10.10.2011 16:10Don't use reserved words (CHAR,which is a format specification) as column names:
http://download.oracle.com/docs/cd/E11882_01/server.112/e22490/ldr_field_list.htm#i1015797
Maybe you are looking for
-
Release of PO: task TS20000166: T16FW
<b>Step 1</b>My PO is having 3 Step release strategy applied. 01 Sr Engineer 02 Manager 03 VP <b>Step 2</b> Assignment of Role to Release Code (Table <i>T16FW</i> Maint. view<i> V_T16FW</i>) 3 different SAP users has been assigned as
-
Can you use your pc's internet on your ipod?
I cant get on the wifi network on my ipod because its a weird metwork. Is there anyway for me to connect my ipod to my computer and use the internet on my ipod via my pc?
-
Why will quicktime 7 not play mp4 from windows
So I made a video with an H.264/mp4 format using a program called Lightwave on Windows 7. When I transferred this file to quicktime 7 on a mac for a presentation, the first image looked fine for about 3 seconds, then the colors were all changed aroun
-
Textfield bug in Flash CS4 and Flash Player?
Hi there, I'm goning mad about this, hope someone can help. What's the problem.. I have a textfield on the stage (100% view). When I place a vertcal line at the end of the text and I zoom in to 200% the text in the textfield is somehow smaller! How i
-
Print booklet CS6 - print presets missing
We have a problem using the print booklet feature in CS6. We can't choose print presets, resulting in low res PDF files and low res print work. How can we solve this problem?