Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2004
    Location
    Claremont, CA
    Posts
    38

    Unanswered: Creating an Oracle table within Delphi 7

    I'm trying to create an Oracle table (ORATable) in a Delphi program with the statement:

    CREATE TABLE tbDEPTCODE AS (SELECT * FROM DEPTCODE)

    but I get the error 'NOT ENOUGH ACTUAL PARAMETERS'.

  2. #2
    Join Date
    Aug 2003
    Location
    West
    Posts
    101
    I would guess that Delphi doesn't like the (Select * from .... ) and would rather you put the column name in (select col1, col2, col3 from .... )

  3. #3
    Join Date
    Jan 2004
    Location
    Claremont, CA
    Posts
    38

    Creating an Oracle Table within Delphi 7

    Thanks but I got the same error when I included the column names in

    CREATE TABLE tbProj$$ AS (SELECT DEPT_CD, DEPARTMENT FROM
    DEPTCODE);

  4. #4
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    I don't know how you're connecting to Oracle, but probably through ADO/DbExpress or some other ODBC type connection?

    If so, these drivers aim to provide generic connectivity - as such, that Oracle specific syntax *might* not be supported.

    Change your command to ....
    Code:
    begin
       create table (... you know the rest... );
    end;
    
    Query.Sql.Text := 'begin create table....; end;';
    Query.Execute;
    This becomes unrecognisable to your driver, and should be passed straight on to Oracle for it to deal with. (You might have to put some carriage return/line feeds into the actual statement.
    Code:
    Query.Sql.Clear;
    Query.Sql.Add( 'begin' );
    Query.Sql.Add( 'create. etc ');
    Oh the joys of interoperabilty :-)

    Hth
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  5. #5
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Quote Originally Posted by acabrera
    Thanks but I got the same error when I included the column names in

    CREATE TABLE tbProj$$ AS (SELECT DEPT_CD, DEPARTMENT FROM
    DEPTCODE);
    Also, you should NOT create tables with lowercase characters, it causes access problems later. Oracle always pushes objects to uppercase unless they are incloused in quotes. Make your statement.
    CREATE TABLE TBPROJ$$ AS (SELECT DEPT_CD, DEPARTMENT FROM DEPTCODE);
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  6. #6
    Join Date
    Jan 2004
    Location
    Claremont, CA
    Posts
    38

    Creating an Oracle Table within Delphi 7

    In Delphi 7, I'm using ODAC instead of BDE and below is the code based on your suggestion:

    with OraQuery do
    begin
    SQL.Clear;
    // SQL.Add('BEGIN');
    SQL.Add('CREATE TABLE TBPROJ$$ AS (SELECT * FROM DEPTCODE)');
    // SQL.Add('END');
    Execute;
    end;
    OraTable.Open;

    Initially, when the BEGIN and END statements were not commented, the error was 'Encountered the symbol "CREATE" when expecting one of the following: begin case declare exit ...'

    When I commented the two statements, my table got created. Thanks a lot.

  7. #7
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi,

    Sorry - the begin/end syntax I gave you wasn't valid for Oracle "create table"

    I don't quite understand how it is doing it, but your commented version is making it past ODAC. This is strange as ODAC is an Oracle specific driver.

    Glad its working anyway - even if I'm not sure how

    Cheers
    Bill
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

  8. #8
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    I believe that the inclusion of BEGIN ... END; is interpreted to be PL/SQL.
    In PL/SQL DDL is not directly allowed.
    to prove my hypothesis, run with BEGIN EXECUTE IMMEDIATE CREATE TABLE... END;

    or just accept that it works & move on to the next challenge
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  9. #9
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Yes, as I said, it isn't valid syntax.
    Please don't email me directly with questions. I've probably just got home from the pub and cannot guarantee the sanity of my answers. In fact, I can't believe I actually made it home.

Posting Permissions

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