Re: [SQL] cursors in plpgsql

2003-09-17 Thread Tomasz Myrta
Releases before 7.4 are spotty about supporting backwards scan of complex queries --- if you have a join or aggregate in the query, it likely won't work, yielding either strange errors or wrong answers. It will work if the top plan node in the query is a SORT, though, so a possible workaround is to

Re: [SQL] transaction locking

2003-09-17 Thread Stephan Szabo
On Wed, 17 Sep 2003, tom baker wrote: > i am (probably) shooting myself in the foot, but here goes the question. > > inside of a begin transaction/commit block, i am attempting to insert a record > into a parts table, and then insert a record that references the part into an > application table.

[SQL] transaction locking

2003-09-17 Thread tom baker
hello all i am (probably) shooting myself in the foot, but here goes the question. inside of a begin transaction/commit block, i am attempting to insert a record into a parts table, and then insert a record that references the part into an application table. and the transaction fails with this

Re: [SQL] Triggers Help...

2003-09-17 Thread Gaetano Mendola
[EMAIL PROTECTED] wrote: Hi, I have two databases with the same tables, one is my Real Database and the other is my Log Database. My Log database does NOT have any kind of keys (PRIMARY or FOREIGN). I need to insert from my Real database to my Log database every row that is Updated or Deleted in

Re: [SQL] [BUGS] session variable

2003-09-17 Thread Tom Lane
[EMAIL PROTECTED] (Miko O'Sullivan) writes: > Unfortunately in the 7.2.x version I have available, EXECUTE does not > allow "select into". The docs suggests a technique for using a FOR > loop to extract information from an EXECUTE, but the technique only > works for finite set of expected variable

Re: [SQL] cursors in plpgsql

2003-09-17 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > I wanted to use some select result several times in pl/pgsql function. > Neither move backward 1 in test; > nor > execute ''move backward 1 in test''; > doesn't work. Releases before 7.4 are spotty about supporting backwards scan of complex queri

[SQL] cursors in plpgsql

2003-09-17 Thread Tomasz Myrta
Hi I wanted to use some select result several times in pl/pgsql function. DECLARE test refcursor; x record; BEGIN open test for select... fetch test into x; while found loop ...work... fetch test into x; end loop; ...rewind cursor using move... fetch test... Neither move backward 10

Re: [SQL] how to get decimal to date form

2003-09-17 Thread Tomasz Myrta
In our postgre database is a decimal field with format YYMMDDhhmmss.99 where the 9s are random digits. I'm trying to strip off just the YYMMDD and put it in date form. So far I came up with: SUBSTR(TO_CHAR(rec_num,999),1,6) AS Date which returns YMMDD. For example where the rec_num

[SQL] Array fields in Postgresql...

2003-09-17 Thread Jagdeesh
Hi all, Can any one give me a link/tutorial for using arrays in databases..I need Queries to access the arrays as well... Thanx in advance. regards, Jagdeesh. ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http

[SQL] how to get decimal to date form

2003-09-17 Thread wireless
In our postgre database is a decimal field with format YYMMDDhhmmss.99 where the 9s are random digits. I'm trying to strip off just the YYMMDD and put it in date form. So far I came up with: SUBSTR(TO_CHAR(rec_num,999),1,6) AS Date which returns YMMDD. For example where the rec_n

[SQL] Trigger on view

2003-09-17 Thread Kyle
I'm trying to set up a trigger that restricts when and how updates are done to the records in a relation. However, when the administrator accesses the relation, I want the restriction to be relaxed. My approach was to have a view that is accessed by the normal users and have the admin access t

Re: [SQL] [BUGS] session variable

2003-09-17 Thread Miko O'Sullivan
[EMAIL PROTECTED] (Bruce Momjian) wrote in message news:<[EMAIL PROTECTED]>... > Yes, see the FAQ. You have to use EXECUTE for temp table access in > functions. Unfortunately in the 7.2.x version I have available, EXECUTE does not allow "select into". The docs suggests a technique for using a FO

[SQL] Triggers Help...

2003-09-17 Thread tiagoalves
Hi, I have two databases with the same tables, one is my Real Database and the other is my Log Database. My Log database does NOT have any kind of keys (PRIMARY or FOREIGN). I need to insert from my Real database to my Log database every row that is Updated or Deleted in any Table of the Real d

Re: [SQL] how to get decimal to date form

2003-09-17 Thread David W Noon
On Wednesday 17 Sep 2003 13:50 in <[EMAIL PROTECTED]>, wireless ([EMAIL PROTECTED]) wrote: > For example where the rec_num is 30608124143.47069519725 the above > functions return 30608. Unless you are logging dates around 3 A.D., I suggest you add 2000 to the number before you apply the TO_CHAR()

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Kristian Jörg
Tom and Richard, I have successfully fixed this problem now thanks to your support! The setting of LC_COLLATE to C prior to running initdb fixed all problems finally once I had sorted out my error in passing the environment variables correctly. Thanx! /Kristian Kristian Jörg wrote:

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Kristian Jörg
Tom Lane wrote: =?ISO-8859-1?Q?Kristian_J=F6rg?= <[EMAIL PROTECTED]> writes: Unfortunately this does not seem to help! I dumped the database, recreated the cluster with initdb with LC_COLLATE = C (and even tried setting LC_CTYPE to C also), and restored the database. The same

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Tom Lane
=?ISO-8859-1?Q?Kristian_J=F6rg?= <[EMAIL PROTECTED]> writes: > Unfortunately this does not seem to help! I dumped the database, > recreated the cluster with initdb with LC_COLLATE = C (and even tried > setting LC_CTYPE to C also), and restored the database. The same > ordering appears... You di

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Richard Huxton
On Wednesday 17 September 2003 13:39, Kristian Jörg wrote: > Kristian Jörg wrote: > > Richard Huxton wrote: > >>> > >>>LUNDGREN > >>>M L R > >>>MACDOWELL > >>>MUSCLE > >>> > >>>But in Postgres I get this order: > >>> > >>>LUNDGREN > >>>MACDOWELL > >>>M L R > >>>MUSCLE > >> > Woops, a type above. M

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Kristian Jörg
Kristian Jörg wrote: Richard Huxton wrote: On Wednesday 17 September 2003 10:47, Kristian Jörg wrote: Hello! I am having troubles with sort order in Postgres. It seems that space is not handled at all? For instance the following rows are sorted in MS SQL Ser

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Kristian Jörg
Richard Huxton wrote: On Wednesday 17 September 2003 10:47, Kristian Jörg wrote: Hello! I am having troubles with sort order in Postgres. It seems that space is not handled at all? For instance the following rows are sorted in MS SQL Server as: LUNDGREN M L R MACDOWELL MUSCLE

Re: [SQL] sub query

2003-09-17 Thread Christoph Haller
The reason why the first one SELECT MAX(e.d), e.host_position FROM (SELECT host_position, COUNT(host_position) as d FROM sss_host GROUP BY host_position) as e GROUP BY e.host_position ORDER BY 1 LIMIT 1; did not work is because the query needs a ORDER BY 1 DESC LIMIT 1 like the second one. Mind the

[SQL] Trigger order problems

2003-09-17 Thread Richard Huxton
TIA people Three related tables: trans_core - transaction details (trans_id, trans_owner, trans_date, trans_amount) trans_src - funding source (core_id, src_id, src_amount) src_summary - summary of funding-source totals (summary_date, summary_src, summary_amount) The total tra

Re: [SQL] Sort order with spaces?

2003-09-17 Thread Richard Huxton
On Wednesday 17 September 2003 10:47, Kristian Jörg wrote: > Hello! > > I am having troubles with sort order in Postgres. It seems that space is > not handled at all? > For instance the following rows are sorted in MS SQL Server as: > > LUNDGREN > M L R > MACDOWELL > MUSCLE > > But in Postgres I ge

Re: [SQL] sub query

2003-09-17 Thread Martin Kuria
Thanks Haller, the second one worked thanks a million be blessed Regards +-+ | Martin W. Kuria (Mr.) [EMAIL PROTECTED] ++ From: Christoph Haller <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] CC:

