pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
sql query - create replace function
2+ messages / 2 participants
[nested] [flat]

* sql query - create replace function
@ 2007-12-20 05:29 Iuri Sampaio <iuri.sampaio@gmail.com>
  2007-12-20 08:31 ` Re: sql query - create replace function Richard Huxton <dev@archonet.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Iuri Sampaio @ 2007-12-20 05:29 UTC (permalink / raw)
  To: pgsql-sql

Hi all,

I created a script to install postgresql. One of the steps is to run a sql
query.

the problem is that i need to run the query as postgres user, plus it needs
to be at psql shell prompt command line, i.e:

# from your shell prompt enter:
$ psql <dbname>

# From the psql prompt enter the follow plpgsql code to create the
bitfromint4 function:

$ create or replace function bitfromint4 (integer) returns bit varying as '
begin return $1::bit(32); end;' language 'plpgsql' immutable strict;

#Exit psql:
$ \q



I expected something like
su - postgres -c "pgsql dbname && create or replace function bitfromint4
(integer) returns bit varying as ' begin return $1::bit(32); end;' language
'plpgsql' immutable str\
ict;"

but i see when the script runs "pgsql dbname" the bash script looses control
of the process, and there's no way back, from pgql shell prompt when it gets
in, to continue the script

iuri

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: sql query - create replace function
  2007-12-20 05:29 sql query - create replace function Iuri Sampaio <iuri.sampaio@gmail.com>
@ 2007-12-20 08:31 ` Richard Huxton <dev@archonet.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Richard Huxton @ 2007-12-20 08:31 UTC (permalink / raw)
  To: iuri.sampaio@computer.org; +Cc: pgsql-sql

Iuri Sampaio wrote:
> Hi all,
> 
> I created a script to install postgresql. One of the steps is to run a sql
> query.
> 
> the problem is that i need to run the query as postgres user, plus it needs
> to be at psql shell prompt command line, i.e:

Why does it need to be at the psql prompt?

> I expected something like
> su - postgres -c "pgsql dbname && create or replace function bitfromint4
> (integer) returns bit varying as ' begin return $1::bit(32); end;' language
> 'plpgsql' immutable str\
> ict;"

What's wrong with this?

-- 
   Richard Huxton
   Archonet Ltd



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-12-20 08:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-12-20 05:29 sql query - create replace function Iuri Sampaio <iuri.sampaio@gmail.com>
2007-12-20 08:31 ` Richard Huxton <dev@archonet.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox