Re: Deletion

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Deletion
Date: 2014-08-27 17:23:22
Message-ID: 1409160202953-5816617.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ramesh T wrote
> Hi,
> I have deletion script to delete particular cust from
> database.I was
> saved a file name with custde.sql.i need to run from command line like
> putty tool..But have a problem
>
> example :
>
> delete from part where part.custid=$1;
>
> when i ran custde.sql from putty tool
>
> db=#\i custde.sql
>
> it's return error
> psql:custde.sql:9: ERROR: there is no parameter $1
> LINE 1: ..._ID from part where part.CUST_ID = $1);
>
> please let me know how to run script ..and how to give parameter..

psql doesn't use parameters - it uses variables.

http://www.postgresql.org/docs/9.3/interactive/app-psql.html

In part <and not tested>:

echo "DELETE FROM part WHERE part.CUST_ID = :'del_id';" > custde.sql
psql --set=del_id=383373 --file=custde.sql

Note that based on your prompt (db=#) and the command "\i" you are already
using psql interactively. This not the same thing as "I need to run from
command line like putty tool".

Beyond this you need to learn about shell scripting to more readily
integrate psql into a complex process.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Deletion-tp5816588p5816617.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

  • Deletion at 2014-08-27 09:52:18 from Ramesh T

Browse pgsql-general by date

  From Date Subject
Next Message Dennis 2014-08-27 18:02:28 query does not return after increasing range in 'between' clause
Previous Message Adrian Klaver 2014-08-27 17:08:02 Re: Deletion