Re: [SQL] 7.4 - FK constraint performance

2004-02-11 Thread Stephan Szabo
On Wed, 11 Feb 2004, ow wrote: PostgreSQL 7.4 on i386-linux-gnu, compiled by GCC 2.96 -- about 10 records CREATE TABLE my.Small ( id my.dint NOT NULL, code my.dvalue NOT NULL, CONSTRAINT pk_1 PRIMARY KEY (id), ) WITHOUT OIDS; -- about 80M rows CREATE TABLE my.Large ( id

Re: [SQL] [NOVICE] 'select nextval('seq_name');' in a function ?

2004-01-31 Thread Stephan Szabo
On Sat, 24 Jan 2004, Pragati Kenkare wrote: I am new to postgresql. Using PostgreSQL 7.3.2, I did the following. testdb#CREATE SEQUENCE principal_id increment 1 start 1000 cache 5; testdb#CREATE TABLE principal (principal_id int not null, name text, constraint pk_principal primary

Re: [SQL] Mechanics of Update:Cascade

2004-01-31 Thread Stephan Szabo
On Sat, 31 Jan 2004, beyaRecords - The home Urban music wrote: Hi, could someone please explain to me the mechanics of an UpDate:Cascade? Delete:Cascade I fully understand but not Update. I have 2 tables A and B. On B I have created a foreign key on user_id in both B and A for Update and

Re: [SQL] Sometimes referential integrity seems not to work

2004-01-31 Thread Stephan Szabo
On Mon, 26 Jan 2004, Enio Schutt Junior wrote: In a database I am working, I sometimes have to delete all the records in some tables. According to the referential integrity defined in the creation of the tables, postmaster should not delete the records, but it does. I have used the following

Re: [SQL] Sometimes referential integrity seems not to work

2004-01-31 Thread Stephan Szabo
On Sat, 31 Jan 2004, Tom Lane wrote: Stephan Szabo [EMAIL PROTECTED] writes: On Mon, 26 Jan 2004, Enio Schutt Junior wrote: In a database I am working, I sometimes have to delete all the records in some tables. According to the referential integrity defined in the creation of the tables

Re: [SQL] Empty String Comparison Standard compliant?

2004-01-30 Thread Stephan Szabo
On Fri, 30 Jan 2004, Christoph Haller wrote: Just a short question (PostgreSQL 7.3.4 on hppa-hp-hpux10.20, compiled by GCC 2.8.1) SELECT ('' 'GDMF') ; SELECT ('GDMF' ''); ?column? -- f (1 row) ?column? -- t (1 row) Are these results standard compliant? I

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Stephan Szabo
On Thu, 29 Jan 2004, Bruno Wolff III wrote: On Thu, Jan 29, 2004 at 15:29:11 +0200, Achilleus Mantzios [EMAIL PROTECTED] wrote: O kyrios Bruno Wolff III egrapse stis Jan 29, 2004 : As i see there was a thread http://archives.postgresql.org/pgsql-hackers/2003-05/msg00762.php dealing

Re: [SQL] query not using index for descending records?

2004-01-29 Thread Stephan Szabo
On Thu, 29 Jan 2004, Tom Lane wrote: Stephan Szabo [EMAIL PROTECTED] writes: I'd thought that I'd previously sent a message containing a set of definitions for the reverse opclasses (not meant for inclusion to the system because I was making SQL functions that basically did -normal

Re: [SQL] array_lower /array_prepend doubt

2004-01-21 Thread Stephan Szabo
On Wed, 21 Jan 2004, Rajesh Kumar Mallah wrote: can anyone explain why SELECT array_lower(array_prepend(0, ARRAY[1,2,3]), 1); returns 0 not 1 because tradein_clients=# SELECT array_prepend(0, ARRAY[1,2,3]); +---+ | array_prepend | +---+ | {0,1,2,3} |

Re: [SQL] Initially Deffered - FK

2004-01-19 Thread Stephan Szabo
On Fri, 16 Jan 2004 [EMAIL PROTECTED] wrote: Thanks for your reply. But, you will agree that result should be same JUST BEFORE and JUST AFTER commit ( assuming no one is working on the database and i am the only user connected.) If you use the definition we're using now, then no, the above

Re: [SQL] Initially Deffered - FK

2004-01-15 Thread Stephan Szabo
On Fri, 16 Jan 2004, Denis wrote: create table contact (id int constraint contact_pk primary key, name text ); create table address (id int constraint address_fk references contact(id) on delete cascade initially deferred, city text, pin text);

Re: [SQL] Interest IN problem on 7.4

2003-12-13 Thread Stephan Szabo
On Sat, 13 Dec 2003, pginfo wrote: Hi, I am using pg 7.4. Pls, see this test: tt07=# update a_cars set dog_or_free=0 where virtualen=0 and dog_or_free=4 and ids NOT IN ( select oc.ids_car_real from a_oferti_cars oc,a_oferti o where oc.IDS_oferti=o.ids and o.date_valid=9964) AND IDS =

Re: [SQL] simple LEFT JOIN giving wrong results ...

2003-12-11 Thread Stephan Szabo
On Thu, 11 Dec 2003, Marc G. Fournier wrote: I've got to be missing something obvious here ... I have two tables, on containing traffic stats, the other disk usage ... I want to do a JOIN in one query to give me the sum of traffic and average of storage ... seperately, the results are right

Re: [SQL] Validity check in to_date?

2003-12-02 Thread Stephan Szabo
On Tue, 2 Dec 2003, Iain wrote: T've been following this thread with interest because I have a related problem. Basically we are storing dates in CHAR fields with al the associated problems. I'd like to do it, but changing everything to date fields isn't practical for now, so as a stopgap

Re: [SQL] Seq Scans when index expected to be used

2003-11-29 Thread Stephan Szabo
On Sat, 29 Nov 2003, ow wrote: Am trying to find duplicate values in a large table (about 80M records). Somehow, none of the two (2) queries (see below) is using the index I_bca that, I believe, should've been used. As a side note, to help determine if it should be used, you probably want

Re: [SQL] Stored procedures and relations

2003-11-28 Thread Stephan Szabo
On Fri, 28 Nov 2003, FET wrote: Hi everybody, I have a stored procedure that drops table A and then creates table A again. The table A has no constraints on any columns. When I execute the stored procedure by saying: SELECT sp_myproc(); It gives me an error saying : Relation 68428 does not

Re: [SQL] How to quote date value?

2003-11-21 Thread Stephan Szabo
On Fri, 21 Nov 2003, Gaetano Mendola wrote: nobody wrote: I have found it in documentation, it is single quote. But it does not explain why SELECT '1/11/2003' AS InvoiceDate; returns unknown data type instead of date. (I haven't seen the original message yet, so I'm replying to a

Re: [SQL] Substrings by Regular Expression

2003-11-19 Thread Stephan Szabo
On Fri, 14 Nov 2003, Jim Drummey wrote: Hello- The 7.2 version distributed with RedHat 8.0 seems not to work for substrings and POSIX regular expressions. I think this should work pds= select substring( str1 from ',' ) from address; ERROR: pg_atoi: error in ,: can't parse , Am I

Re: [SQL] strange not deferrable behaviour

2003-11-17 Thread Stephan Szabo
On Mon, 17 Nov 2003, Tomasz Myrta wrote: I've got some tables defined as: create table xx ( some_column references master_table It means this column is defined by default: NOT DEFERRABLE, INITIALLY IMMEDIATE I tried replacing rows in this table by new ones as: set autocommit=off;

Re: [SQL] Addition and subtraction on BIT type

2003-11-17 Thread Stephan Szabo
On Mon, 17 Nov 2003, Yasir Malik wrote: Thank you for your reply. select int4(b'1001')::bit(32); gives the same result as what you gave. select int4(b'1001')::bit(4); gives the upper four bits, which are all zeroes. How would I get the lower four bits? I building bitmaps using plpgsql, and

Re: [SQL] Addition and subtraction on BIT type

2003-11-16 Thread Stephan Szabo
On Sun, 16 Nov 2003, Yasir Malik wrote: I think I am almost at a solution to my last question. I can do select int4(a) from test; to convert to an integer. So now addition and subtraction can be done between bit types. But how do I convert back to BIT type? If I do select

Re: [SQL] Dynamic Query for System functions - now()

2003-11-10 Thread Stephan Szabo
On Mon, 10 Nov 2003, Kumar wrote: select now()+ interval'1 month'; -- This is working fine. I wanna dynamically assign the interval number. i,e -- select now()+ interval'n month'; If n is an integer, I'd suggest something like select now() + n * interval '1 month'; rather than messing

Re: [SQL] pg 7.4.rc1, Range query performance

2003-11-10 Thread Stephan Szabo
On Mon, 10 Nov 2003, ow wrote: --- Stephan Szabo [EMAIL PROTECTED] wrote: I'm not sure that AK_abc is the best index for check a range on a and single values on b and c. I'd think that something like an index on (b,c,a) would probably be better for this purpose (without doing any

Re: [SQL] transaction processing after error in statement

2003-11-09 Thread Stephan Szabo
On Fri, 7 Nov 2003 [EMAIL PROTECTED] wrote: Whenever an error occurs within the transaction, PostgreSQL puts the whole transaction in an *ABORT* state, so that there is no difference at all between COMMITing or ROLLBACKing it. Even commands successfully carried out before the error ocurred

Re: [SQL] pg 7.4.rc1, Range query performance

2003-11-08 Thread Stephan Szabo
On Sat, 8 Nov 2003, ow wrote: Postgresql 7.4.rc1 on i686 pc linux compiled by gcc 2.06. All configuration settings are default. Hi, Trying to find a way to improve range query performance. The table Test has about 30 million records. -- DLong, Dtimestamp, Dint, etc are domains of the

Re: [SQL] Bug in Rule+Foreing key constrain?

2003-10-30 Thread Stephan Szabo
On Thu, 30 Oct 2003, Michele Bendazzoli wrote: I have found a strange behaviour that I don't know if is a bug or not. I have three tables: * abilitazione with a primary key of (comuneid, cassonettoid, chiaveid) * cassonetto with a primary key of (comuneid, cassonettoid) * chiave with a

Re: [SQL] update from select

2003-10-29 Thread Stephan Szabo
On Wed, 29 Oct 2003, Gary Stainburn wrote: Hi folks, don't know if it's cos of the 17 hours I've just worked (sympathy vote please) but I can't get this one worked out I've got table names with nid as name id field and nallowfollow flag. I've got a vehicles table with vowner pointing at

Re: [SQL] bug in working with TEXT constants ?

2003-10-28 Thread Stephan Szabo
On Tue, 28 Oct 2003, sad wrote: Good day. AFAIK PostgreSQL provides the type TEXT with 4-byte prefix length which is distinct to C's zero-terminated (char *) That's very good. Then I expect natural possibility to store texts having zero characters. If you want to store zero characters (or

Re: [SQL] plpgsql related question: intervals and variables

2003-10-21 Thread Stephan Szabo
On Tue, 21 Oct 2003, Josh Berkus wrote: heute := ''today''; Select Into vk ourcolumn From table where other = foo; If vk 0 Then vk_txt := ''Vorkuehlung notwendig''; ez := heute + interval ''vk days''; PL/pgSQL handles variable like SQL, not like PHP or Perl. You can't

Re: [SQL] UPDATE one table with values from another

2003-10-08 Thread Stephan Szabo
On Wed, 8 Oct 2003, Josh Berkus wrote: UPDATE commit_log_ports_elements X IIRC, PostgreSQL doesn't like aliases of the update table, so I think you'll need to spell it out in the WHERE. SET X.needs_refresh = CLP.needs_refresh, X.port_version = CLP.port_version,

Re: [SQL] Creating Index

2003-10-02 Thread Stephan Szabo
On Thu, 2 Oct 2003, CN wrote: I am trying to explain the meaning of tables and views: The tables in the first SELECT in the UNION of view1 are jorunal, whose rows are entered daily. The table in the second SELECT in the UNION of view1 is budget, whose rows use year+month as key. View1

Re: [SQL] Creating Index

2003-10-01 Thread Stephan Szabo
On Wed, 1 Oct 2003, CN wrote: Peter, Thanks a lot! Unqualified count() cannot use an index because it has to visit all the rows in the table. It is only for my test. In my real practice, queries like SELECT * FROM view1 WHERE year = 2003 AND month BETWEEN 10 AND 12 will be performed.

Re: [SQL] Creating Index

2003-10-01 Thread Stephan Szabo
On Wed, 1 Oct 2003, CN wrote: You do realize that extract returns a double precision value not an integer, and it's probably not going to be willing to push clauses down through the union where the types are different . Argh! I didn't noticed that. Thanks for the reminder. Let's do

Re: [SQL] SRF Functions don't want to return empty tuple

2003-09-29 Thread Stephan Szabo
On Mon, 29 Sep 2003, GRIMOIS Eric wrote: Hi I have a problem with SRF functions on a RedHat 8.0 system with PostgreSQL 7.3.2. Schema is following : CREATE TABLE public.agents ( numero_age int4 NOT NULL, nom_age varchar(30) NOT NULL, prenom_age varchar(30) NOT NULL,

Re: [SQL] SRF Functions don't want to return empty tuple

2003-09-29 Thread Stephan Szabo
On Mon, 29 Sep 2003, GRIMOIS Eric wrote: On Mon, 29 Sep 2003, GRIMOIS Eric wrote: CREATE TABLE public.agents ( numero_age int4 NOT NULL, nom_age varchar(30) NOT NULL, prenom_age varchar(30) NOT NULL, date_entree_age date NOT NULL, identite varchar(50),

Re: [SQL] Case Insensitive comparison

2003-09-24 Thread Stephan Szabo
On Wed, 24 Sep 2003, George A.J wrote: The main problems i am facing is that in sql server the text comparisons are case insensitive. how can i compare text case insensitive in postgresql without using an upper() or lower() function in both sides (=). Is there any option to set in

Re: [SQL] Problem with timestamp - Pls help

2003-09-19 Thread Stephan Szabo
On Fri, 19 Sep 2003, Kumar wrote: Dear Friends, I am using Postgres 7.3.4 on Linux server 7.3. I wanted to update one column of my table with now() or timestamp. And I want that timestamp of format 2003-09-19 18:39:08.13 I think select CAST(CURRENT_TIMESTAMP(0)

Re: [SQL] Problem with timestamp - Pls help

2003-09-19 Thread Stephan Szabo
On Fri, 19 Sep 2003, Stephan Szabo wrote: On Fri, 19 Sep 2003, Kumar wrote: Dear Friends, I am using Postgres 7.3.4 on Linux server 7.3. I wanted to update one column of my table with now() or timestamp. And I want that timestamp of format 2003-09-19

Re: [SQL] transaction locking

2003-09-18 Thread Stephan Szabo
On Thu, 18 Sep 2003, tom baker wrote: ah, yes, i DID not see the NOT. that is fixed. here is the code that is having problems (paired down; all error checking has been removed!) $res=pg_query( BEGIN TRANSACTION ) ; $sql = LOCK TABLE parts IN SHARE ROW EXCLUSIVE MODE ; $res = pg_query( $sql

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. and

Re: [SQL] How do I replace select ... into commands?

2003-09-11 Thread Stephan Szabo
On Fri, 12 Sep 2003, Richard Sydney-Smith wrote: I have a number of sybase procedures in which I use something like declare mx : integer; begin select max(field) from table into mx; return mx; end; Postgresql is telling me that select...into has not been implemented yet. what is the

Re: [SQL] Getting the return type right for SETOF

2003-08-30 Thread Stephan Szabo
On Sat, 30 Aug 2003, Dan Langille wrote: Hi folks, I'm playing with SETOF on functions. But I can't get the return type correct. What have I missed? A cast? CREATE OR REPLACE FUNCTION elementGet (text) RETURNS SETOF element_type AS ' select 1, \'test\', \'F\'

Re: [SQL] How to optimize this query ?

2003-08-28 Thread Stephan Szabo
On Wed, 27 Aug 2003, ProgHome wrote: You were right, Stephan ! The query below is still not correct ... because the second line shouldn't be shown ! Now I really don't know how I could rewrite this without a subquery because it doesn't seem to be possible with some LEFT or INNER joins ! Do

Re: [SQL] How to return a record set from function.

2003-08-28 Thread Stephan Szabo
On Wed, 27 Aug 2003, Kumar wrote: Dear Friends, I am newbie to Postgres. I am running 7.3.4 on Linux 7.3. I am using Pgadmin tool. I need to return the table rows via record set. Create table t1 (c1 int, c2 varchar, c3 varchar); Create or Replace function sel_t1 () returns setof records

Re: [SQL] How to join from two tables at once?

2003-08-26 Thread Stephan Szabo
On Mon, 25 Aug 2003, Joseph Shraibman wrote: How can I join on one table with join conditions refering to two tables? In this example p is missing an entry that corresponds to u. I want to select from u and p, but have entries in u that don't have an entry in p. The problem is I need to

Re: [SQL] Bug on parameter bigint in PL/PGSQL

2003-08-22 Thread Stephan Szabo
On Fri, 22 Aug 2003, Michele Bendazzoli wrote: I think i found a bug in PL/PGSQL: when i use a parameter bigint (int8) and call the function from psql an error message which says that the functioname(bigint) doesn't exist is displayed. If i turn the int8 to int4 all works fine ... I can't

Re: [SQL] Delete denied?

2003-08-22 Thread Stephan Szabo
On Fri, 22 Aug 2003, Josh Berkus wrote: Guys: Contributing could be that the table holding the deleted records is a child table with an ON CASCADE DELETE of one of the tables being updated elsewhere in the function. And the function works if called by the owner of the table (and the

Re: [SQL] Auto-update a field when record is changed

2003-08-22 Thread Stephan Szabo
On Fri, 22 Aug 2003, Stuart wrote: Folks, I was wandering if there was a feasible way to automatically update a field in a table, say 'revision_date' in a record whenever any other field in the record is changed. My attempts to use a trigger caused repeating loops and bombed with

Re: [SQL] SELECT IN Still Broken in 7.4b

2003-08-21 Thread Stephan Szabo
On Thu, 21 Aug 2003, Dani Oderbolz wrote: Stephan Szabo wrote: On Wed, 20 Aug 2003, Rod Taylor wrote: ... Is the temp table version any faster? I realize it has a higher limit to the number of items you can have in the list. Within the scope of the new hashed IN stuff I believe

Re: [SQL] SELECT IN Still Broken in 7.4b

2003-08-20 Thread Stephan Szabo
On Wed, 20 Aug 2003, Mike Winter wrote: I'm sure many on this list are sick of hearing about this problem, but it was on the fix list for 7.4, but doesn't appear to have been changed. IN (subselect) was changed for 7.4 (although I'm not sure of the list mentions the difference). I don't know

Re: [SQL] SELECT IN Still Broken in 7.4b

2003-08-20 Thread Stephan Szabo
On Wed, 20 Aug 2003, Rod Taylor wrote: Thanks, Stephan. I was really hoping that the IN(valuelist) was going to be changed at the same time, because it really is unusable for anything over a couple of thousand values. Changed to do what? One possibility might be to act as if the

Re: [SQL] SELECT IN Still Broken in 7.4b

2003-08-20 Thread Stephan Szabo
On Wed, 20 Aug 2003, Rod Taylor wrote: On Wed, 2003-08-20 at 17:41, Stephan Szabo wrote: On Wed, 20 Aug 2003, Rod Taylor wrote: Thanks, Stephan. I was really hoping that the IN(valuelist) was going to be changed at the same time, because it really is unusable for anything over

Re: [SQL] Optional join

2003-08-15 Thread Stephan Szabo
On Thu, 14 Aug 2003, Slawek Jarosz wrote: Hi, I trying to write a query that will join 2 tables. Here's the concept: Table 1: table1, primary key pk1 Table 2: table2, primary key pk2 One of the fields (f2) in table2 contains either the primary key of table1 or a NULL value. So

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-14 Thread Stephan Szabo
On Mon, 11 Aug 2003, BenLaKnet wrote: we make a dump before ... and with a product pgmanager (ems tech) we do not show any foreign keys. That's possible, I'd have guessed that it should be dumping the triggers as CREATE CONSTRAINT TRIGGER commands in the dump. But I think all of triggers of

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
that is not equal to 21101. -Original Message- From: Stephan Szabo [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 1:10 PM To: Franco Bruno Borghesi Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [SQL] How to optimize this query ? On 13 Aug 2003, Franco Bruno

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On Tue, 12 Aug 2003, Franco Bruno Borghesi wrote: I *guess* this query does the same as yours (please verify). It does not in general unfortunately. :( I see two possible problems. The first is that by using an inner join you're going to lose any rows where there is no match on the right hand

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On 13 Aug 2003, Franco Bruno Borghesi wrote: Maybe its better now. Anyway, what I think is that joining will perform better than using IN. Am I wrong? Generally that's true (for 7.3 and earlier). For 7.4 IN has gotten much better, and you probably want to retry with IN. However, it's

Re: [SQL] How to speeed up the query performance

2003-08-14 Thread Stephan Szabo
On Thu, 14 Aug 2003, Abdul Wahab Dahalan wrote: Hai Chris! Thanks for the solution but seem it doesnt work. (0 rows) returned when I used NOT EXITS but (4 rows) returned when NOT IN is used... Maybe you need a set of parenthesis around the old conditions because of the or.

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On 12 Aug 2003, krysto wrote: Hi all I have to optmize this query, because it takes a while to run (about 30s) Here are the tables (with the keys): affiliate_lockout (6 rows) (member_id, affiliate_id) lead (4490 rows) (id, ...) member (6 rows) (id, ...)

Re: [SQL] How to optimize this query ?

2003-08-14 Thread Stephan Szabo
On Wed, 13 Aug 2003, ProgHome wrote: select member.id, automated.delivery, member.email from (automated INNER JOIN member ON member.id = automated.member_id) where activated=1 and website='$SITE_NAME' and (select count(*) from trans_member where

Re: [SQL] lower/upper functions and strings in searches

2003-08-14 Thread Stephan Szabo
On Thu, 14 Aug 2003, Gregory S. Williamson wrote: I am obviuously doing some newbie trick, and I ordinarily would spend time browing the archives, but the archives.postgresql.org site seems to be absurdly slow. This is 7.3.3 on a linux box. I have a bunch of data with state, city, county

Re: [SQL] sub-sel/group problem

2003-08-14 Thread Stephan Szabo
On Mon, 11 Aug 2003, Gary Stainburn wrote: I don;t know if it's cos it's Monday or what, but I can't see what's wrong here. I've got two tables, turns which holds a turn number, a task, and where appropriate a link to a loco. The select below works but only shows those tasks where a loco

Re: [SQL] [ADMIN] Why table has drop, but the foreign key still there?

2003-08-14 Thread Stephan Szabo
On Wed, 13 Aug 2003, Raymond Chui wrote: Here are the simple things I did create table state ( state_code char(2) not null, state varchar(15) not null, primary key (state_code) ); create table whitepage ( user_id char(8) not null, email varchar(50), telephone

Re: [SQL] [ADMIN] string function -- replace needs a clear doc

2003-08-14 Thread Stephan Szabo
On Mon, 11 Aug 2003, Jie Liang wrote: 1. No doc said % should escape by %%, and select replace('whatever%20sites','%20','%%20') won't work also. 2. v7.3.2 haven't resolved this problem yet, I am not sure the later version. I seem to get the expected results on my 7.3.4 system.

Re: [SQL] [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3

2003-08-09 Thread Stephan Szabo
On Fri, 8 Aug 2003, BenLaKnet wrote: When I duplicate this code in an other table named spectacle_v without Foreygn key ... all is running. But when I try to delete a spectacle_membre, linked value in spectacle are correctly deleted, but I have an error for spectacle_v which is not linked :

Re: [SQL] How to check: is some key referenced from sometable

2003-08-09 Thread Stephan Szabo
On Sun, 10 Aug 2003, eVl One wrote: Hello, Bruno. You wrote 9 08 2003, 18:08:09: BWI On Mon, Aug 04, 2003 at 11:17:56 +0300, BWI [EMAIL PROTECTED] wrote: Please help. Need a boolean function which returns true if given key in table is referensed from another table(s). BWI Use

Re: [SQL] time precision.

2003-07-30 Thread Stephan Szabo
On Wed, 30 Jul 2003, Anagha Joshi wrote: Hi All, I'm using PG-7.2.4 on Solaries. When I do: template1=# select time(6576); ERROR: TIME(6576) precision must be between 0 and 13 Where am I wrong? IIRC time(n) refers to the type time with a precision of n and n is limited as stated by the

Re: [SQL] Fwd: Bad Join moment - how is this happening?

2003-07-30 Thread Stephan Szabo
On Wed, 30 Jul 2003, Jamie Lawrence wrote: I have a view: create or replace view addenda as select documents.id, documents.oid, documents.projects_id, documents.doc_num, documents.description, documents.date,

Re: [SQL] Can a table have a reference to itself?

2003-07-27 Thread Stephan Szabo
On Wed, 23 Jul 2003, Oliver Duke-Williams wrote: I'd like to have a table in which one column has an integrity reference to another column within the same table, and for updates to the primary column to be cascaded. The former aspect seems to work OK, but the latter does not. I think you

Re: [SQL] [GENERAL] Query analyse

2003-07-25 Thread Stephan Szabo
On Fri, 25 Jul 2003, Elielson Fontanezi wrote: First of all, my envoronment is: Linux netlab142.prodam 2.4.8-26mdk #1 Sun Sep 23 17:06:39 CEST 2001 i686 unknown pg_ctl (PostgreSQL) 7.2.1 I would like some suggestions on how to speed up a query. Both of the

Re: [SQL] ERROR: DefineIndex: index function must be marked iscachable

2003-07-25 Thread Stephan Szabo
On Fri, 25 Jul 2003, Elielson Fontanezi wrote: What can I do in this case? I could not found anything about iscachable. postgres$ cat in.sql create index bt_proposta_f01 on proposta using btree (func_cod_secretaria(nr_proponente)); postgres$ psql -d escola -f in.sql

Re: [GENERAL] [SQL] ERROR: DefineIndex: index function must be

2003-07-25 Thread Stephan Szabo
On Fri, 25 Jul 2003, Stephan Szabo wrote: On Fri, 25 Jul 2003, Elielson Fontanezi wrote: What can I do in this case? I could not found anything about iscachable. postgres$ cat in.sql create index bt_proposta_f01 on proposta using btree (func_cod_secretaria(nr_proponente

Re: [SQL] [GENERAL] ERROR: DefineIndex: index function must be marked

2003-07-25 Thread Stephan Szabo
On Fri, 25 Jul 2003, Elielson Fontanezi wrote: Who can help me on that? First of all, my envoronment is: Linux netlab142.prodam 2.4.8-26mdk #1 Sun Sep 23 17:06:39 CEST 2001 i686 unknown pg_ctl (PostgreSQL) 7.2. You should definately move to the highest 7.2 release

Re: [SQL] min() and NaN

2003-07-22 Thread Stephan Szabo
On Tue, 22 Jul 2003, Bruce Momjian wrote: Well, my 2 cents is that though we consider NULL when ordering via ORDER BY, we ignore it in MAX because it really isn't a value, and NaN seems to be similar to NULL. When doing ORDER BY, we have to put the NULL value somewhere, so we put it at the

Re: [SQL] min() and NaN

2003-07-20 Thread Stephan Szabo
On Sun, 20 Jul 2003, Tom Lane wrote: Michael S. Tibbetts [EMAIL PROTECTED] writes: I'd expect the aggregate function min() to return the minimum, valid numeric value. Instead, it seems to return the minimum value from the subset of rows following the 'NaN'. Not real surprising given

Re: [SQL] changing an update via rules

2003-07-20 Thread Stephan Szabo
On 15 Jul 2003, Lauren Matheson wrote: Hello, I am having difficulty setting an on update rule which seems to be caught in a recursive loop. Context is a table with three columns assigning users to groups with the third column being boolean to flag the primary group. I would like to set

Re: [SQL] min() and NaN

2003-07-20 Thread Stephan Szabo
On Tue, 15 Jul 2003, Michael S. Tibbetts wrote: Hi, I have a table containing a double precision column. That column contains at least one judiciously placed NaN. I'd expect the aggregate function min() to return the minimum, valid numeric value. Instead, it seems to return the minimum

Re: [SQL] Problem with temporary table -- Urgent

2003-07-19 Thread Stephan Szabo
On Thu, 10 Jul 2003, Vijay Kumar wrote: Hi, We are using postgresql 7.3.3, we are encountering the following problems when we used temporary tables. Here with i'm sending my Sample function. create or replace function TestTemp_refcur(refcursor) returns refcursor As ' declare refc alias

Re: [SQL] [HACKERS] plpgsql strangeness with select into variable

2003-07-18 Thread Stephan Szabo
On Fri, 18 Jul 2003, Josh Berkus wrote: I'm debugging a trigger in plpgsql and for some reason or the select into var does not seem to work. Here is an unaltered snippet of my trigger code: raise notice ''this id : %'',NEW.id; select into i_hierarchy_id

Re: [SQL] parse error for function def

2003-07-17 Thread Stephan Szabo
On Thu, 17 Jul 2003, Terence Kearns wrote: CREATE FUNCTION base.fn_fkey_check(text, text, int4) RETURNS bool AS 'DECLARE BEGIN RETURN (SELECT count($1) FROM $2 where $1 = $3)::bool; END;' LANGUAGE 'sql'; produces this error ERROR: parser: parse error at or near RETURN at character

Re: [SQL] ad hoc referential integrity

2003-07-14 Thread Stephan Szabo
On Tue, 15 Jul 2003, Matt Tenenbaum wrote: Say I created a couple tables A and B, where A contains a column p which B references as a foreign key. Further say that, when I created these tables, I meant to specify 'on delete cascade' for p in the definition of B but didn't. What's the proper

Re: [SQL] max length of sql select statement ?

2003-07-07 Thread Stephan Szabo
On 7 Jul 2003, markus brosch wrote: I was searching the archive and was wondering why nobody asked this strange(!) question (or I've not found it?): What is the max allowed length of a sql statement or query? AFAIR in recent versions it's effectively limited only by resources (how much

Re: [SQL] avoid select expens_expr(col) like unneccessary calculations

2003-07-07 Thread Stephan Szabo
On 8 Jul 2003, Markus Bertheau wrote: when you have select expensive_expression(column), * from table offset 20 limit 40 can you somehow save the cost for the first 20 calculations of expensive_expression? Right now the only way I can think of that might work is to push the offset/limit

Re: [SQL] CREATE SEQUENCE fails in plpgsql function

2003-06-30 Thread Stephan Szabo
On Mon, 30 Jun 2003, Erik Erkelens wrote: new_max_records ALIAS FOR $1; BEGIN DROP SEQUENCE my_sequence; --CREATE SEQUENCE my_sequence MAXVALUE 4 CYCLE; CREATE SEQUENCE my_sequence MAXVALUE new_max_records CYCLE; Most of the creates/drops/etc... don't

Re: [SQL] database table size

2003-06-24 Thread Stephan Szabo
On Wed, 25 Jun 2003, Anagha Joshi wrote: 4. the file '2078989' corresponds to 'cdrrec' file (table) $ ls -l 2078989 -rw--- 1 postgres postgres 2359296 Jun 24 17:18 2078989 This means table 'cdrrec' takes approx. 2030.2626953125 KB i.e. approx. 2MB Table is like this:

Re: [SQL] Trouble porting a Oracle PL/SQL procedure to PL/pgSQL

2003-06-16 Thread Stephan Szabo
On Mon, 16 Jun 2003, Tony G. Harris wrote: Hello. I'm using PostgreSQL to learn SQL and SQL-based languages. The text I'm using (SAMS Teach Yourself SQL in 21 Days, 3rd.ed.) references Oracle in its examples, though I can usually get PostgreSQL to work almost as well. Well, I'm almost to

Re: [SQL] create tables within functions

2003-06-13 Thread Stephan Szabo
On Fri, 13 Jun 2003, Demidem Mohamed Amine wrote: hello, Can anyone help me create a function that creates a table, in this way for example : See EXECUTE for a way to execute a query that you've built into a string, for example, something like: EXECUTE ''create table '' || $1 || '' (id

Re: [SQL] control structures in plpgsql

2003-06-12 Thread Stephan Szabo
On 12 Jun 2003, Robert Treat wrote: Does anyone know if there is support for IF x OR y THEN syntax in plpgsql? The docs just say IF [boolean expression] then. which loosely interpreted could allow for an OR, but I couldn't seem to get it to work. TIA, Can you give a full example of what

Re: [SQL] Some Questions

2003-06-12 Thread Stephan Szabo
On Thu, 12 Jun 2003, Ludwig Lim wrote: I would like to ask the following questions: a) Are foreign key constraint triggers guaranteed to execute first before any ordinary BEFORE INSERT/UPDATE/DELETE trigger is executed? (This is assuming that the foreign keys are declared as NOT

Re: [SQL] simulating partial fkeys.. [ATTN Developers please]

2003-06-07 Thread Stephan Szabo
On Fri, 6 Jun 2003, Richard Huxton wrote: On Thursday 05 Jun 2003 3:55 pm, [EMAIL PROTECTED] wrote: hi , Is there any way to enforce fkeys only on subset of the table something on the lines of unique partial indexes I'm afraid not (AFAIK). What might be a solution in your case is to

Re: [SQL] join/case

2003-05-31 Thread Stephan Szabo
On Fri, 30 May 2003, jtx wrote: Hi everyone, I'm trying to do a left join on two tables, mainly because data from table 'b' (lists) may or may not exist, and if it doesn't I want results. However, if data from table lists DOES exist, I want to run a conditional on it, and then return data

Re: [SQL] record datatype - plpgsql

2003-05-30 Thread Stephan Szabo
On Thu, 29 May 2003, Brian Knox wrote: Given a variable of the record data type in pl/pgsql, is it possible to get the names of the columns ( attributes ) of that record? eg, given record NEW for table foo, is there a way to get information concerning the columns that make up that record?

Re: [SQL] bad query performance

2003-05-14 Thread Stephan Szabo
On Mon, 12 May 2003, Didrik Pinte wrote: Here is the query : SELECT profiles_et.username, profiles_et.name, profiles_et.firstname, profiles_et.email, company_et.name AS company, count(logs_et.dt) AS cnt,

Re: [SQL] timestamp with postgresql 7.3

2003-04-04 Thread Stephan Szabo
On Fri, 4 Apr 2003, Claude wrote: I have a table a field with timestamps in seconds since epoch and I would like to get a human readable date... but it seems that postgresql 7.3 does not support the datetime(), timestamp(), timestamptz() functions... I'd say probably something like:

Re: [SQL] Complex outer joins?

2003-03-26 Thread Stephan Szabo
On Wed, 26 Mar 2003, Tom Lane wrote: Stephan Szabo [EMAIL PROTECTED] writes: On 26 Mar 2003, Greg Stark wrote: Can you show an example where the join order would affect the result set? I can't think of any. I can think of a few somewhat degenerate cases. I don't think you need

Re: [SQL] Any limitation in size for return result from SELECT?

2003-03-01 Thread Stephan Szabo
On Tue, 25 Feb 2003, Natasa Bulatovic wrote: Select statement returns as a result concatenated all varchar, text and char columns of a table as one single column ... select col1||col2||col3||.||col100 from table However, when the number of concatenated columns is bigger than 22 no

Re: [SQL] pgsql problem

2003-02-27 Thread Stephan Szabo
On Wed, 26 Feb 2003, Grignon Etienne wrote: test=# SELECT createuser('toto', true, true, true); NOTICE: Begin Of Update Permissions NOTICE: End Of Update Permissions NOTICE: TRIGGER createuser 0 (1 row) test=# My problem is that the trigger for the insert

Re: [SQL] Sub Select inside Check ?

2003-02-25 Thread Stephan Szabo
On Tue, 25 Feb 2003, Rudi Starcevic wrote: I'm trying to create this table with a Check that fails. I'm using 'Check' instead of 'References' due to poor db schema ( before me .. ) Here is my error message: ERROR: cannot use subselect in CHECK constraint expression CREATE TABLE

Re: [SQL] [BUGS] 7.3 GROUP BY differs from 7.2

2003-02-22 Thread Stephan Szabo
On Fri, 21 Feb 2003, Tom Lane wrote: Dan Langille [EMAIL PROTECTED] writes: This is the query in question: SELECT element_id as wle_element_id, COUNT(watch_list_id) FROM watch_list JOIN watch_list_element ON watch_list.id = watch_list_element.watch_list_id WHERE

Re: [SQL] [BUGS] 7.3 GROUP BY differs from 7.2

2003-02-22 Thread Stephan Szabo
On Sat, 22 Feb 2003, Tom Lane wrote: Stephan Szabo [EMAIL PROTECTED] writes: On Fri, 21 Feb 2003, Tom Lane wrote: Anyone care to offer a gloss on the spec to prove that this behavior is correct or not correct? Hmm, I'd read SQL92 Section 7.5 (joined tables) Syntax Rules as saying

<    1   2   3   4   5   6   7   >