Re: error with functions

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: shyamperi(at)davlin(dot)co(dot)in
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: error with functions
Date: 2003-09-22 15:43:38
Message-ID: 20030922083927.M2590@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


On Mon, 22 Sep 2003 shyamperi(at)davlin(dot)co(dot)in wrote:

> >You do realize that the shell is going to interpret that string in
> >double quotes right?
> I guess so, for the very same I have tried with
> Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
> INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE
> 'plpgsql';"
> But still it is not taking it as $1, instead empty string.
> Ideeally it shud consider $1 as string... but why isn't it

The shell interprets the double quoted string and effectively replaces $1
with the shell's idea of what to put in place of it. This really has
nothing to do with postgres at all. Use a backslash before the $1, or
put it in a file and execute it from there.

Try these for example:
echo "$1"
echo '$1'
echo "\$1"

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jodi Kanter 2003-09-22 15:44:55 steps to ensure referential integrity
Previous Message Oliver Elphick 2003-09-22 15:43:02 Re: error with functions