Subject Re: [firebird-support] Isql and add constaint...
Author Helen Borrie
At 11:42 PM 27/07/2004 +0200, you wrote:
>I'm getting some strange errors while using isql for initial db-setup.
>Here is what I do:
>isql.exe C:\hberp.fdb -i C:\create_db.sql -u SYSDBA -p masterkey
>The create_db.sql looks like this:
>CREATE DATABASE 'C:\hberp.fdb' page_size 8192 user 'SYSDBA' password
>Strange thing here, the database was created correctly, and I get this
>Statement failed, SQLCODE = -902
>I/O error for file "C:\HBERP.FDB"
>-Error while trying to open file
>-The system cannot find the file specified.
>Use CONNECT or CREATE DATABASE to specify a database
>But if the command is done in the isql shell, no error messages.
>Same thing if I do the initial DDL's,
>but here some statements do not work at all via the commandline + script
>approach. Like this:
>Again, the lines below are in an external file and I call isql with the
>"-i" option.
>Create Table "COUNTRY" (
> "COUNTRY_ID" Varchar(5) NOT NULL,
> "NAME" Varchar(60),
>Constraint "pk_COUNTRY" Primary Key ("COUNTRY_ID")
>Create Table "ADDRESS" (
> "STREET1" Varchar(120),
> "STREET2" Varchar(120),
> "CITY" Varchar(80),
> "PLZ" Varchar(8),
> "COUNTRY_ID" Varchar(5) NOT NULL,
>Constraint "pk_ADDRESS" Primary Key ("ADDRESS_ID")
>Alter Table "ADDRESS" add Constraint "Relationship16" Foreign Key
>("COUNTRY_ID") references "COUNTRY" ("COUNTRY_ID") on update no action
>on delete no action ;
>I get this message:
>unsuccessful metadata update
>-Table column not found
>Statement failed, SQLCODE = -607
>But sending this commands within the isql shell it works.
>Any ideas ?
>What Im basically trying to do, is to have one batch which does the
>whole basic setup. Any other way to do this.

Yes. Your problem is that you are not committing the DDL statements before
issuing further statements that depend on them.

By default, the isql interactive shell autocommits each DDL statement. To
have your script behave like the isql shell's default setting, include this
statement at the beginning of your script:


Alternatively, include explicit COMMIT statements in the script.