0

Learning Sql, this query returns a syntax error in Pgadmin and Sql shell says there are more entries than target yet there are 8 entries for 8 columns in my table. I've tried specifying the target columns as i've read its good practice to no avail. I'm going off of a course for this, its another random exercise, but the course is frankly useless mixes commands for psql oracle or straight up incorrect ones, basically nothing in it works as it describes. While i'm used to it can't say it helps and leaves me stuck on what's overwhelmingly likely basic syntax written wrong.

Ty for your time.

    INSERT INTO EMP(noemp, nomemp, emploi, mgr, dateemb, sal, comm, nodept)
        VALUES (
        (7369, 'SERGE', 'FONCTIONNAIRE', 7902, TO_DATE('17-DEC-1980', 'DD-MON-YYYY'), 800, NULL, 20),
        (7499, 'BRAHIM', 'VENDEUR', 7698, TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30),
        (7521, 'NASSIMA', 'VENDEUR', 7698, TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30),
        (7566, 'LUCIE', 'GESTIONNAIRE', 7839, TO_DATE('12-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20),
        (7654, 'MARTIN', 'VENDEUR', 7698, TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30),
        (7698, 'BENJAMIN', 'GESTIONNAIRE', 7839, TO_DATE('01-MAY-1981', 'DD-MON-YYYY'), 2850, NULL, 30),
        (7782, 'DAYANE', 'GESTIONNAIRE', 7839, TO_DATE('09-JUNE-1981', 'DD-MON-YYYY'), 2450, NULL, 10),
        (7788, 'ARIJ', 'ANALYSTE', 7566, TO_DATE('09-DEC-1982', 'DD-MON-YYYY'), 3050, NULL, 20),
        (7839, 'MAYAR', 'PRESIDENT', NULL, TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10),
        (7844, 'ROI', 'VENDEUR', 7698, TO_DATE('08-SEP-1981', 'DD-MON-YYYY'), 1500, 0, 30),
        (7876, 'VIRGINIE', 'FONCTIONNAIRE', 7788, TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20),
        (7900, 'LYNA', 'FONCTIONNAIRE', 7698, TO_DATE('03-DEC-1981', 'DD-MON-YYYY'), 950, NULL, 30),
        (7902, 'ASMA', 'ANALYSTE', 7566, TO_DATE('03-DEC-1981', 'DD-MON-YYYY'), 3000, NULL, 20),
        (7934, 'SIMONE', 'FONCTIONNAIRE', 7782, TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10)
  );

Edit: Adding parenthseses (which i add at some point, cf below gets) rid of line 4 error and returns line 11 error instead, same text.

Edit2: TLdr there was a typo on one month and lacked proper formatting. Ty all.

Depths
  • 29
  • 6
  • Does this answer your question? [How do I insert multiple values into a postgres table at once?](https://stackoverflow.com/questions/20815028/how-do-i-insert-multiple-values-into-a-postgres-table-at-once) – evsheino May 07 '22 at 21:12
  • Wish you could edit comment past 5 min. Deleting/rewriting as is no longer relevant. Ty for all contributors. – Depths May 07 '22 at 22:08

1 Answers1

0

I found a french month name in your SQL Code (JUIN) :

7782, ’DAYANE’, ’GESTIONNAIRE’, 7839, TO_DATE(’9-**JUIN**-1981', ’DD-MON-YYYY’), 2450, NULL, 10,

it must be remplaced by 'JUNE'.

Try to put each record between parenthesis like that :

INSERT INTO EMP(noemp, nomemp, emploi, mgr, dateemb, sal, comm, nodept)
VALUES (7369, 'SERGE', 'FONCTIONNAIRE', 7902, TO_DATE('17-DEC-1980', 'DD-MON-YYYY'), 800, NULL, 20),
(7499, 'BRAHIM', 'VENDEUR', 7698, TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30),
(7521, 'NASSIMA', 'VENDEUR', 7698, TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30),
(7566, 'LUCIE', 'GESTIONNAIRE', 7839, TO_DATE('12-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20),
(7654, 'MARTIN', 'VENDEUR', 7698, TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30),
(7698, 'BENJAMIN', 'GESTIONNAIRE', 7839, TO_DATE('01-MAY-1981', 'DD-MON-YYYY'), 2850, NULL, 30),
(7782, 'DAYANE', 'GESTIONNAIRE', 7839, TO_DATE('9-JUNE-1981', 'DD-MON-YYYY'), 2450, NULL, 10),
(7788, 'ARIJ', 'ANALYSTE', 7566, TO_DATE('09-DEC-1982', 'DD-MON-YYYY'), 3050, NULL, 20),
(7839, 'MAYAR', 'PRESIDENT', NULL, TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10),
(7844, 'ROI', 'VENDEUR', 7698, TO_DATE('08-SEP-1981', 'DD-MON-YYYY'), 1500, 0, 30),
(7876, 'VIRGINIE', 'FONCTIONNAIRE', 7788, TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20),
(7900, 'LYNA', 'FONCTIONNAIRE', 7698, TO_DATE('03-DEC-1981', 'DD-MON-YYYY'), 950, NULL, 30),
(7902, 'ASMA', 'ANALYSTE', 7566, TO_DATE('03-DEC-1981', 'DD-MON-YYYY'), 3000, NULL, 20),
(7934, 'SIMONE', 'FONCTIONNAIRE', 7782, TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10) 

You can verify it with this link

Mohamad TAGHLOBI
  • 581
  • 5
  • 11
  • Ty for catching the Month typo and for the reshaping. That being said, it must be corrected to "JUN" and not "JUNE" to respect the format. This was it anyway, ty – Depths May 07 '22 at 22:06