[SQL] Sort order with spaces?

2003-09-17 Thread Kristian Jörg
Hello! I am having troubles with sort order in Postgres. It seems that space is not handled at all? For instance the following rows are sorted in MS SQL Server as: LUNDGREN M L R MACDOWELL MUSCLE But in Postgres I get this order: LUNDGREN MACDOWELL M L R MUSCLE I seems that space is no consider

Re: [SQL] sub query

2003-09-17 Thread Christoph Haller
> > > Hi I have this problem, when I try to run this query: > > > > SELECT MAX(d), host_position FROM (SELECT host_position, > > COUNT(host_position) as d FROM sss_host GROUP BY host_position) as e; > > > > am getting and ERROR: Attribute e.host_position must be GROUPed or > used in > > an aggregat

Re: [SQL] sub query

2003-09-17 Thread Christoph Haller
> Hi I have this problem, when I try to run this query: > > SELECT MAX(d), host_position FROM (SELECT host_position, > COUNT(host_position) as d FROM sss_host GROUP BY host_position) as e; > > am getting and ERROR: Attribute e.host_position must be GROUPed or used in > an aggregate function. > > Pl

[SQL] sub query

2003-09-17 Thread Martin Kuria
Hi I have this problem, when I try to run this query: SELECT MAX(d), host_position FROM (SELECT host_position, COUNT(host_position) as d FROM sss_host GROUP BY host_position) as e; am getting and ERROR: Attribute e.host_position must be GROUPed or used in an aggregate function. Please to advic

[SQL] sub query

2003-09-17 Thread Martin Kuria
Hi I have this problem, when I try to run this query: SELECT MAX(d), host_position FROM (SELECT host_position, COUNT(host_position) as d FROM sss_host GROUP BY host_position) as e; am getting and ERROR: Attribute e.host_position must be GROUPed or used in an aggregate function. Please to advic