Re: [SQL] Insert into and Sequence

2007-12-19 Thread Ireneusz Pluta





Apparently, new records are not inserted in the table according to the
order selected by "Test_Step_Id" field;
  
  
As seen in: http://en.wikipedia.org/wiki/SQL:
"The order of rows returned by an SQL query is never guaranteed unless
an ORDER BY clause is specified".

In other words, a database system does not guarantee you the order in
which table rows are stored. So, the order in which you insert your
rows is not the one which has to be followed when selecting them
afterwards. You must specify by "ORDER BY" how you want to sort your
recordset.

It seems you need to revisit the concept of your system.

Best regards

Irek






[SQL] DBLink or setof record functions & type shortcuts

2007-12-19 Thread Jeff Trout

So I'm using dblink to run a query on another db, which works fine.

I'm wondering if there is some shortcut I can use since I have the  
type the remote function is returning defined on my side so I don't  
need to list all the columns -
so instead of select * from dblink('select * from  
someFooTypeReturningFunc()') as t1(col text, )

I could write select * from dblink('select ... ') as t1(footype)

I've poked over the docs and googled around, haven't seen anything yet.

--
Jeff Trout <[EMAIL PROTECTED]>
http://www.dellsmartexitin.com/
http://www.stuarthamm.net/




---(end of broadcast)---
TIP 4: Have you searched our list archives?

  http://archives.postgresql.org


[SQL] sql query - create replace function

2007-12-19 Thread Iuri Sampaio
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 

# 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