Re: [SQL] update with subselect (long)

2005-03-17 Thread Stephan Szabo
On Thu, 17 Mar 2005, Leif B. Kristensen wrote: > CREATE TABLE name_part_types ( -- a key/label pair > name_part_type_id INTEGER PRIMARY KEY, > name_part_type VARCHAR(50) > ); > > > CREATE TABLE names ( -- one person can have multiple names > name_id INTEGER PRIMARY KEY, > person_i

Re: [SQL] plpgsql & date-time functions

2005-03-13 Thread Stephan Szabo
On Tue, 8 Mar 2005, Fatih Cerit wrote: > I have a function and I want to update a table's two rows but having problem > with plpgsql & date-time functions. First field of the table must be now() > this is ok.. but the second field must be now() + '60 days' if the query > like this : SELECT INTO to

Re: [SQL] Simple delete takes hours

2005-03-04 Thread Stephan Szabo
On Thu, 3 Mar 2005, Thomas Mueller wrote: > Hi there, > > I have a simple database: > > CREATE TABLE pwd_description ( >id SERIALNOT NULL UNIQUE PRIMARY KEY, >name varchar(50) NOT NULL > ); > > CREATE TABLE pwd_name ( >id SERIALNOT NULL UNIQUE PR

Re: [SQL] what does ONLY do

2005-02-18 Thread Stephan Szabo
On Fri, 18 Feb 2005, Bret Hughes wrote: > I can't seem to find an explanation of what adding ONLY does for an sql > statement for instance : > > ALTER TABLE [ONLY] ADD COLUMN ... > > or what ever. Does anyone have a pointer to docs on this. I am simply > curious since there is obviously somethi

Re: [SQL] [HACKERS] Function .. AS..?

2005-02-09 Thread Stephan Szabo
On Wed, 9 Feb 2005, Ing. Jhon Carrillo wrote: > Those instructions are good but i want to call this function only for " > select consulta_contacto(1)" nothing more, Is really necesary to use > "AS ..."? If it absolutely needs to be setof record, yes. It may be more appropriate to make a composi

Re: [SQL] plpgsql functions and NULLs

2005-01-31 Thread Stephan Szabo
earch. You may want to do some testing to see how it runs for you. > On Mon, 31 Jan 2005 13:31:34 -0800 (PST), Stephan Szabo > <[EMAIL PROTECTED]> wrote: > > > > On Sun, 30 Jan 2005, Don Drake wrote: > > > > > OK, I have a function that finds records that ch

Re: [SQL] plpgsql functions and NULLs

2005-01-31 Thread Stephan Szabo
On Sun, 30 Jan 2005, Don Drake wrote: > OK, I have a function that finds records that changed in a set of > tables and attempts to insert them into a data warehouse. > > There's a large outer loop of candidate rows and I inspect them to see > if the values really changed before inserting. > > My

Re: [SQL] Foreign Key relationship between two databases

2005-01-27 Thread Stephan Szabo
On Thu, 27 Jan 2005, Sandeep Gaikwad wrote: > I can give foreign key relationship between two tables of same > database. Can I give foreign key relationship between tables of two > databases ? Plz, let me know if possible & send me how can I do that? Unfortunately, that's not really current

Re: [SQL] plpgsql and for with integer loopvar error

2005-01-17 Thread Stephan Szabo
On Sat, 15 Jan 2005, Ari Kahn wrote: > CREATE FUNCTION gets_nooky() returns numeric AS > ' > DECLARE > i integer; > gt1cnt record; > gt1 record; > cluster record; > cluster_cnt integer; > slocus integer; > minmax record; > > BEGIN > SELECT INTO gt1 * FROM c

Re: [SQL] Simple Question

2005-01-11 Thread Stephan Szabo
On Tue, 11 Jan 2005, Terry Lee Tucker wrote: > Hello: > > I'm trying to figure out how to convert a floating point value into an > interval of time. I'm calculating the time required to drive from point A to > point B. For the sake of this question, we'll just say it is miles/speed. So: > > drv_t

Re: [SQL] foreign key problems

2005-01-05 Thread Stephan Szabo
On Wed, 5 Jan 2005, Stephan Szabo wrote: > > On Wed, 5 Jan 2005, [iso-8859-2] BARTKO, Zoltán wrote: > > > Ok, so I made some changes (manual "inheritance" of PK and FK > > constraints), but nevertheless I get still the same dumb error. I made > > a dump of t

Re: [SQL] foreign key problems

2005-01-05 Thread Stephan Szabo
On Wed, 5 Jan 2005, [iso-8859-2] BARTKO, Zoltán wrote: > Ok, so I made some changes (manual "inheritance" of PK and FK > constraints), but nevertheless I get still the same dumb error. I made > a dump of the DB via pg_dump, it is available at > > http://de.geocities.com/bartkozo/dump.tgz > > DRec

Re: [SQL] foreign key problems

2005-01-04 Thread Stephan Szabo
On Tue, 4 Jan 2005, [iso-8859-2] BARTKO, Zoltán wrote: > if I create the tables that are in the attached file, I can't insert > rows into the AAttachment table, even though the rows in DObject with > the given primary key exist (PgSQL 8.0 rc1 complains about > (ownerid)=(insert the number here) n

Re: [SQL] Join issue?

2004-12-15 Thread Stephan Szabo
On Wed, 15 Dec 2004, Marian POPESCU wrote: > Hi, > > I have a problem with this join query: > > > SELECT > CASE WHEN (UR.id_rights IS NULL) THEN '0' ELSE UR.id_rights END as > id_rights, > CASE WHEN (UR.r_category IS NULL) THEN 'CMP' ELSE UR.r_category END as > category, > U.id

Re: [SQL] replacing mysql enum

2004-12-11 Thread Stephan Szabo
On Sat, 11 Dec 2004, Rod Taylor wrote: > On Sat, 2004-12-11 at 07:47 -0800, Stephan Szabo wrote: > > On Sat, 11 Dec 2004, Ian Barwick wrote: > > > > > (Oddly enough, putting the NULL in the CHECK constraint seems > > > to make the constraint worthless: > >

Re: [SQL] replacing mysql enum

2004-12-11 Thread Stephan Szabo
On Sat, 11 Dec 2004, Ian Barwick wrote: > (Oddly enough, putting the NULL in the CHECK constraint seems > to make the constraint worthless: > test=> create table consttest (field varchar(2) check (field in > (null, 'a','b','c'))); > CREATE TABLE > test=> insert into consttest values ('xx'); > INS

Re: [SQL] Cast NULL into Timestamp?

2004-12-10 Thread Stephan Szabo
On Fri, 10 Dec 2004, Wei Weng wrote: > I have a table > > create table temp > ( > tempdatetimestamp, > tempnamevarchar(10) > ); > > And I tried to insert the following: > > insert into table temp (tempname, tempdate) > select distinct 'tempname', null from some_other_re

Re: [SQL] Query is slower

2004-12-01 Thread Stephan Szabo
On Wed, 1 Dec 2004, Sandro Joel Eller wrote: > I have a query using "like" operator (select * from name like 'JOHN%'), > but the table has about 500 hundred records. The has a index (create > index ixcontract_name on contract (name)) , but it is very slow because > it is not using index. How do

Re: [SQL] NULLS and string concatenation

2004-11-19 Thread Stephan Szabo
On Fri, 19 Nov 2004, Don Drake wrote: > On Fri, 19 Nov 2004 17:48:34 +, Richard Huxton <[EMAIL PROTECTED]> wrote: > > Don Drake wrote: > > > select 'some text, should be null:'|| NULL > > > > > > This returns NULL and no other text. Why is that? I wasn't expecting > > > the "some text.." to

Re: [SQL] Counting Distinct Records

2004-11-17 Thread Stephan Szabo
On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: > Hmm. I was more interested in using COUNT( * ) than DISTINCT *. > > I want a count of all rows, but I want to be able to specify which > columns are distinct. I'm now a bit confused about exactly what you're looking for in the end. Can you give a s

Re: [SQL] Counting Distinct Records

2004-11-16 Thread Stephan Szabo
On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: > Is there another way to accomplish what the former is doing, then? The only thing I can think of is a subselect in from that uses distinct. select count(*) from (select distinct ...) foo That also theoretically allows you to use select distinct *

Re: [SQL] Counting Distinct Records

2004-11-16 Thread Stephan Szabo
On Tue, 16 Nov 2004, Thomas F.O'Connell wrote: > I am wondering whether the following two forms of SELECT statements are > logically equivalent: > > SELECT COUNT( DISTINCT table.column ) ... > > and > > SELECT DISTINCT COUNT( * ) ... Not in general. The former counts how many distinct table.colu

Re: [SQL] Cascade updates wait until the end of the transaction?

2004-11-15 Thread Stephan Szabo
On Fri, 12 Nov 2004, Thomas Berg wrote: > Within a function (and therefore within a transaction), if I UPDATE the > primary key of a table, the old value remains visible in the child table > through the end of the function. Is this 8.0 runs immediate triggers after each statement of a function a

Re: [SQL] select using regexp does not use indexscan

2004-11-13 Thread Stephan Szabo
On Tue, 9 Nov 2004, carex wrote: > And it works also perfectly with Gentoo. > > So,is this a typical "Redhat Enterprise" problem ? > Or do I overlook something ?? IIRC, in 7.3.x, index scans are only considered in "C" locale for regexp/LIKE. In 7.4.x, non-"C" locale databases can use a special i

Re: [SQL] UPDATE/INSERT on multiple co-dependent tables

2004-11-09 Thread Stephan Szabo
On Tue, 9 Nov 2004, Ferindo Middleton, Jr wrote: > Is it possible for an UPDATE/INSERT query string to function in such a way > that it requires two like fields in different tables to be equal to/'in sync > with' one another: > > Example: I have two tables: registration & schedules > they both

Re: [SQL] Foreign Key Non-Null Problem in 8.0

2004-10-30 Thread Stephan Szabo
On Wed, 27 Oct 2004, Jon Uhal wrote: > I'm having trouble trying to get my databases setup so that when I > delete a row from the base table, all related information is removed as > well. I've been testing this with PostgreSQL version (postmaster > (PostgreSQL) 8.0.0beta1) on a Windows 2000 Pro m

Re: [SQL] RULE and default nextval() column

2004-10-27 Thread Stephan Szabo
On Wed, 27 Oct 2004, Dmitry P. Ovechkin wrote: > Hello. > I'mtrying to implement history tables using rules. > I have > test_table > -- > create sequence history_seq start 1; > create sequence test_sequence; > # source table > drop table test_table; > create table test_table ( > i integer

Re: [SQL] How do you compare (NULL) and (non-NULL)?

2004-10-26 Thread Stephan Szabo
On Tue, 26 Oct 2004, Wei Weng wrote: > In the following query > > SELECT Parent FROM Channels ORDER BY Parent ASC; > > If I have a couple of (NULL)s in the field [Parent], they will be listed at > the bottom of the query result. > > Is it because PostgreSQL considers (NULL) as the biggest value? I

Re: [SQL] Finding duplicated values

2004-10-21 Thread Stephan Szabo
On Thu, 21 Oct 2004, Kent Anderson wrote: > I have a few tables that have duplicated values from an import from a > different database. I have two keys I tried to set as primary and got an > error > ERROR: could not create unique index > DETAIL: Table contains duplicated values. > > Is there som

Re: [SQL] time of constraint checking

2004-10-20 Thread Stephan Szabo
On Wed, 20 Oct 2004, Markus Bertheau wrote: > http://www.postgresql.org/docs/current/static/sql-createtable.html says, > down at the explanation of DEFERRABLE, that constraints are checked > after every command. Why does the following not work then: > > CREATE TABLE foo ( > pos INT UNIQUE > );

Re: [SQL] Ordering a record returned from a stored procedure

2004-10-18 Thread Stephan Szabo
On Mon, 18 Oct 2004, Kent Anderson wrote: > I am pulling a report from the database using a stored procedure but cannot > get the information to return in a specific order unless I hardcode the > order by clause. > > CREATE OR REPLACE FUNCTION submissionreport(INTEGER, DATE, TEXT) RETURNS > setof

Re: [SQL] Help with function

2004-09-21 Thread Stephan Szabo
On Tue, 21 Sep 2004, CHRIS HOOVER wrote: > Thanks a bunch for the pointers and help. > > One other hopefully quick question. > > How do you query using a variable containing the query? > > I'm trying to build a select statment based upon what parameters are being > passed to the function. > > somt

Re: [SQL] degradation in performance

2004-09-21 Thread Stephan Szabo
On Tue, 21 Sep 2004, Alain Reymond wrote: > I created a database with Postgres 7.3.4 under Linux RedHat 7.3 on a > Dell PowerEdge server. You should probably upgrade to the end of the 7.3 branch at the least (7.3.7). > One of the table is > resultats(numbil, numpara, mesure, deviation) > with a

Re: [SQL] Help with function

2004-09-20 Thread Stephan Szabo
On Mon, 20 Sep 2004, CHRIS HOOVER wrote: > I need some help writing a simple function. > > Due to some program limitations for a program I run the db's for, I'm having > to write some simple functions to run some selects. However, I am not sure > how to have them correctly return the record(s) se

Re: [SQL] explain analyze results are different for each iteration

2004-09-14 Thread Stephan Szabo
On Tue, 14 Sep 2004, Robert Davis wrote: > I'm trying to benchmark some complex sql queries. One query, in > particular, is causing problems -- its cost values can vary from 228 > to 907, its Total Runtimes from 60 ms to 5176 ms. The query plans > show that the optimizer is choosing different pl

Re: [SQL] INFORMATION_SCHEMA and foreign keys

2004-09-05 Thread Stephan Szabo
On Mon, 6 Sep 2004, Troels Arvin wrote: > The query returns double the numer of rows, compared to what I wanted. The > problem seems to stem from PostgreSQL's naming of constraints without > explicit name: They seem to be named $1, $2, etc, and the default names > are reused. [...] > Note, again,

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Stephan Szabo
On Wed, 1 Sep 2004, Tom Lane wrote: > Peter Eisentraut <[EMAIL PROTECTED]> writes: > > The cast to text, however, is part of the data model, and it has to be > > both natural and universal. I think you agree that there is no > > universal, obvious correspondence between character strings and boo

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Stephan Szabo
On Wed, 1 Sep 2004, sad wrote: > > There's a difference between an output function and a cast to text. > > One gives you an external representation of the data for end use. The > > other gives you an internal representation for manipulation. > > And at the same time > > 't'::TEXT can be casted t

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Stephan Szabo
On Wed, 1 Sep 2004, sad wrote: > On Wednesday 01 September 2004 09:24, Stephan Szabo wrote: > > On Wed, 1 Sep 2004, sad wrote: > > > On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote: > > > > On Aug 31, 2004, at 8:24 PM, sad wrote: > > > > >

Re: [SQL] casting BOOL to somthng

2004-08-31 Thread Stephan Szabo
On Wed, 1 Sep 2004, sad wrote: > On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote: > > On Aug 31, 2004, at 8:24 PM, sad wrote: > > > and i am still desire to know _WHY_ there are no predefined cast for > > > BOOL ? > > > and at the same time there are predefined casts for INT and FLOAT...

Re: [SQL] Possible rounding error of large float values?

2004-08-24 Thread Stephan Szabo
On Wed, 25 Aug 2004, Iain wrote: > > # select 9223372036854775807 = 9223372036854775807::float; > ?column? > -- > t > (1 row) > This and the fact that it's still possible to find the row using the > original value would seem to indicate that the rounding is just a display > artifact..

Re: [SQL] multi column foreign key for implicitly unique columns

2004-08-20 Thread Stephan Szabo
On Fri, 20 Aug 2004, Richard Huxton wrote: > It'd be nice to say something like: > > ALTER TABLE status ADD CONSTRAINT user_status_fk > FOREIGN KEY (status) WHERE relation = 'users' > REFERENCES users(status); > > And the flip-side so you can have: > > ALTER TABLE cheque_details ADD CONSTRAINT chq

Re: [SQL] multi column foreign key for implicitly unique columns

2004-08-18 Thread Stephan Szabo
On Wed, 18 Aug 2004, Josh Berkus wrote: > > In the case that a table constraint is a referential constraint, > > the table is referred to as the referencing table. The referenced > > columns of a referential constraint shall be the unique columns of > > some unique constraint

Re: [SQL] multi column foreign key for implicitly unique columns

2004-08-18 Thread Stephan Szabo
On Wed, 18 Aug 2004, Jan Wieck wrote: > On 8/18/2004 9:49 AM, Markus Bertheau wrote: > > > В Срд, 18.08.2004, в 15:33, Jan Wieck пишет: > > > >> Meaning that not enforcing the uniqueness of those columns isn't an > >> option. > > > > The thing is that the columns _are_ unique, there's just no uniq

Re: [SQL] SQL Challenge: Arbitrary Cross-tab

2004-08-17 Thread Stephan Szabo
On Tue, 17 Aug 2004, Josh Berkus wrote: > I have a wierd business case. Annoyingly it has to be written in *portable* > SQL92, which means no arrays or custom aggregates. I think it may be > impossible to do in SQL which is why I thought I'd give the people on this > list a crack at it. Solve

Re: [SQL] multi column foreign key for implicitly unique columns

2004-08-17 Thread Stephan Szabo
On Tue, 17 Aug 2004, Markus Bertheau wrote: > В Втр, 17.08.2004, в 17:06, Stephan Szabo пишет: > > On Tue, 17 Aug 2004, Markus Bertheau wrote: > > > > > В Втр, 17.08.2004, в 16:46, Tom Lane пишет: > > > > > > > I think one reason for this is that

Re: [SQL] SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo

2004-08-17 Thread Stephan Szabo
On Tue, 17 Aug 2004, Markus Bertheau wrote: > В Втр, 17.08.2004, в 16:12, Bruno Wolff III пишет: > > > SELECT MAX(position) FROM (SELECT position FROM classes WHERE name = > > > 'foo' FOR UPDATE OF classes) AS foo > > > > > > It's clear which rows should be locked here, I think. > > > > Even if it

Re: [SQL] multi column foreign key for implicitly unique columns

2004-08-17 Thread Stephan Szabo
On Tue, 17 Aug 2004, Markus Bertheau wrote: > Ð ÐÑÑ, 17.08.2004, Ð 16:46, Tom Lane ÐÐÑÐÑ: > > > I think one reason for this is that otherwise it's not clear which > > unique constraint the FK constraint depends on. Consider > > > > create table a (f1 int unique, f2 int unique); > > > > cr

Re: [SQL] multi column foreign key for implicitly unique columns

2004-08-17 Thread Stephan Szabo
On Tue, 17 Aug 2004, Richard Huxton wrote: > Markus Bertheau wrote: > > Hi, > > > > PostgreSQL doesn't allow the creation of a foreign key to a combination > > of fields that has got no dedicated unique key but is unique nonetheless > > because a subset of the combination of fields has a unique c

Re: [SQL] LIKE '%%' does not return NULL

2004-08-15 Thread Stephan Szabo
On Wed, 11 Aug 2004, Traci Sumpter wrote: > A team developer has chosen the lazy way of not checking if a variable > exists on his PHP page and has code which produces the following SQL > > SELECT * FROM mytable where myfield ilike '%%' > > I have noticed that this statement does not return null o

Re: [SQL] function expression in FROM may not refer to other relations

2004-08-12 Thread Stephan Szabo
On Thu, 12 Aug 2004, Philippe Lang wrote: > > > The problem now is that get_lines is being called twice per line. > > > > Is get_lines() defined as IMMUTABLE? Should it be? > > I have tried defining get_lines as "IMMUTABLE", or "WITH (iscachable)", > but it keeps on getting called twice per line

Re: [SQL] SQL syntax extentions - to put postgres ahead in the race

2004-08-05 Thread Stephan Szabo
On Thu, 5 Aug 2004, Ram Nathaniel wrote: > > 1) The operator "of max": > suppose I have a table "grades" of 3 fields: class/student/grade where I > store many grades of many students of many classes. I want to get the > name of the highest scoring student in each class. Note that there may > be m

Re: [SQL] Trigger and function not on speaking terms

2004-08-02 Thread Stephan Szabo
On Mon, 2 Aug 2004, Jeff Boes wrote: > Hmm, this is puzzling me: > > create or replace function fn_foo(text) returns trigger as ' > begin ># Do some stuff with $1 > end; > ' language 'plpgsql'; > > CREATE FUNCTION > > create table bar (aaa text); > > CREATE TABLE > > create trigger trg_bar > a

Re: [SQL] Problem with transaction in functions and tempory tables

2004-07-22 Thread Stephan Szabo
On Thu, 22 Jul 2004, Gerardo Castillo wrote: > Hello, > > I'm using PostgreSQL 7.4 > > I have a function wich use temporary tables. I read about temporary tables > and they exists during the session. > But i have to call this function many times in the same sesion with > diferents parameters and e

Re: [SQL] next integer in serial key

2004-07-22 Thread Stephan Szabo
On Thu, 22 Jul 2004 [EMAIL PROTECTED] wrote: > > > Alternatively, you can do: > > > INSERT (accepting the default) > > > then SELECT currval(the_sequence_object); > > > then > > > > > > NOTE: 2nd method assumes that nobody else called nextval() on the > > > sequence between when you did the > >

Re: [SQL] immutable function calling stable function

2004-07-21 Thread Stephan Szabo
On Wed, 21 Jul 2004, Markus Bertheau wrote: > shouldn't it be illegal for an immutable function to call a stable one? It's expected that the function's creator is responsible for properly marking its stability. This allows some flexibility when you know more than the system does (for example, a

Re: [SQL] Sorting problem

2004-07-16 Thread Stephan Szabo
On Mon, 12 Jul 2004, Ruggero wrote: > Hi all, > I have a problem sorting varchar fields. > I will explain the problem with a simple example: > > this query >select '##10' as sortfield >union >select '###1' as sortfield >order by sortfield > produces this correct output: >'###1'

Re: [SQL] please help me with text cast to int ....

2004-07-11 Thread Stephan Szabo
On Sun, 11 Jul 2004, Theodore Petrosky wrote: > I give up.. what don't I understand about casting and > ints and text.. > > i have a table jobinfo with: > > acode text, > jobnumber text default > nextval('public.jobinfo_seq'::text), > jobtitle text > > I have about 3000 rows starting with jobnumb

Re: [SQL] [BUGS] [JDBC] Error in DatabaseMetaData.getColumns() with Views

2004-07-04 Thread Stephan Szabo
On Sun, 4 Jul 2004, Dario V. Fassi wrote: > Stephan, look at the samples I send in previous posts , from PgSql and Db2. I don't see any samples apart from the original view descriptions and the getColumns results. I see some implication about db2 but no details. My guess is that the messages a

Re: [SQL] [BUGS] [JDBC] Error in DatabaseMetaData.getColumns() with Views

2004-07-04 Thread Stephan Szabo
On Sun, 4 Jul 2004, Dario V. Fassi wrote: > > > Stephan Szabo wrote: > > >On Sun, 4 Jul 2004, Kris Jurka wrote: > > > > > > > >>On Sat, 3 Jul 2004, Dario V. Fassi wrote: > >> > >> > >> > >>>In the sample adjunct,

Re: [SQL] [BUGS] [JDBC] Error in DatabaseMetaData.getColumns() with Views

2004-07-04 Thread Stephan Szabo
On Sun, 4 Jul 2004, Kris Jurka wrote: > On Sat, 3 Jul 2004, Dario V. Fassi wrote: > > > In the sample adjunct, you can see that error arise at the time when the > > view's sql text is parsed and saved in database catalog. > > Then generic NUMERIC type is forced for every calculated column without

Re: [SQL] finding if a foreign key is in use

2004-07-01 Thread Stephan Szabo
On Thu, 1 Jul 2004, Kenneth Gonsalves wrote: > On Tuesday 29 June 2004 07:19 pm, Phil Endecott wrote: > > Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: > > > in my app i have a table where the id serves as a foreign key for > > > one or more other tables. if i want to delete a row in the table, > >

Re: [SQL] OUTER JOIN problem

2004-06-29 Thread Stephan Szabo
On Wed, 23 Jun 2004, Zoltan Boszormenyi wrote: > I don't know how PostgreSQL works internally but this bug *must* be > conforming to some standard if two distinct SQL server products behave > (almost) the same. I said almost, I discovered the same annoyance today > on an Informix 9.21 running und

Re: FW: [SQL] "=" operator vs. "IS"

2004-06-29 Thread Stephan Szabo
On Tue, 29 Jun 2004, Greg Stark wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > > > IS TRUE and IS FALSE have a different effect from =true and =false when > > the left hand side is NULL. The former will return false, the latter will > > return NULL. > >

Re: FW: [SQL] "=" operator vs. "IS"

2004-06-28 Thread Stephan Szabo
On Tue, 29 Jun 2004, Stefan Weiss wrote: > On Tuesday, 29 June 2004 00:17, Dmitri Bichko wrote: > > As far as TRUE and FALSE go, from what I know you can use = to compare > > them with boolean columns, unless I misunderstood your question. > > Sorry, I must have remembered that incorrectly, or ma

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, Bruno Wolff III wrote: > On Thu, Jun 24, 2004 at 07:34:18 -0700, > Stephan Szabo <[EMAIL PROTECTED]> wrote: > > > > I was thinking that something like Cs switch might work. There's still a > > question of the keywords because I

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, sad wrote: > > then lots of currently perfectly correct > > programs break. If they're the same, then ELSE has different meanings > > depending on whether NULL is specified, and that's generally bad from an > > understanding the language standpoint. > > i've already thougth

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, sad wrote: > > If you were to add a NULL block you'd have to deal with things > > like, if you only have a then and else, do you run the else on NULL or do > > you do nothing? If you do nothing, what if you want the null and else to > > be the same, do you add another way to

Re: [SQL] feature request ?

2004-06-24 Thread Stephan Szabo
On Thu, 24 Jun 2004, sad wrote: > > I don't see what your point is. That SQL is wrong ? Or that SQL is not "C" > > ? Or that SQL is not a "programming language" ? > > Who said wrong ? who said SQL ? > > I thougth _WHY_ > the IF control structure has exactly two alternate blocks ? > a BOOLEAN expre

Re: [SQL] subselect prob in view

2004-06-22 Thread Stephan Szabo
On Tue, 22 Jun 2004, Gary Stainburn wrote: > On Monday 21 Jun 2004 4:11 pm, Gary Stainburn wrote: > > On Monday 21 Jun 2004 3:19 pm, Tom Lane wrote: > > > Gary Stainburn <[EMAIL PROTECTED]> writes: > > > > from requests r, users u, request_types t, > > > > request_states s, dealersh

Re: [SQL] help with Postgres function

2004-06-20 Thread Stephan Szabo
On Wed, 16 Jun 2004, ctrl wrote: > CREATE OR REPLACE FUNCTION getNextWebsiteForCrawl(integer) RETURNS > website AS ' > DECLARE > my_record RECORD; > w website%rowtype; > count smallint; You can't safely use a variable named count and the count(*) expression below I think, so you'll want to rename

Re: [SQL] query with =ALL

2004-06-14 Thread Stephan Szabo
On Mon, 14 Jun 2004, Tom Lane wrote: > "Jaime Casanova" <[EMAIL PROTECTED]> writes: > > AND > > CPA.cur_paralelo = ALL (SELECT cur_paralelo FROM aca_t_curso ...) > > Wait a second ... we are all overthinking the problem. The subselect > returns three *different* values. It is not possible for a

Re: [SQL] query with =ALL

2004-06-14 Thread Stephan Szabo
On Mon, 14 Jun 2004, Jaime Casanova wrote: > On Mon, 14 Jun 2004, Jaime Casanova wrote: > > > i have an strange result here, i'm using 7.4.2 on redhat 8 > > > > i have a query like this > > > > SELECT CPA.rub_codigo, RUB.rub_descripcion, CPA.cpa_valor, > > CPA.cpa_fechavencimiento > > FROM

Re: [SQL] query with =ALL

2004-06-14 Thread Stephan Szabo
On Mon, 14 Jun 2004, Jaime Casanova wrote: > i have an strange result here, i'm using 7.4.2 on redhat 8 > > i have a query like this > > SELECT CPA.rub_codigo, RUB.rub_descripcion, CPA.cpa_valor, > CPA.cpa_fechavencimiento > FROM rec_m_cuadropagos CPA, rec_m_rubro RUB > WHERE RUB.ent_codigo = CPA

Re: [SQL] Trigger problem

2004-06-09 Thread Stephan Szabo
On Tue, 8 Jun 2004, kasper wrote: > Im tryint to make a trigger that marks a tuble as changed whenever someone > has updated it > > my table looks something like this > > create table myTable ( > ... > changed boolean; > ) > > now ive been working on a trigger and a sp that looks like thi

Re: [SQL] simple addition of constraints problem

2004-06-08 Thread Stephan Szabo
On Tue, 8 Jun 2004, Michelle Murrain wrote: > I'm trying to do something which seems really simple to me. (Postgres 7.3.4) > > I've got this table: > > charter_dev2=# \d rcourseinfo > Table "public.rcourseinfo" > Column| Type |

Re: [SQL] empty string casting to typed value

2004-06-07 Thread Stephan Szabo
On Mon, 7 Jun 2004, sad wrote: > It is clear that '' is a bad integer or timestamp representation > > but during the user input NULLs are usually represented with empty strings > sometimes bunch of 'if empty' instructions grows huge > (and in case of casting to timestamp apostrophes make sense)

Re: [SQL] Reference with condition on other table column?

2004-06-03 Thread Stephan Szabo
On Thu, 3 Jun 2004, Andrei Bintintan wrote: > Hi to all, > > I have the following tables: > CREATE TABLE t1( > id serial PRIMARY KEY, > active boolean NOT NULL DEFAULT 'y', > num int4 NOT NULL, > ); > CREATE UNIQUE INDEX t1_uniqueidx ON t1(num) WHERE active; > > CREATE TABLE t2( > id serial PRIMAR

Re: [SQL] Problem with JOINS

2004-05-21 Thread Stephan Szabo
On Fri, 21 May 2004, Charlie Clark wrote: > SELECT > gender.value as anrede_value, > person.name as person_name, > person.vorname as person_vorname, > person.zusatz as person_zusatz, > person.birthdate as person_birthdate, > address.strasse as address_strasse, > address.hausnummer as address_hau

Re: [SQL] where to start with this procedure ?

2004-05-20 Thread Stephan Szabo
On Thu, 20 May 2004, Andreas wrote: > > Hi Andrei, > > > >Use the Offset and Limit in the SQL query. > >[...] > >SELECT select_list > >FROM table_expression > >WHERE condition > >LIMIT 50 > >OFFSET 1 > > > >This query will return 50 elements starting with the 1 elements...

Re: [SQL] rules

2004-05-19 Thread Stephan Szabo
On Wed, 19 May 2004, Jie Liang wrote: > According to the document of rule: > > CREATE RULE rulename AS ON delete TO mytablename DO > ( > delete from aaa where id=OLD.id; > Delete from bbb where id=OLD.id; > Delete from ccc where id=OLD.id > ); > > > Should work, but it doesn't, what wrong with it?

Re: [SQL] a wierd query

2004-05-17 Thread Stephan Szabo
On Mon, 17 May 2004, Stijn Vanroye wrote: > Are you sure about that Edmund? > > I have the following query: > select distinct on (task_id, date) task_id, workhour_id, date from > ( > select task_id, workhour_id, begindate as date from workhour > UNION > select task_id, w

Re: [SQL] where is this problem (trigger)

2004-05-14 Thread Stephan Szabo
On Wed, 12 May 2004, Theodore Petrosky wrote: > I can not seem to update these rows because of the dot > in the jobnumber field. I have found that I can change > the dot to an underscore but I thought I would ask if > there is a better solution. > > here is the error: > > UPDATE jobinfo SET isbil

Re: [SQL] a wierd query

2004-05-13 Thread Stephan Szabo
On Fri, 14 May 2004, sad wrote: > On Thursday 13 May 2004 19:27, you wrote: > > sad wrote: > > > select distinct a as F from table > > > union > > > select distinct b as F from table; > > > > Note that UNION only returns the unique values of the union > > You can get repeated values by using UNION

Re: [SQL] update table where rows are selected by inner join?

2004-05-10 Thread Stephan Szabo
On Mon, 10 May 2004, Jeff Kowalczyk wrote: > I have two tables orders and customerpaymentnote, which keep denormalized > columns of the status in rows related by orderid. The column duplication > is intentional, to ease end-user ad-hoc queries. I don't understand the > UPDATE FROM clause at: > htt

Re: [SQL] Multi ordered select and indexing

2004-04-23 Thread Stephan Szabo
On Fri, 23 Apr 2004, Antal Attila wrote: > Hi! > > We have a complex problematic area. What is the simplest solution for > the next query type: > > SELECT * FROM tablename ORDER BY col1 ASC, col2 DESC; > > In our experience, postgres cannot use a multi-colum index on (col1, > col2) in this situa

Re: [SQL] trigger/for key help

2004-04-11 Thread Stephan Szabo
On Sat, 11 Apr 2004, Bret Hughes wrote: > S*t s*t s*t. I have managed to screw up the system tables trying to > delete a foreign key on a new table I was going to start using tomorrow. > > > elevating-# \d diag_logs > Table "diag_logs" > Column |

Re: [SQL] partial unique constraint

2004-04-06 Thread Stephan Szabo
On Tue, 6 Apr 2004, Robert Treat wrote: > Trying to come up with the proper syntax to meet the following criteria: > > create table foo (bar integer, baz boolean UNIQUE (bar, baz = true)); > > note the above syntax is not correct, but should demonstrate what i'm > trying to do; I want to add a un

Re: [SQL] group by not returning sorted rows

2004-04-05 Thread Stephan Szabo
On Mon, 5 Apr 2004, Bret Hughes wrote: > select cities.name as city, buildings.name as building, > pagename, > log_date , > sum(exhibition_count) as tot > from logrecords > join cities on (logrecords.city=cities.num) > join buildings on (logrecords.building=buildings.

Re: [SQL] fine grained trigger time specification...

2004-03-23 Thread Stephan Szabo
On Tue, 23 Mar 2004, Erik Thiele wrote: > On Tue, 23 Mar 2004 10:17:31 -0600 > Bruno Wolff III <[EMAIL PROTECTED]> wrote: > > > On Tue, Mar 23, 2004 at 15:19:13 +0100, > > Erik Thiele <[EMAIL PROTECTED]> wrote: > > > now sadly i am getting this kind of problem: > > > > > > > > > zeit=> insert in

Re: [SQL] special integrity constraints

2004-03-22 Thread Stephan Szabo
On Mon, 22 Mar 2004, Erik Thiele wrote: > On Mon, 22 Mar 2004 06:21:28 -0800 (PST) > Stephan Szabo <[EMAIL PROTECTED]> wrote: > > > > > On Mon, 22 Mar 2004, Erik Thiele wrote: > > > > However, foreign keys are implemented using "constraint trigg

Re: [SQL] special integrity constraints

2004-03-22 Thread Stephan Szabo
On Mon, 22 Mar 2004, Erik Thiele wrote: > On Mon, 22 Mar 2004 12:13:29 +0200 (EET) > Achilleus Mantzios <[EMAIL PROTECTED]> wrote: > > > O kyrios Erik Thiele egrapse stis Mar 22, 2004 : > > > > Did you check out the DEFERRABLE option on the constraint? > > > > DEFERRABLE > NOT DEFERRABLE > > This

Re: [SQL] Date format issue

2004-03-17 Thread Stephan Szabo
On Thu, 18 Mar 2004, Raman wrote: > In my query of time zone i have details of interval with me like '-9:00', > '+5:30' etc > > my problem is regarding the format of Date which i receive... ie. when I add > the interval field the results are like: > Query: > select current_date at TIME ZONE "inter

Re: [SQL] Object-relational features

2004-03-15 Thread Stephan Szabo
On Sat, 13 Mar 2004, Yasir Malik wrote: > For my object-relational database class I decided to use PostgreSQL > because it is my favorite database and it calls it self a ORDBMS. Little > did I know that it supports supports very little OR features. For > example, using "create type as" is totall

Re: [SQL] Inserting data in a table using sub-selects

2004-03-10 Thread Stephan Szabo
On Wed, 10 Mar 2004, Andreas Joseph Krogh wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi, I'd like to fill one table with the contents of another table. Mye schema > is like this: > > CREATE TABLE table1( > id serial NOT NULL PRIMARY KEY, > title varchar NOT NULL, > description v

Re: [SQL] Converting query to view - duplicate fields

2004-03-09 Thread Stephan Szabo
On Tue, 9 Mar 2004, Richard Grosse wrote: > Trying to convert the query below to a view. The problem is > despite it working as a query when trying to save it as a > view the database returns the error that the field tablealias.cmpname > is duplicated. (Which it is and has to be) You're going to

Re: [SQL] correlated multi-set update?

2004-03-09 Thread Stephan Szabo
On Tue, 9 Mar 2004, Marty Scholes wrote: > Hello, > > My company recently deployed Pg 7.4.1. on Solaris for an experimental > project and is using the experience to evaluate its viability for > migration from Oracle 7.0. > > While I like a lot of the features of Pg, one thing I noticed that > "se

Re: [SQL] returning a recordset from PLpg/SQL

2004-03-01 Thread Stephan Szabo
On Tue, 2 Mar 2004, Terence Kearns wrote: > Tom Lane wrote: > > Terence Kearns <[EMAIL PROTECTED]> writes: > > > >>I tried > >>RETURNS SETOF RECORD > >>but that doesn't work > > > > > > Sure it does, if you use it correctly. Better show us what you did. > > > >regard

Re: [SQL] Convert INT to INTERVAL?

2004-02-27 Thread Stephan Szabo
On Fri, 27 Feb 2004, Brian Knox wrote: > Is it possible within pl/pgsql, to convert an integer to an interval in > months? IE, if num_months is an INT set to 48, can it be converted to an > interval? You should be able to say something like num_months * INTERVAL '1 month' I believe. ---

Re: [SQL] Return more than a record

2004-02-26 Thread Stephan Szabo
On Thu, 26 Feb 2004, Kumar wrote: > Get the following from the groups > create or replace function ExpensiveDepartments() returns setof table1 as Note that at least the example with this name in the SetReturningFunctions guide seems to use setof int as the return type. > ' > declare > r tabl

<    1   2   3   4   5   6   7   8   >