You probably need keyword "foreign key" right after "constraint xfgusuario"
and before
"references".

Jiang





Villa Horacio <[EMAIL PROTECTED]> on 07/06/2001 12:47:20 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:    (bcc: Jiang Tong/mbsgroup/CDG)
Subject:  DB2EUG: Create table failing





Hi,
I get an error running the following script:

CREATE TABLE cd_actas (
     cdcaja              CHAR(10) NOT NULL,
     cdnro               CHAR(8) NOT NULL,
     cdfechagrabado      DATE NOT NULL,
     cdfechaingreso      TIMESTAMP NOT NULL,
     constraint xpkcd_actas primary key (cdnro),
     constraint xak1cd_actas unique (cdcaja, cdnro))
    data capture none
    in userspace1;

CREATE TABLE grupo (
     grpcod              CHAR(8) NOT NULL,
     grpdes              VARCHAR(35) NOT NULL,
     constraint xpkgrupo primary key (grpcod))
    data capture none
    in userspace1;

CREATE TABLE usuario (
     usucod              VARCHAR(15) NOT NULL,
     usudes              VARCHAR(35) NOT NULL,
     usupwd              VARCHAR(15) NOT NULL,
     grpcod              CHAR(8) NOT NULL,
     constraint xpkusuario primary key (usucod),
     constraint xfgusuario references grupo (grpcod)
          on delete restrict
          on update no action)
    data capture none
    in userspace1;

CREATE TABLE acta (
     actcod              CHAR(10) NOT NULL,
     acttipo             CHAR(1) NOT NULL,
     actfmtimagen        CHAR(3) NOT NULL,
     cdnro               CHAR(8) NOT NULL,
     actimagen           BLOB(128K) NOT NULL not logged not compact,

     constraint xpkacta primary key (actcod),
     constraint xak1acta unique (cdnro, actcod),
     constraint xfg1acta references cd_actas (cdnro)
          on delete restrict
          on update no action)
    data capture none
    in userspace2
    index in userspace2
    long in longspace1;

The first two create tables go well, but the 3rd. & 4th. are in error. Why?

06/07/2001 14:38:02 CREATE TABLE usuario ( usucod              VARCHAR(15)
NOT NULL, usudes              VARCHAR(35) NOT NULL, usupwd
VARCHAR(15) NOT NULL, grpcod              CHAR(8) NOT NULL, constraint
xpkusuario primary key (usucod), constraint xfgusuario references grupo
(grpcod) on delete restrict on update no action) data capture none in
userspace1
06/07/2001 14:38:02 DB21034E  The command was processed as an SQL statement
because it was not a valid Command Line Processor command.  During SQL
processing it returned:
06/07/2001 14:38:02 SQL0104N  An unexpected token "constraint" was found
following "rimary key (usucod),".  Expected tokens may include:
"<col_name>".  SQLSTATE=42601

06/07/2001 14:38:02 CREATE TABLE acta ( actcod              CHAR(10) NOT
NULL, acttipo             CHAR(1) NOT NULL, actfmtimagen        CHAR(3) NOT
NULL, cdnro               CHAR(8) NOT NULL, actimagen           BLOB(128K)
NOT NULL not logged not compact, constraint xpkacta primary key (actcod),
constraint xak1acta unique (cdnro, actcod), constraint xfg1acta references
cd_actas (cdnro) on delete restrict on update no action) data capture none
in userspace2 index in userspace2 long in longspace1
06/07/2001 14:38:02 DB21034E  The command was processed as an SQL statement
because it was not a valid Command Line Processor command.  During SQL
processing it returned:
06/07/2001 14:38:02 SQL0104N  An unexpected token "constraint" was found
following "que (cdnro, actcod),".  Expected tokens may include:
"<col_name>".  SQLSTATE=42601

TIA
Horacio Villa

=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see
http://people.mn.mediaone.net/scottrmcleod








=====
To unsubscribe, send 'unsubscribe' to [EMAIL PROTECTED]
For other info (and scripts), see http://people.mn.mediaone.net/scottrmcleod

Reply via email to