Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: CREATE TABLE in procedure?

Re: CREATE TABLE in procedure?

From: Roger G. <rgorden_at_my-deja.com>
Date: 2000/01/28
Message-ID: <86t4l5$sfd$1@nnrp1.deja.com>

Alan;

You cannot do any DDL (create table etc.) statements in a PL/SQL procedure, or any PL/SQL block.
There are 2 ways around this.

1- Create a table in SQLPLUS using simple commands and delete the

   table when you're through

        -or-
2- Declare a PL/SQL table datatype and use this in your procedure.

   (The advantage to this is that hte PL/SQL table lives only while the    procedure is being run and takes up no permanent space on the    database).

I hope this helps.

Roger

In article <86oqp7$25pg$3_at_dolf.netfront.net>,   "M. Armaghan Saqib" <armaghan_at_yahoo.com> wrote:
> This is a multi-part message in MIME format.
>
> ------=_NextPart_000_0076_01BF64EE.A5B43CF0
> Content-Type: text/plain;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> My 2 cents:
>
> My SQL PlusPlus (freeware) makes using DBMS_SQL very easy. It
 generates =
> all the PLSQL code required to WRAP an SQL statement before executing.
>
> regards,
> M. Armaghan Saqib
> +---------------------------------------------------------------
> | 1. SQL PlusPlus =3D> Add power to SQL Plus command line
> | 2. SQL Link for XL =3D> Integrate Oracle with XL
> | 3. Oracle CBT with sample GL Accounting System
> | Download free: http://www.geocities.com/armaghan/
> +---------------------------------------------------------------
> Sybrand Bakker <postmaster_at_sybrandb.demon.nl> wrote in message =
> news:948435085.4842.0.pluto.d4ee154e_at_news.demon.nl...
> This same question was answered yesterday.
> Use the dbms_sql package (v7)
> Use execute immediate (v8)
>
> Hth,
>
> --=20
> Sybrand Bakker, Oracle DBA
> Alan Hong <hongshi_at_fuse.net> wrote in message =
> news:s8fhhcjseh670_at_corp.supernews.com...
> Hi,
>
> Can I put the "create table temp1 as select .... from .... where =
> ....." into
> a stored procedure/function on the server??
>
> I got the error when I was trying to do this:
>
> PLS-00103: Encountered the symbol "CREATE" when expecting one of
 the
> following:
>
> begin declare end exception exit for goto if loop mod null
> pragma raise return select update while <an identifier
>
> Is it possible to put 'CREATE table....' in a procedure?
>
> Any idea/help will be greatly appreciated!!
>
> Dana
> dan_jian_at_hotmail.com
>
> Andreas Michler <Andreas.Michler_at_adicom.de> wrote in message
> news:3887301D.38E238D0_at_adicom.de...
> > I think you mean temp-tables.
> > In this way oracle doesn't have any temp Tables.
> > You can do it in the following way
> > create table temp1 as select .... from .... where .....,;
> > create table temp2 as select .... from .... where ....;
> >
> > Don't forget to drop the table temp1,temp2,,,, manually. The
 will =
> not be
> > droppped automatically.
> >
> >
> > Dana Jian wrote:
> >
> > > Hi,
> > >
> > > I'm converting one procedure from SQL server to Oracle =
> procedure.
> > >
> > > Here's the simplified statements in the SQL proc,
> > >
> > > SELECT ... INTO #temp1 FROM....WHERE..
> > >
> > > SELECT ... INTO #temp2 FROM... WHERE
> > >
> > > SELECT ... FROM #temp1, #temp2 , .... WHERE ...
> > >
> > > How to do this in Oracle PL/SQL?
> > >
> > > Any comments/help will be highly appreciated!!
> > >
> > > Dana
> > > djian_at_trasa.com
> >
> > --
> > -------------------------------------
> > ADICOM Informatik GmbH
> > Andreas Michler
> > Wiesfleckenstr. 34
> > 72336 Balingen
> > Tel: 07433/9977-57,Fax: -90
> > E-Mail: Andreas.Michler_at_adicom.de
> > http:\\www.adicom.de
> > -------------------------------------
> >
> >
>
> ------=_NextPart_000_0076_01BF64EE.A5B43CF0
> Content-Type: text/html;
> charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META content=3D"text/html; charset=3Diso-8859-1" =
> http-equiv=3DContent-Type>
> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT face=3D"Courier New" size=3D2>My 2 cents:</FONT></DIV>
> <DIV>&nbsp;</DIV>
> <DIV><FONT face=3D"Courier New" size=3D2>My SQL PlusPlus (freeware) =
> makes using=20
> DBMS_SQL very easy. It generates all the PLSQL code required to WRAP
 an =
> SQL=20
> statement before executing.</FONT></DIV>
> <DIV><BR>regards,<BR>M. Armaghan=20
>

Saqib<BR>+--------------------------------------------------------------
-=
> <BR>|=20
> 1. SQL PlusPlus =3D&gt; Add power to SQL Plus command line<BR>| 2. SQL
 =
> Link for XL=20
> =3D&gt; Integrate Oracle with XL<BR>| 3. Oracle CBT with sample GL =
> Accounting=20
> System<BR>| Download free: <A=20
>

href=3D"http://www.geocities.com/armaghan/">http://www.geocities.com/arm a=
>
ghan/</A><BR>+----------------------------------------------------------
-=
> ----</DIV>
> <BLOCKQUOTE=20
> style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px;
 MARGIN-RIGHT: =
> 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
> <DIV>Sybrand Bakker &lt;<A=20
> =
>

