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

Home -> Community -> Usenet -> c.d.o.misc -> Re: MSSQL TSQL to Oracle PL/SQL

Re: MSSQL TSQL to Oracle PL/SQL

From: Steffen Stellwag <Steffen.Stellwag_at_pcm.bosch.de>
Date: Mon, 10 May 1999 09:50:16 +0200
Message-ID: <37368FB8.7D00@pcm.bosch.de>


Mio-Nino P. Marquez wrote:
>
> Hi.
>
> Can somebody please give me the equivalent of these MSSQL TSQL in Oracle
> PL/SQL:
>
> DECLARE
> @TableName VarChar(30),
> @CustomerKey VarChar(20)
>
> SELECT @TableName = 'CUSTOMER'
> SELECT @CustomerKey = 'Oracle'
>
> EXECUTE('INSERT INTO ' + @TableName + ' VALUES (' + @CustomerKey +
> ')')
>
> Basically, all I wanted to do is to dynamically create the SQL
> statement, with variables replacing what's supposed to be an object
> (i.e. Table's name, Column's Name)....
>
> Please help.
>
> Thanks.
>
> Mio Marquez
> Delphi Developer

Hi,

you can pass dynmic SQl to the database using

the DBMS_SQL package which is shipped with your Database Server.

example:

declre

   v_cursor integer := dbms_sql.open_cursor;

   table_name varchar2(30)	 := 'CUSTOMER ';
   colum_string     varchar2(30) :=  'CustomerKey' ;
   values_string varchar2(30) := '12345';

begin

   dbms_sql.parse(v_cursor,'INSERT INTO '||'table_name'||' VALUES ('||column_string ||'),VALUES ('||value_string ||') ,DBMS.sql.v7);

dbms_sql.close_curosr(V_cursor);

end;

For exact syntax rule please refer to the manual.

Regards steffen Received on Mon May 10 1999 - 02:50:16 CDT

Original text of this message

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