temporary table creation in Oracle through procedure

Dúvidas, dicas e truques de PL/SQL. Aqui também vão assuntos relacionados a pacotes, triggers, funções, Java-Stored Procedures, etc
Post Reply
Adriana Borges
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 3
Joined: Mon, 27 Jul 2009 3:53 pm
Location: Rio de Janeiro
Adriana Borges

People! I'm trying to create the procedure below to create a Temporary table in Oracle.
I am using the toad with the code below and the same returns the error

Select all

PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: 
   begin declare exit for goto if loop mod null pragma raise
Some can help me ....: D: D: D: D

Select all

CREATE OR REPLACE PROCEDURE sp_tableTempComb IS  
BEGIN	 
 
	CREATE TEMPORARY TABLE TEMP_COMBINACAO 
	( 
	  COD_PARCEIRO INTEGER, 
	  COD_PLANO INTEGER, 
	  COD_CAMPANHA_CAP INTEGER, 
	  NUM_SERIE INTEGER, 
	  FLD_DATA DATE, 
	  NUM_COMBINACAO NUMBER, 
	  VLR_TITULO_CAMPANHA FLOAT, 
	  DATA_EXPORTACAO DATE, 
	  VERSAO_ARQ_EXPORTACAO VARCHAR2(1), 
	  DAT_EXT_SORTEIO DATE, 
	  DAT_INI_VIGOR DATE, 
	  DAT_SEGURO DATE 
	) 
	ON COMMIT DELETE ROWS; 
 
End sp_tableTempComb; 
/
rafaelfrocha
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 45
Joined: Wed, 31 Oct 2007 9:30 am
Location: Uberlândia
Rafael Rocha

And if you use within your procedure:

Select all

 
execute immediate  
'CREATE GLOBAL TEMPORARY TABLE TEMP_COMBINACAO  
(  
COD_PARCEIRO INTEGER,  
COD_PLANO INTEGER,  
COD_CAMPANHA_CAP INTEGER,  
NUM_SERIE INTEGER,  
FLD_DATA DATE,  
NUM_COMBINACAO NUMBER,  
VLR_TITULO_CAMPANHA FLOAT,  
DATA_EXPORTACAO DATE,  
VERSAO_ARQ_EXPORTACAO VARCHAR2(1),  
DAT_EXT_SORTEIO DATE,  
DAT_INI_VIGOR DATE,  
DAT_SEGURO DATE  
)  
ON COMMIT DELETE ROWS'; 
Adriana Borges
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 3
Joined: Mon, 27 Jul 2009 3:53 pm
Location: Rio de Janeiro
Adriana Borges

Thanks
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

The question that does not want to shut up is:
Do you have any special reason to create a runtime table?
Adriana Borges
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 3
Joined: Mon, 27 Jul 2009 3:53 pm
Location: Rio de Janeiro
Adriana Borges

The intention is popular the temporary table at run time only.
User avatar
fsitja
Rank: OraSauro
Rank: OraSauro
Posts: 611
Joined: Mon, 19 Jan 2009 4:29 pm
Location: Gaúcho no Rio de Janeiro - RJ
"The scars exist to remind us that the past was real"
Campanha: Como fazer uma pergunta e obter uma resposta.
http://tkyte.blogspot.com/2005/06/how-t ... tions.html

OCA & OCP Developer — OCE SQL Expert — OCS Data Warehousing Specialist

You did not answer very well why. For most purposes you can use nested tables or varrays, or even a "normal" table documented in the data model. 8)
RodrigoValentim
Moderador
Moderador
Posts: 367
Joined: Tue, 25 Mar 2008 3:41 pm
Location: Salvador - BA
Rodrigo Valentim
Analista de Sistemas
Oracle Developer

Campanha: Faça uma pesquisa antes de perguntar!!!

Adriana,

One day I already had your thought but soon I saw that I was wrong ... I thought Temporary table was a memory table or something of the type ... and I thought about creating it Dynamic and etc ... but as soon as I saw the error, I went behind the information and saw that, nothing more is than a bank object that works faster by not generating archive, logs, etc ...

Create your table in Navigator running the script, forgetting this to create at run time ... After servant, you can work with it normally, giving select, update, insert, etc ... Remembering the conditions of by committee, guards the lines or delete themselves.
Remembering that the information is in this table per session!
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Or creates a global temporary table.
are extremely fast, as they do not generate Red Log, Archive, etc.
And all information is visible only for the session that included the data. No need to worry or delete the data!

This creation temporary table at run time is a large stuck in this case.
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests