Topic
4 replies Latest Post - ‏2010-03-05T03:05:18Z by weid502
wakeboarder3780
wakeboarder3780
6 Posts
ACCEPTED ANSWER

Pinned topic Derby PK auto-increment woes

‏2009-03-23T18:48:32Z |
I have tried the example stated in the documentation and the one I found on another post. The following scripts works:


CREATE TABLE MAPS2 ( MAP_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), MAP_NAME VARCHAR(24) NOT NULL, REGION VARCHAR(26), AREA DECIMAL(8,4) NOT NULL, PHOTO_FORMAT VARCHAR(26) NOT NULL, PICTURE BLOB(102400), CONSTRAINT Map2AutoPK PRIMARY KEY (MAP_ID) ) ;


When I try to apply this to a custom example I get shut down over and over again. I cannot figure out what the problem is. Below is what I am trying.

CREATE TABLE AUTHOR ( ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), FIRST VARCHAR(30) NOT NULL, MIDDLE VARCHAR(30), LAST VARCHAR(30) NOT NULL, CONSTRAINT AuthorAutoPK PRIMARY KEY (ID) ) ;


The following error pops out:


ERROR 42X01: Syntax error: Encountered 
"FIRST" at line 5, column 1.

What in the world am I doing wrong?
Updated on 2010-03-05T03:05:18Z at 2010-03-05T03:05:18Z by weid502
  • wakeboarder3780
    wakeboarder3780
    6 Posts
    ACCEPTED ANSWER

    Re: Derby PK auto-increment woes

    ‏2009-03-23T18:57:15Z  in response to wakeboarder3780
    yet this example works just fine. I seriously am starting to question my sanity:

    
    CREATE TABLE AUTHOR ( ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), MIDDLE VARCHAR(30), CONSTRAINT AuthorAutoPK PRIMARY KEY (ID) ) ;
    
    • wakeboarder3780
      wakeboarder3780
      6 Posts
      ACCEPTED ANSWER

      Re: Derby PK auto-increment woes

      ‏2009-03-23T19:14:03Z  in response to wakeboarder3780
      first and last are reserved keywords:
      http://db.apache.org/derby/docs/10.1/ref/rrefkeywords29722.html

      The following script will work:

      
      create table AUTHOR ( ID INTEGER NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY (START WITH 100), 
      "FIRST" VARCHAR(30), MIDDLE VARCHAR(30), 
      "LAST" VARCHAR(30) );
      
  • weid502
    weid502
    1 Post
    ACCEPTED ANSWER

    Re: Derby PK auto-increment woes

    ‏2010-03-05T03:05:18Z  in response to wakeboarder3780
    Mac DVD Copy is definitely the simplest solution to copy and backup DVD movie on Mac. With Mac DVD Copy, you own the most efficient way to create backup copies of your DVD movie collection. copy DVD on Mac perfectly in 1:1 ratio, or to compress DVD9 to DVD5 disc is pretty steady, fast and easy. Mac DVD Cloner is a great tool which allows you to make a backup copy of a DVD movies that you own. With Mac DVD Cloner, you can copy DVD movie to DVD R/RW disc on Mac, directly burn to the target disc makes it really quick and easy to create DVD copies and backups.