href=3D"mailto:postmaster_at_sybrandb.demon.nl">postmaster_at_sybrandb.demon.n l=
> </A>&gt;=20
> wrote in message <A=20
> =
>

href=3D"news:948435085.4842.0.pluto.d4ee154e_at_news.demon.nl">news:9484350 8=
> 5.4842.0.pluto.d4ee154e_at_news.demon.nl</A>...</DIV>
> <DIV><FONT face=3DArial size=3D2>This same question was answered=20
> yesterday.</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>Use the dbms_sql package =
> (v7)</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>Use execute immediate =
> (v8)</FONT></DIV>
> <DIV>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2>Hth,</FONT></DIV>
> <DIV><BR>-- <BR>Sybrand Bakker, Oracle DBA</DIV>
> <BLOCKQUOTE=20
> style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; =
> MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
> <DIV>Alan Hong &lt;<A=20
> href=3D"mailto:hongshi_at_fuse.net">hongshi_at_fuse.net</A>&gt; wrote in
 =
> message <A=20
> =
>

href=3D"news:s8fhhcjseh670_at_corp.supernews.com">news:s8fhhcjseh670_at_corp.s u=
> pernews.com</A>...</DIV>
> <DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
> <DIV>&nbsp;</DIV>
> <DIV><FONT face=3DArial size=3D2>Can I put the "create table temp1
 =
> as select=20
> .... from .... where ....." into<BR>a stored procedure/function on
 =
> the=20
> server??<BR></FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>I got the error when I was trying
 =
> to do=20
> this:<BR><BR>PLS-00103: Encountered the symbol "CREATE" when =
> expecting one=20
> of the<BR>following:<BR><BR>&nbsp;&nbsp; begin declare end
 exception =
> exit=20
> for goto if loop mod null<BR>&nbsp;&nbsp; pragma raise return
 select =
> update=20
> while &lt;an identifier<BR></FONT></DIV>
> <DIV><FONT face=3DArial size=3D2>Is it possible to put 'CREATE =
> table....' in a=20
> procedure?</FONT></DIV>
> <DIV><FONT face=3DArial size=3D2><BR>Any idea/help will be
 greatly=20
> appreciated!!<BR><BR>Dana<BR><A=20
> =
>

href=3D"mailto:dan_jian_at_hotmail.com">dan_jian_at_hotmail.com</A><BR><BR>And r=
> eas=20
> Michler &lt;<A=20
> =
>

href=3D"mailto:Andreas.Michler_at_adicom.de">Andreas.Michler_at_adicom.de</A>& g=
> t;=20
> wrote in message<BR><A=20
> =
>

href=3D"news:3887301D.38E238D0_at_adicom.de">news:3887301D.38E238D0_at_adicom. d=
> e</A>...<BR>&gt;=20
> I think you mean temp-tables.<BR>&gt; In this way oracle doesn't =
> have any=20
> temp Tables.<BR>&gt; You can do it in the following way<BR>&gt; =
> create table=20
> temp1 as select .... from .... where .....,;<BR>&gt; create table
 =
> temp2 as=20
> select .... from .... where ....;<BR>&gt;<BR>&gt; Don't forget to
 =
> drop the=20
> table temp1,temp2,,,, manually. The will not be<BR>&gt;
 droppped=20
> automatically.<BR>&gt;<BR>&gt;<BR>&gt; Dana Jian =
> wrote:<BR>&gt;<BR>&gt; &gt;=20
> Hi,<BR>&gt; &gt;<BR>&gt; &gt; I'm converting one procedure from
 SQL =
> server=20
> to Oracle procedure.<BR>&gt; &gt;<BR>&gt; &gt; Here's the
 simplified =
>
> statements in the SQL proc,<BR>&gt; &gt;<BR>&gt; &gt; SELECT ... =
> INTO #temp1=20
> FROM....WHERE..<BR>&gt; &gt;<BR>&gt; &gt; SELECT ... INTO #temp2 =
> FROM...=20
> WHERE<BR>&gt; &gt;<BR>&gt; &gt; SELECT ... FROM #temp1, #temp2 , =
> .... WHERE=20
> ...<BR>&gt; &gt;<BR>&gt; &gt; How to do this in Oracle =
> PL/SQL?<BR>&gt;=20
> &gt;<BR>&gt; &gt; Any comments/help will be highly =
> appreciated!!<BR>&gt;=20
> &gt;<BR>&gt; &gt; Dana<BR>&gt; &gt; <A=20
>

 href=3D"mailto:djian_at_trasa.com">djian_at_trasa.com</A><BR>&gt;<BR>&gt; =
> --<BR>&gt;=20
> -------------------------------------<BR>&gt; ADICOM Informatik =
> GmbH<BR>&gt;=20
> Andreas Michler<BR>&gt; Wiesfleckenstr. 34<BR>&gt; 72336 =
> Balingen<BR>&gt;=20
> Tel: 07433/9977-57,Fax: -90<BR>&gt; E-Mail: <A=20
> =
>

href=3D"mailto:Andreas.Michler_at_adicom.de">Andreas.Michler_at_adicom.de</A>< B=
> R>&gt;=20
> http:\\www.adicom.de<BR>&gt;=20
> =
>
-------------------------------------<BR>&gt;<BR>&gt;<BR><BR></DIV></BLO
C=
> KQUOTE></BLOCKQUOTE></FONT></BODY></HTML>
>
> ------=_NextPart_000_0076_01BF64EE.A5B43CF0--
>
> ------
> Posted via news://freenews.netfront.net
> Complaints to news_at_netfront.net
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Jan 28 2000 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US