Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2003
    Location
    Portugal
    Posts
    21

    Unanswered: <include...> in a sql script??

    Hi,

    Is it possible to have an include statement (similiar to c) in a sql scripte that creates tables for example?

    Thanks

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: <include...> in a sql script??

    Originally posted by Carla.Michelle
    Hi,

    Is it possible to have an include statement (similiar to c) in a sql scripte that creates tables for example?

    Thanks
    You can use @filename or @@filename. Use @@ within scripts to specify another script in the same folder as the script, or @ to specify a full path or the default path.

    For example:

    File1.sql:
    create table t1 (...);

    File2.sql:
    create table t2 (...);

    Batch.sql:
    @@file1
    @@file2

  3. #3
    Join Date
    Feb 2003
    Location
    Portugal
    Posts
    21
    Thanks a ton!
    Works great!

  4. #4
    Join Date
    Apr 2002
    Location
    California, USA
    Posts
    482

    Smile

    You can use Dynamic SQL to do that as well. Simple use EXCUTE IMMEDIATE and wrap your DDL in single quotes, eg.

    SQL> begin
    2 execute immediate 'CREATE TABLE test (id number)';
    3 end;
    4 /

    PL/SQL procedure successfully completed.

    SQL> desc test
    Name Null? Type
    ----------------------------------------- -------- ---------
    ID NUMBER

    SQL>


    Hope that helps,

    clio_usa - OCP - DBA


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •