Обсуждение: Insert into sintax
Hello list,
Could anyone point me the rigth way to write this query:
INSERT INTO ped_cam
(SELECT * from ped_pro where ped_pk=lnpedpk)
WHERE NOT EXISTS (SELECT ped_pk FROM ped_cam
WHERE ped_pk=lnpedpk);
I got this:
ERROR: syntax error at or near "WHERE" at character 63
Thanks,
--
Sinceramente,
Josué Maldonado.
"¿Porqué es tan difícil <querer>, mientras es tan fácil <desear>? Porque
en el deseo se expresa la impotencia, y en el querer, la fuerza. "
Josué Maldonado <josue@lamundial.hn> writes: > Hello list, > > Could anyone point me the rigth way to write this query: > > INSERT INTO ped_cam > (SELECT * from ped_pro where ped_pk=lnpedpk) > WHERE NOT EXISTS (SELECT ped_pk FROM ped_cam > WHERE ped_pk=lnpedpk); > > I got this: > ERROR: syntax error at or near "WHERE" at character 63 You've misparenthesized. -Doug -- Let us cross over the river, and rest under the shade of the trees. --T. J. Jackson, 1863
What table is lnpedpk in - ped_cam? What table is ped_pk in - ped_pro and ped_cam?
-----Original Message-----
From: Josué Maldonado [mailto:josue@lamundial.hn]
Sent: Thursday, August 05, 2004 3:50 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Insert into sintax
Hello list,
Could anyone point me the rigth way to write this query:
INSERT INTO ped_cam
(SELECT * from ped_pro where ped_pk=lnpedpk)
WHERE NOT EXISTS (SELECT ped_pk FROM ped_cam
WHERE ped_pk=lnpedpk);
I got this:
ERROR: syntax error at or near "WHERE" at character 63
Thanks,
--
Sinceramente,
Josué Maldonado.
"¿Porqué es tan difícil <querer>, mientras es tan fácil <desear>? Porque
en el deseo se expresa la impotencia, y en el querer, la fuerza. "
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Duane,
El 05/08/2004 5:29 PM, Duane Lee - EGOVX en su mensaje escribio:
> What table is lnpedpk in - ped_cam? What table is ped_pk in - ped_pro and
> ped_cam?
lnPedPk is parameter pased to the function and it could be a fixed value
on the sql console too, ped_pk is common in both tables, I changed the
code to this and still get the same error
INSERT INTO ped_cam
(SELECT * from ped_pro where ped_pro.ped_pk=81178)
WHERE NOT EXISTS
(SELECT 1 FROM ped_cam WHERE ped_cam.ped_pk=81178);
Thanks,
--
Sinceramente,
Josué Maldonado.
"Deja que los perros ladren, Sancho, es señal que caminamos." -- Miguel
de Cervantes Saavedra.