Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Genereic reference type in PL/SQL?
Thomas Blankschein wrote:
> Hello,
>
> I work with Oracle 9.2.0.7 Standard.
>
> I know about the REF CURSOR type. But is it possible to create and use
> references for other types, like pointers in C/C++?
>
> Here is a pseudocode example of what I want to achieve. In this special
> case I can of course use an array. It's just an example.
>
> CREATE OR REPLACE FUNCTION ref_test(p_Index IN NUMBER) RETURN VARCHAR2
> IS
> strText1 VARCHAR2(10);
> strText2 VARCHAR2(10);
> strText3 VARCHAR2(10);
> pointer_to_varchar REF VARCHAR2; <--- ???
>
> BEGIN
>
> strText1 := 'One';
> strText2 := 'Two';
> strText3 := 'Three';
>
> -- Set the reference to the right variable, depending on the
> -- index parameter
> IF p_Index = 1 THEN pointer_to_varchar := REF(strText1); <--- ???
> IF p_Index = 2 THEN pointer_to_varchar := REF(strText2); <--- ???
> IF p_Index = 3 THEN pointer_to_varchar := REF(strText3); <--- ???
>
> -- Returning the text
> RETURN DEREF(pointer_to_varchar); <--- ???
>
> END;
Pointers to scalar types are not available in PL/SQL. Actually, they
shouldn't have been available in other languages, too. :) (and some
modern languages already got rid of them...) Why do you think you need
pointers in PL/SQL? What's the task at hand?
Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com
Received on Fri Oct 13 2006 - 02:09:35 CDT