Re: [SQL] How to get a self-conflicting row level lock?

2000-07-07 Thread Tom Lane
Forest Wilkinson <[EMAIL PROTECTED]> writes: > I'm worried about concurrent process synchronization. According to the > PostgreSQL docs on the LOCK command, SELECT ... FOR UPDATE acquires a "ROW > SHARE MODE" lock, which is not self-conflicting. That doc is only telling part of the story, I gues

[SQL] How to get a self-conflicting row level lock?

2000-07-07 Thread Forest Wilkinson
I have become maintainer of a program that uses PostgreSQL 6.5.2 for database functionality. It is littered with code blocks that do the following: 1. SELECT * FROM some_table WHERE foo = bar FOR UPDATE; 2. -- Choose a new value for some_field, which might or might not be based on its origina

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Peter Eisentraut
Tom Lane writes: > Exercise for the student: if you need to match a literal backslash > in a LIKE pattern, how many backslashes do you have to write in your > query? I like how Python handles this: You prefix the text literal with an `r' (as in "raw") and the backslashes are not special. Maybe w

Re: [SQL] Altnerate Column Return Names

2000-07-07 Thread Peter Eisentraut
Thomas Swan writes: > If I do a select * from table1, table2 where table1.id = table2.id I > normally get two columns returned with a column identifier of id. > id | name | data | id | name | data > +--+--++--+-- > Is there anyway to get the result to return > > ta

Re: [SQL] confused by select.

2000-07-07 Thread Antoine Reid
On Fri, Jul 07, 2000 at 11:44:30AM +0200, Patrick Jacquot wrote: [snip] > > usually many-to-many relationships are handled by a third table, like this: > > create table items (item_id,...) > create table customers (customer_id, ...) > create table orders (customer_id, item_id, quantity_orderered

[SQL] date comparision

2000-07-07 Thread sandis
Is anyone out here can give some advice? i have a table with a timestamp field. i should know if there is records for the particular year and month so i need a query like (in MySQL it was very simple, but i should move to postgres!): SELECT something FROM mytable WHERE MONTH('timestamp_field')=0

Re: [SQL] order by accents?

2000-07-07 Thread Web Manager
Patrick Coulombe wrote: > > hi, > if I do a query like this one : > > SELECT name from medias ORDER BY name > > name > > > > > > > ÉCCC > > 6 rows > > Why the record : ÉCCC is at the end? > HOW can I fix this? > > Thank you > Patrick Hello, I have the same

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Bruce Momjian
> I wrote: > > Similarly, '\\%' would be the way to match a literal %. You can > > actually backslash-quote any single character this way in LIKE, > > but % and _ are the only ones where it makes a difference. > > Er, check that. Backslash itself also needs quoting in LIKE. > > Exercise for th

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Tom Lane
I wrote: > Similarly, '\\%' would be the way to match a literal %. You can > actually backslash-quote any single character this way in LIKE, > but % and _ are the only ones where it makes a difference. Er, check that. Backslash itself also needs quoting in LIKE. Exercise for the student: if yo

[SQL] Get: Month & Month-1 & Month+1

2000-07-07 Thread Ebbe Poulsen
Hi, E.g. : The user/customer writes December, and I want to give back the plants flowering in November + December + January. (A circular situation, a 'season' covering more the one calender year in two cases ) The flowering field should be marked montly - in some convenient way: March-May , A

Re: [SQL] Search for underscore w/ LIKE

2000-07-07 Thread Tom Lane
[EMAIL PROTECTED] writes: > How do I use LIKE to search for strings with an underscore? The > documentation (well, Bruce's book) says to use 2 underscores (__) but it > doesn't work. If Bruce's book says that, I hope it's not too late for him to change it ;-) The correct way is to escape the und

[SQL] order by accents?

2000-07-07 Thread Patrick Coulombe
hi, if I do a query like this one : SELECT name from medias ORDER BY name name ÉCCC 6 rows Why the record : ÉCCC is at the end? HOW can I fix this? Thank you Patrick

[SQL] Ancient postgres+EXCEPT

2000-07-07 Thread Antti Linno
Lo. I have in my local machine quite new POstgresql [PostgreSQL 6.5.3 on i586-pc-linux-gnu, compiled by gcc egcs-2.91.66] but the machine, I am writing scripts for has some ancient postgres(btw, how to see the version on psql, if its not shown at the start? ). I made a query SELECT ajaperiood.isi

Re: [SQL] MAX() of 0 records.

2000-07-07 Thread Paul McGarry
Hi Benoit, > I once had the same problem with an int4 column and solved it by > using the function below : > > CREATE FUNCTION "nulliszero" (int4 ) > RETURNS int4 AS > 'SELECT 0 WHERE $1 IS NULL > UNION SELECT $1 WHERE $1 IS NOT NULL' LANGUAGE 'SQL'; > > Your request then would look like : > (

Re: [SQL] confused by select.

2000-07-07 Thread Patrick Jacquot
John wrote: > Hello. I'm trying to do a select here that i have looked at from many > angles and cannot find a solution too. My main problem, (i believe) is > that it is trying to create a many to many relationship. I would be > grateful if anyone knew a way around this. > > Here's my predicam

[SQL] Search for underscore w/ LIKE

2000-07-07 Thread brianb-pgsql
How do I use LIKE to search for strings with an underscore? The documentation (well, Bruce's book) says to use 2 underscores (__) but it doesn't work. For example: create table liketest ( somestr varchar(50) ); insert into liketest values ('foo_bar'); insert into liketest values ('foobar');

Re: [SQL] MAX() of 0 records.

2000-07-07 Thread benoit
> Hello, > > I wish to perform the following query in a plsql function upon an > update/insert/delete trigger: > > UPDATE entry_stats > SET entry_maxprice=MAX(item_price) > FROM item > WHERE item.item_entry_id=NEW.item_entry_id > AND item.item_live = 't'; > > However there will be situati

Re: [SQL] MAX() of 0 records.

2000-07-07 Thread Tom Lane
Paul McGarry <[EMAIL PROTECTED]> writes: > However there will be situations where there are no records for > a given item_entry_id with item_live='t'. Currently when I try > do update/insert a record so that this occurs I get the following > error 'ERROR: ExecutePlan: (junk) 'ctid' is NULL!' and

[SQL] Altnerate Column Return Names

2000-07-07 Thread Thomas Swan
If I do a select * from table1, table2 where table1.id = table2.id I normally get two columns returned with a column identifier of id. Such as id | name | data | id | name | data +--+--++--+-- | | || | Is there anyway to get the result to retu

Re: [SQL] MAX() of 0 records.

2000-07-07 Thread DalTech - Continuing Technical Education
> UPDATE entry_stats > SET entry_maxprice=MAX(item_price) > FROM item > WHERE item.item_entry_id=NEW.item_entry_id > AND item.item_live = 't'; Try COALESCE(MAX(item_price),0) Christopher J.D. Currie Computer Technician Dalhousie: DalTech - CTE _