Re: How to turn this simple SQL-Server script into Oracle equivalent?

From: Khalid <khalidata1_at_yahoo.com>
Date: 15 Nov 2001 08:15:49 -0800
Message-ID: <55ffba59.0111150815.1ed9e37b_at_posting.google.com>


if u have oracle 8i then use the following: Declare
  c NUMBER(5);
Begin

     select count(*) 
     into   c
     from dba_ind_columns
     where table_name='dba_constraints';
     if (c = 0) then
        execute immediate 'create index ind_con on dba_constraints (table_name)';
     End if;

End;
if u have pre oracle 8i then use the following:

Declare
  c NUMBER(5);
  i number(3);
  r number(3);
Begin

     select count(*) 
     into   c
     from dba_ind_columns
     where table_name='dba_constraints';
     if (c = 0) then
        -- Dynamic SQL code using DBMS_SQL  package
           i :=dbms_sql.open_cursor;
           dbms_sql.parse(i,'create index ind_con on dba_constraints 
(table_name)', DBSM_SQL.NATIVE);
           r:=dbms_sql.execute(i);
     End if;

End;
DONLCS_at_YAHOO.COM (DL) wrote in message news:<f9e448cc.0111141413.5a4c83a1_at_posting.google.com>...
> declare _at_c int
> set _at_c = (select count(*)
> from dba_ind_columns
> where table_name='dba_constraints')
> if (_at_c=0)
> create index ind_con on dba_constraints (table_name)
>
>
> Thanks.
>
> DL
Received on Thu Nov 15 2001 - 17:15:49 CET

Original text of this message