dbTalk Databases Forums  

Can MEMBER OF condition use pl/sql tables

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Can MEMBER OF condition use pl/sql tables in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kevin S
 
Posts: n/a

Default Can MEMBER OF condition use pl/sql tables - 01-27-2009 , 09:16 AM






All,

Is it possible to use pl/sql tables (Associative Arrays) instead of a
varray when using the MEMBER OF condition?

Thanks

Reply With Quote
  #2  
Old   
Ed Prochak
 
Posts: n/a

Default Re: Can MEMBER OF condition use pl/sql tables - 01-27-2009 , 01:05 PM






On Jan 27, 10:16*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
All,

Is it possible to use pl/sql tables (Associative Arrays) instead of a
varray when using the MEMBER OF condition?

Thanks
WHAT version of ORACLE?????

have you checked the documentation? (i.e., RTFM)
here's 10g
http://download.oracle.com/docs/cd/B...htm#sthref1108


Reply With Quote
  #3  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: Can MEMBER OF condition use pl/sql tables - 01-27-2009 , 03:01 PM



Kevin S schrieb:
Quote:
All,

Is it possible to use pl/sql tables (Associative Arrays) instead of a
varray when using the MEMBER OF condition?

Thanks
Actually, "member of" doesn't work with varrays (the same about
associative arrays) - the only collection type it supports is nested table.

Best regards

Maxim


Reply With Quote
  #4  
Old   
Kevin S
 
Posts: n/a

Default Re: Can MEMBER OF condition use pl/sql tables - 01-28-2009 , 05:37 AM



Maxim,

Good point, I should have said nested table.

What I want to be able to do is use a record created at run time
rather than create something in the schema.

It doesn't seem to big a thing to expect to be able to do but
apparently it is not possible.

Anyone know if there is a technical reason why opr if it was simply
something that was overlooed whern the functionality was introduced?

Anyone have a work around?

Thanks for responding.

KS

Reply With Quote
  #5  
Old   
William Robertson
 
Posts: n/a

Default Re: Can MEMBER OF condition use pl/sql tables - 01-29-2009 , 02:33 AM



On Jan 28, 11:37*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
What I want to be able to do is use a record created at run time
rather than create something in the schema.

It doesn't seem to big a thing to expect to be able to do but
apparently it is not possible.

Anyone know if there is a technical reason why opr if it was simply
something that was overlooed whern the functionality was introduced?

Anyone have a work around?
MEMBER OF works fine with nested table collections declared within PL/
SQL. However the part about records could be complicating things, as
PL/SQL record variables don't have a lot of the functionality of
object types. What have you tried that isn't working?


Reply With Quote
  #6  
Old   
Kevin S
 
Posts: n/a

Default Re: Can MEMBER OF condition use pl/sql tables - 01-29-2009 , 05:49 AM



William,

Running the code below will illustrates the issue I am trying to
resolve which takes the form of a compile time error
PLS-00330: Invalid use of type name or subtype name.

I am presuming this is to do with my use of a pl/sql table instead of
a nested table.

In addition to a pl/sql table, I have also tried it with the
collection declarations/types commented out in the code and got the
same message

Thanks for your interest.

Kevin

CREATE OR REPLACE PACKAGE BODY REPORT_PKG IS

PROCEDURE testmemberofprc(
po_ref_cursor OUT RefCursor)
IS
TYPE alc_tab IS TABLE OF VARCHAR2(4000) INDEX BY PLS_INTEGER;
--TYPE alc_tab IS TABLE OF VARCHAR2(4000);
--TYPE alc_tab IS TABLE OF VARCHAR2(4000) NOT NULL;
--TYPE alc_tab IS VARRAY(10) OF VARCHAR2(4000) NOT NULL;

t_alc alc_tab;

v_index NUMBER:=0;
v_sql VARCHAR2(2000);
v_errcode VARCHAR2(2000);

BEGIN

t_alc(v_index) := 'GOR01';
v_index := v_index +1;
t_alc(v_index) := 'GOR02';
v_index := v_index +1;
t_alc(v_index) := 'GOR03';

v_sql := 'SELECT * FROM IOW_FULL_VW WHERE aggregatelevelcode
MEMBER OF :t_alc ';

OPEN po_ref_Cursor FOR v_sql USING t_alc;

EXCEPTION
WHEN OTHERS
THEN
v_errcode := Sqlerrm;
RAISE;
END testmemberofprc;

END REPORT_PKG;

Reply With Quote
  #7  
Old   
William Robertson
 
Posts: n/a

Default Re: Can MEMBER OF condition use pl/sql tables - 01-31-2009 , 01:52 AM



On Jan 29, 11:49*am, Kevin S <Sear... (AT) googlemail (DOT) com> wrote:
Quote:
William,

Running the code below will illustrates the issue I am trying to
resolve which takes the form of a compile time error
PLS-00330: Invalid use of type name or subtype name.

I am presuming this is to do with my use of a pl/sql table instead of
a nested table.

In addition to a pl/sql table, I have also tried it with the
collection declarations/types commented out in the code and got the
same message

Thanks for your interest.

Kevin

CREATE OR REPLACE PACKAGE BODY REPORT_PKG IS

* PROCEDURE testmemberofprc(
* * * * * * po_ref_cursor * * * * * *OUT RefCursor)
* IS
* * TYPE alc_tab IS TABLE OF VARCHAR2(4000) INDEX BY PLS_INTEGER;
* * --TYPE alc_tab IS TABLE OF VARCHAR2(4000);
* * --TYPE alc_tab IS TABLE OF VARCHAR2(4000) NOT NULL;
* * --TYPE alc_tab IS VARRAY(10) OF VARCHAR2(4000) NOT NULL;

* * t_alc alc_tab;

* * v_index NUMBER:=0;
* * v_sql VARCHAR2(2000);
* * v_errcode VARCHAR2(2000);

* BEGIN

* * t_alc(v_index) := 'GOR01';
* * v_index := v_index +1;
* * t_alc(v_index) := 'GOR02';
* * v_index := v_index +1;
* * t_alc(v_index) := 'GOR03';

* * v_sql := 'SELECT * FROM IOW_FULL_VW WHERE aggregatelevelcode
MEMBER OF :t_alc ';

* * OPEN po_ref_Cursor FOR v_sql USING t_alc;

* EXCEPTION
* WHEN OTHERS
* * * *THEN
* * * *v_errcode := Sqlerrm;
* * * *RAISE;
* END testmemberofprc;

END REPORT_PKG;
True, that won't work with any locally defined collection type. That's
a restriction of SQL within PL/SQL though, not of MEMBER OF. There are
also some restrictions around what can be passed to dynamic SQL like
this as bind variables. Does it have to be dynamic? Why can't you have
a generic VARCHAR2_NTT scalar collection type and reuse it in all
situations like this?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.