Re: MSSQL TSQL to Oracle PL/SQL
Date: Mon, 10 May 1999 09:50:16 +0200
Message-ID: <37368FB8.7D00_at_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
> _at_TableName VarChar(30),
> _at_CustomerKey VarChar(20)
>
> SELECT _at_TableName = 'CUSTOMER'
> SELECT _at_CustomerKey = 'Oracle'
>
> EXECUTE('INSERT INTO ' + _at_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 - 09:50:16 CEST