Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:34:40+00:00 2026-05-28T04:34:40+00:00

In Oracle, we do this: def TNAME=&1 create table &TNAME (foo varchar(10)); How to

  • 0

In Oracle, we do this:

def TNAME=&1
create table &TNAME (foo varchar(10));

How to do the equivalent for DB2? The constraints are:

1. The create table statement is generated when TNAME is unknown
2. The create table statement is in a file which cannot be modified
3. Cannot create a temporary file with TNAME substituted by awk
4. Essentially we want to pass in the table name at run time as an argument

Possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:34:40+00:00Added an answer on May 28, 2026 at 4:34 am

    The EXECUTE IMMEDIATE statement can be used in just about any block of SQL that is surrounded by a BEGIN and END, such as a stored procedure or anonymous compound statement.

    CREATE PROCEDURE create_table_from_file( IN fileDir VARCHAR( 1024 ), 
                                             IN fileName VARCHAR( 128 ),
                                             IN tabSchema VARCHAR( 128 ),
                                             IN tabName VARCHAR( 128 )
                                            )
    BEGIN
    DECLARE fh UTL_FILE.FILE_TYPE;
    DECLARE sqlStmt VARCHAR( 32672 );
    DECLARE currentLine VARCHAR( 32672 );
    DECLARE SQLCODE INTEGER DEFAULT 0;
    DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
    DECLARE SQLSTATE1 CHAR(5) DEFAULT '00000';
    DECLARE CONTINUE HANDLER FOR SQLSTATE 'ORANF' SET SQLSTATE1 = SQLSTATE;
    
    SET sqlStmt = 'CREATE TABLE ' 
        || CASE WHEN ( NULLIF( tabSchema, '' ) IS NOT NULL ) 
           THEN RTRIM( tabSchema ) || '.'
           ELSE '' END || tabName;
    CALL UTL_DIR.CREATE_OR_REPLACE_DIRECTORY( 'createTablePath', fileDir );
    SET fh = UTL_FILE.FOPEN( 'createTablePath', fileName, 'r' );
    loop1: LOOP
        CALL UTL_FILE.GET_LINE( fh, currentLine );
        IF SQLSTATE1 = 'ORANF' THEN -- NO DATA FOUND
            LEAVE loop1;
        END IF;
        SET sqlStmt = sqlStmt || ' ' || currentLine ;
    END LOOP;
    EXECUTE IMMEDIATE sqlStmt;
    END
    @
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table like this (Oracle, 10) Account Bookdate Amount 1 20080101 100
I have this table in an Oracle DB which has a primary key defined
When I try to execute this statement in Oracle SQL Developer 2.1 a dialog
I have stored-procedure in Oracle database like this: create or replace PROCEDURE EDYTUJ_PRACOWNIKA (PR_IMIE
I have two tables like this create table A_DUMMY ( TRADE_ID VARCHAR2(16) TRADE_DATA VARCHAR2(500)
My python application is dying, this oracle trace file is being generated. I am
i want to create unique constraints in table for 7 columns, so when someone
Could this Oracle query: select * from table(some_stored_procedure(someParameter => :someValue) be transformed into LINQ?
Oracle has this concept of allowing database users to be identified by the operating
Asking for your help on this Oracle query. It's giving me the error 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.