Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: URGENT: Temporary Tables
In article <7kvjh9$m2h$1_at_news3.saix.net>,
"Billy Verreynne" <vslabs_at_onwe.co.za> wrote:
> yitbsal_at_statcan.ca wrote in message <7ku6r1$hd4$1_at_nnrp1.deja.com>...
> >
> >I want to create a temporary table -- visible only within a session
> >-- in a stored procedure. Is this possible?
>
> No.
>
> Now that was too easy to answer. That won't do in this newsgroup. So
let me
> try again... :-)
>
> temp tables? - ala SQL-Server style? No, not in Oracle.
>
> tables visible only within a session? - No (Oracle security works at
> user/schema level and not physical session/process level - you can
not grant
> rights or privs to a session)
>
> create a table in a stored proc? - Yes (using the dynamic SQL stored
proc
> package).
>
> Maybe if you tells us what the requirement is behind all this, we can
try
> and come up with alternative solutions?
>
> regards,
> Billy
>
>
Well, my interpretation of the question is a bit different than Billy's so here is my take on it. Yes, you can create a persistent pl/sql table (otherwise known as indexed-by table) for a session. Session being defined as a user's persistent connection (with out disconnecting, web transactions are not persistent). How do you do this?
Here is an example:
[Snip]
type customer_recs_tabtype is table of customer_rectype index by
binary_integer;
customer_recs customer_recs_tabtype;
END PERSISTENCE; /
CREATE OR REPLACE PACKAGE BODY PERSISTENCE AS PROCEDURE LOAD_ARRAY IS BEGIN
END LOAD_ARRAY;
dbms_output.put_line('*** Record ' || i || ' ***'); dbms_output.put_line('CustID: ' || customer_recs(i).cust_id); dbms_output.put_line('CustName: ' || customer_recs(i).cust_name); dbms_output.put_line('CustBirth: ' || customer_recs (i).cust_birth_dt); dbms_output.put_line(chr(10));
SQL> set serveroutput on;
SQL> exec persistence.load_array;
PL/SQL procedure successfully completed.
SQL> exec persistence.display_array;
*** Record 1 ***
CustID: 1000
CustName: Erik
CustBirth: 25-JUN-99
PL/SQL procedure successfully completed.
SQL> exec persistence.display_array;
*** Record 1 ***
CustID: 1000
CustName: Erik
CustBirth: 25-JUN-99
PL/SQL procedure successfully completed.
SQL>
--
Erik
Consultant
Saraswati Systems Corporation - (SSC)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Fri Jun 25 1999 - 13:05:30 CDT
![]() |
![]() |