Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Location
    Calgary, Canada
    Posts
    30

    Unanswered: Explicit cast on create table?

    hello

    i have been testing a script to create a database. I have run it several times and it worked wonderfully.

    I have started recieving this error tho:
    Code:
    psql:/home/mike/host:173: NOTICE:  CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s)
    psql:/home/mike/host:173: ERROR:  Unable to identify an operator '=' for types 'character varying' and 'numeric'
            You will have to retype this query using an explicit cast
    here is the table it is happening on. the only thing I have changed was I added the default sequence on the ID field.

    Code:
    -----------------------------------------------
    --HOST TABLE
    -----------------------------------------------
    
    DROP SEQUENCE host_id_seq;
    
    CREATE SEQUENCE host_id_seq
    INCREMENT 1
    START 1
    ;
    
    CREATE table HOST (
    ID 			numeric DEFAULT nextval('host_id_seq'),
    host_id		varchar(14) NOT NULL UNIQUE,
    IP			inet,
    port		numeric(5),
    enic		varchar(20),
    telco		varchar(5) NOT NULL,
    rate		varchar(3),
    brate		varchar(30),
    city		varchar(20),
    state		varchar(3),
    country		varchar(3),
    location	varchar(40),
    CONSTRAINT pk_host_id PRIMARY KEY(ID),
    CONSTRAINT fk_host_telco FOREIGN KEY(telco) REFERENCES telco(ID),
    CONSTRAINT fk_host_rate FOREIGN KEY(rate) REFERENCES rate(rateid),
    CONSTRAINT fk_host_brate FOREIGN KEY(brate) REFERENCES bulk_rate(brate),
    CONSTRAINT fk_host_country FOREIGN KEY (country) REFERENCES country(code),
    CONSTRAINT fk_host_state FOREIGN KEY (state) REFERENCES state(state),
    CONSTRAINT fk_host_enic FOREIGN KEY (enic) REFERENCES enic(id)
    );
    any ideas?

  2. #2
    Join Date
    Apr 2002
    Location
    Calgary, Canada
    Posts
    30
    I found my error. The Foreign key of enic(id) was referencing another sequence of a different table. So hence i was getting that error.

Posting Permissions

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