Re: Deletion

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Ramesh T <rameshparnanditech(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Deletion
Date: 2014-08-27 19:22:12
Message-ID: CAFj8pRDzrPi7+HOnggOZO6XyUauyBxeSr8YuN5JN9Af_KHBFQA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

psql variables has different format and its is not directly related to psql
options. But you can do:

[pavel(at)localhost ~]$ psql postgres --set=myproname=upper
psql (9.5devel)
Type "help" for help.

postgres=# select proname, prosrc from pg_proc where proname = :'myproname';
proname | prosrc
---------+-------------
upper | upper
upper | range_upper
(2 rows)

postgres=# \echo :proname :"proname" :'proname'
:proname :"proname" :'proname'

psql with enforces correct escaping

Regards

Pavel

2014-08-27 20:59 GMT+02:00 Ramesh T <rameshparnanditech(at)gmail(dot)com>:

>
> In oracle I ran the deletion script to clean up the particular database
> using custid.custid is the parameter .&&1 is used in the oracle Inthe same
> way tried but $1 not possible ?but using function is possible is their any
> problem with fun to Clean the database I have 100 statements in script ...
> On Wednesday, August 27, 2014, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
> wrote:
>
>> On 08/27/2014 08:24 AM, Ramesh T wrote:
>>
>>> any help...
>>>
>>
>> Honestly, this is basic programming/scripting. I would suggest picking up
>> an introductory programming book to get the basics down.
>> In the meantime, you have used a parameter variable ($1) with out
>> actually supplying a parameter. So Postgres has no idea what $1 represents.
>> Either hard code the part.custid value i.e part.custid = 1 or find a way to
>> supply the value. How you do that is going to depend on how you are going
>> to use the script and where you are expecting to pull the value from.
>>
>> thanks,
>>> ram
>>>
>>>
>>> On Wed, Aug 27, 2014 at 3:22 PM, Ramesh T <rameshparnanditech(at)gmail(dot)com
>>> <mailto:rameshparnanditech(at)gmail(dot)com>> 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..
>>>
>>>
>>>
>>
>> --
>> Adrian Klaver
>> adrian(dot)klaver(at)aklaver(dot)com
>>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2014-08-27 19:50:02 Re: Deletion
Previous Message John R Pierce 2014-08-27 19:15:44 Re: Deletion