DELETE

Started by c kover 17 years ago2 messagesgeneral
Jump to latest
#1c k
shreeseva.learning@gmail.com

hello,
what will be the error in syntax of following statement?

delete from accountingtransactions where
accountingtransactions.refaccdocid=docs.docid and docs.tmpselect=-1 and
docs.tmpselectedby= $1;
when a new function is created it does not gives any error but when this
function is called from outside it gives syntax error as 'missing
FROM-clause entry for table "docs"'. Why? any clue?

Regards,
CPK

#2Bill Reynolds
Bill.Reynolds@ateb.com
In reply to: c k (#1)
Re: DELETE

Add the USING list clause:

usinglist

A list of table expressions, allowing columns from other tables to
appear in the WHERE condition. This is similar to the list of tables
that can be specified in the FROM Clause
<http://www.postgresql.org/docs/8.3/static/sql-select.html#SQL-FROM&gt; of
a SELECT statement; for example, an alias for the table name can be
specified. Do not repeat the target table in the usinglist, unless you
wish to set up a self-join.

See this page for more info:

http://www.postgresql.org/docs/8.3/static/sql-delete.html

So something like this:

delete from ......... using DOCS where ..................

Full syntax description:

DELETE FROM [ ONLY ] table [ [ AS ] alias ]
[ USING usinglist ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ AS output_name ] [, ...] ]

________________________________

From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of c k
Sent: Tuesday, August 19, 2008 3:04 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] DELETE

hello,
what will be the error in syntax of following statement?

delete from accountingtransactions where
accountingtransactions.refaccdocid=docs.docid and docs.tmpselect=-1 and
docs.tmpselectedby= $1;
when a new function is created it does not gives any error but when this
function is called from outside it gives syntax error as 'missing
FROM-clause entry for table "docs"'. Why? any clue?

Regards,
CPK