[CLUE-Tech] PostgreSQL: psql dry heaves (no usable error message)

Grant Johnson grant at amadensor.com
Sat Jan 19 10:42:35 MST 2002


Jed S. Baer wrote:

>Well, psql (or Postgres) won't run this DDL, and all it tells me is it has
>a parse error at or near "" (i.e. null string). Any thoughts?
>
I found it.  The last constraint has 2 more left than right parenthesis. 
 You also need a semicolon at the end (PostgreSQL does NOTHING until it 
gets it in command line mode, and if running a file, I don't trust it 
without)

Here is my best guess at the right answer, but may change depending on 
what you really wanted.

create table job (
  id            serial
    constraint contact_pk primary key,
  company_id        int4
    constraint job_company_fk
      references company (id),
  location_id        int4
    constraint job_location_fk
      references location (id),
  person_id        int4
    constraint job_person_fk not null
      references person (id),
  perm_flag        bool not null,
  tax_type        text not null
    constraint job_tax_type_chk
      check (
        tax_type in ('W2','1099','C2C')
      ),
  rate            money,
  rate_type        text
    constraint job_rate_type_chk
      check (
        rate_type in ('hourly','monthly','annual')
      ),
  accepted_flag        bool not null,
  start_date        date,
  end_date        date,
  notes            text
  constraint job_tax_type_chk
    check
    (
        (
            perm_flag
            and
            (tax_type = 'W2')
        )
        OR
        (
            (NOT perm_flag)
            AND
            (tax_type in ('1099','C2C'))
        )
    )
)
;






More information about the clue-tech mailing list