Re: Help with syntax error

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Arbol One <ArbolOne(at)hotmail(dot)ca>, PostGreSQL MailingList <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help with syntax error
Date: 2024-12-02 00:17:37
Message-ID: fd23dc4e-cb98-48d7-b122-e391891431a4@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 12/1/24 16:14, Arbol One wrote:
> I have these tables:
>
> *CREATE TABLE IF NOT EXISTS registrar (
> index SERIAL,
> registrar_id TEXT,
> day TEXT NOT NULL,
> month TEXT NOT NULL,
> year TEXT NOT NULL,
> hour TEXT NOT NULL,
> minute TEXT NOT NULL,
> second TEXT NOT NULL,
> millisecond TEXT NOT NULL,
> am_pm TEXT NOT NULL,
> admin BOOLEAN NOT NULL DEFAULT false,
> CONSTRAINT key PRIMARY KEY (registrar_id) );
>
> CREATE TABLE IF NOT EXISTS user_name (
> user_name_id TEXT PRIMARY KEY REFERENCES registrar(registrar_id),
> first_name TEXT NOT NULL,
> middle_name TEXT NOT NULL,
> last_name TEXT NOT NULL);*
>
> When I enter the following pg commands :
>
> *INSERT INTO registrar VALUES (DEFAULT, '18551420601012L23', '1', '12',
> '2024', '18', '55', '14', '207', 'PM');
> INSERT INTO user_name '18551420601012L23', 'John', 'Fitzgerald',
> 'Kennedy'); <= **/UserNameTable.write()/*
>

You don't see the difference between the first and second statements.

Hint, it starts with V.

> I get this message :
>
> */Exception in thread "main" java.sql.SQLException: In
> company.contact.Company$UserNameTable.write()
> ERROR: syntax error at or near "'18551420601012L23'"
>   Position: 23/
> *
>
> The error is in the user_name_id, which is a primary that references the
> table "*registrar*" 's "*registrar_id" *primary key.
> According to the documentation
> <https://www.postgresql.org/docs/current/tutorial-fk.html>, the
> insertion should be OK, no?
>
> What am I doing wrong?
>
>
> --
> */ArbolOne ™/*
> Using Fire Fox and Thunderbird.
> ArbolOne is composed of students and volunteers dedicated to providing
> free services to charitable organizations.
> ArbolOne's development on Java, PostgreSQL, HTML and Jakarta EE is in
> progress [ í ]

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2024-12-02 00:18:36 Re: Help with syntax error
Previous Message Arbol One 2024-12-02 00:14:04 Help with syntax error