Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Posts
    2

    Unanswered: creating a Foreign Key

    I am using DB2 version 7.
    I am trying to execute the following stmnt on the table open_select1:

    ALTER TABLE "DB2ADMIN"."OPEN_SELECT1"
    ADD CONSTRAINT "FK_FORMNO" FOREIGN KEY ("FORMNO")
    REFERENCES "DB2ADMIN"."COLL_GEN" ("FORMNO")
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    ENFORCED ENABLE QUERY OPTIMIZATION;

    for which i am getting the following error:

    The command was processed as an SQL statement because it was not a

    valid Command Line Processor command. During SQL processing it returned:

    SQL0104N An unexpected token "ENFORCED ENABLE QUERY OPTIMIZATION" was found

    following "ON UPDATE NO ACTION". Expected tokens may include: "<space>".

    SQLSTATE=42601

    Any help will be appreciated.
    Last edited by klata; 07-23-07 at 08:26.

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    It looks like you are using V8 syntax. You need to look up the V7 syntax. This might be hard, since V7 has been out of service and support for quite some time.

    Andy

  3. #3
    Join Date
    Jul 2007
    Posts
    2
    Hi Andy,
    thanks for the reply. Your reply has confirmed what i suspected. I was sure the problem was because of version mismatch. The scripts have been generated in version 8 and now i am trying to create the db in version 7 and i am stuck now because of this problem. I have also tried to take a backup of the version 8 db and restore in version 7 where again i have failed. Please suggest.

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You will have to manually edit each script to make sure that it is compatible with V7. Either that or upgrade you V7 systems to V8 or V9.

    Andy

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Restoring a V8 backup on V7 is not supported - just the other way around.

    I highly recommend that you move to V8 (better V9) because you won't get any real help (and no support from IBM) for V7 any longer.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Jan 2003
    Posts
    1,605
    Quote Originally Posted by klata
    ALTER TABLE "DB2ADMIN"."OPEN_SELECT1"
    ADD CONSTRAINT "FK_FORMNO" FOREIGN KEY ("FORMNO")
    REFERENCES "DB2ADMIN"."COLL_GEN" ("FORMNO")
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    ENFORCED ENABLE QUERY OPTIMIZATION;
    Hi,
    "Enforced enable query optimization" is not supported in v7. Why don't you use just:
    ALTER TABLE "DB2ADMIN"."OPEN_SELECT1"
    ADD CONSTRAINT "FK_FORMNO" FOREIGN KEY ("FORMNO")
    REFERENCES "DB2ADMIN"."COLL_GEN" ("FORMNO")
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
    I don't think this should be a reason for migration to newer version. This "enforced" statement is just performance string. There are a couple of other thinks that is interesting in v8 and v9 to migrate.
    Hope this helps,
    Grofaty
    Last edited by grofaty; 07-24-07 at 03:13.

Posting Permissions

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