public inbox for [email protected]  
help / color / mirror / Atom feed
Help with syntax error
3+ messages / 3 participants
[nested] [flat]

* Help with syntax error
@ 2024-12-02 00:14 Arbol One <[email protected]>
  2024-12-02 00:17 ` Re: Help with syntax error Adrian Klaver <[email protected]>
  2024-12-02 00:18 ` Re: Help with syntax error Ron Johnson <[email protected]>
  0 siblings, 2 replies; 3+ messages in thread

From: Arbol One @ 2024-12-02 00:14 UTC (permalink / raw)
  To: pgsql-general

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()/*

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 [ í ]

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Help with syntax error
  2024-12-02 00:14 Help with syntax error Arbol One <[email protected]>
@ 2024-12-02 00:17 ` Adrian Klaver <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Adrian Klaver @ 2024-12-02 00:17 UTC (permalink / raw)
  To: Arbol One <[email protected]>; 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
[email protected]







^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Help with syntax error
  2024-12-02 00:14 Help with syntax error Arbol One <[email protected]>
@ 2024-12-02 00:18 ` Ron Johnson <[email protected]>
  1 sibling, 0 replies; 3+ messages in thread

From: Ron Johnson @ 2024-12-02 00:18 UTC (permalink / raw)
  To: pgsql-general

On Sun, Dec 1, 2024 at 7:14 PM Arbol One <[email protected]> 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()*
>
> 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?
>

What happens when you run those INSERT commands directly in psql?

Hint: it's probably going to complain about a syntax error in the second
INSERT statement.

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2024-12-02 00:18 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-12-02 00:14 Help with syntax error Arbol One <[email protected]>
2024-12-02 00:17 ` Adrian Klaver <[email protected]>
2024-12-02 00:18 ` Ron Johnson <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox