Re: [SQL] What do I do with this error?

2001-03-18 Thread Stephan Szabo
Using the below (with a few fixes, delcare->declare and adding the close quote and language type as plpgsql, and a table1 defined as id int, field1 varchar, field2 varchar, I get a NULL returned if I select test1(); I'm somewhere between beta4 and 5 though. On Sun, 18 Mar 2001, Josh Berkus wrote

Re: [SQL] serial type question

2001-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2001, postgresql wrote: > I have a table that I want to add a serial type column. Is there a way > to add it or do I have to create a new table and insert into it. I have > experimented with: > > insert into newdb (name) select name from olddb order by jobno; > > however, pg d

Re: [SQL] Manual Trigger Creation

2001-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2001, Josh Berkus wrote: > Tom, Stephan. List folks: > > I'm having a great deal of trouble with the automated constraint > triggers as implemented in 7.1 beta 3. I find that if I establish a > foriegn key through the CREATE TABLE statement, things start to blow up > if I mo

Re: [SQL] Manual Trigger Creation

2001-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2001, Josh Berkus wrote: > Stephan, > > > Yeah, it doesn't play nice with alter table at all. :( > > Actually, for recreating -- All you really need to do is kill the > > three triggers that it creates (drop trigger should work) and use > > alter table to add them again. > > How

Re: [SQL] count() and multiple tables

2001-03-19 Thread Stephan Szabo
On Mon, 19 Mar 2001, Joseph Shraibman wrote: > I want to select all the entries from d that have at least one > corresponding entry in u that meets my conditions. The problem is that > count(*) is returning the number of corresponding entries in u, and I > want only the number of entries in d.

Re: [SQL] count() and multiple tables

2001-03-19 Thread Stephan Szabo
> > And postgres tries to be helpful again... :( [I *really* dislike this > > adding to from list thing] Technically the above should be illegal > > because no from list contains u or a. Postgres is adding them to the > > from list for you. > > > I get the same result if I do: > select count(d

Re: [SQL] Foreign key referencing subclasses.

2001-03-22 Thread Stephan Szabo
On Thu, 22 Mar 2001, [iso-8859-1] Johannes Grødem wrote: > Hi, > > it seems I can't have a foreign key that references some subclass. Postgres > says it can't figure out what its primary key is. The primary key is defined > in the superclass. Unique/primary key doesn't inherit to subclasses.

Re: [SQL] Hi there, having problems with the following:

2001-03-25 Thread Stephan Szabo
You'll probably want something like null::varchar (or other appropriate type) for the nulls. It's trying to grab the type from the first select and can't figure the type out for the null. (Technically speaking, it's probably supposed to be CAST(NULL AS VARCHAR) to be technically sql complient,

Re: [SQL] about raise exception

2001-03-25 Thread Stephan Szabo
On Mon, 26 Mar 2001, Jack wrote: > According to user guide, both Raise Notice & Raise Exception will write > message to database log. Which system table is the database log about? It's actually generally on either STDERR or sent to syslog depending on configuration. > By the way what is the di

Re: [SQL] is it me or trigger side effects

2001-03-26 Thread Stephan Szabo
> create function updateCat() returns opaque as ' > declare > rec record; > rename new to cat; > rename old to ct; > maxlen integer; > > begin > if tg_op = ''INSERT'' and cat.category is null then > raise exception ''You are missing entry for category field'';

Re: [SQL] DELETE FROM fails with error

2001-03-28 Thread Stephan Szabo
I was going to guess that it was something related to the foreign key, but I can't imagine why that would be affected by a delete on the referencing table (there shouldn't be a trigger there anyway). Can you send full schema with constraints for the tables? On Wed, 28 Mar 2001, chris Günther wr

Re: [SQL] is this proper sql?

2001-04-17 Thread Stephan Szabo
On Tue, 17 Apr 2001, clayton cottingham wrote: > hi one of the developers here at work say this should work > insert into detail (det_id,det_mas_id,det_date,det_amt) values > (0,0,now(),'0'), (1,1,now(),'1'); > > > > but when i try that in postgres like: > insert into detail (det_id,det_ma

Re: [SQL] Subqueries in select clause

2001-04-18 Thread Stephan Szabo
On Wed, 18 Apr 2001, Sara Cohen wrote: > The Problem: > > > I would like to use a subquery that returns one column, but more than one > tuple. The result of this subquery is then used in an aggregate function. > > For example, suppose I have a table c, with columns a and b of > num

Re: [SQL] breakage in schema with foreign keys between 7.0.3 and7.1

2001-04-18 Thread Stephan Szabo
On Wed, 18 Apr 2001, Stef Telford wrote: > CREATE TABLE action > ( > ORDER_IDintegerPRIMARY KEY, > ORDERTYPE integerNOT NULL, > client_idchar(16)NOT NULL, > priority integerDEFAULT 5

Re: [SQL] RI permission problem

2001-04-25 Thread Stephan Szabo
On Wed, 25 Apr 2001, Kyle wrote: > Peter Eisentraut wrote: > > > Kyle writes: > > > > > Is there a way to get this to work without granting update to table b? > > > > Update to 7.1.] > > I'm on 7.1. Should an RI trigger under 7.1 run as the DBA or as the current > user? IIRC, only the checks

Re: [SQL] must I create the function check_primary_key ?

2001-04-25 Thread Stephan Szabo
On Wed, 25 Apr 2001, Peter J. Schoenster wrote: > I want to use this referential integrity etc. that I've never used in > mysql ... so I tried many things and looked here and there ... My > example below produces this error: > > > CreateTrigger: function check_primary_key() does not exist >

Re: [SQL] Regular expressions and indexes

2001-04-27 Thread Stephan Szabo
On Fri, 27 Apr 2001, [iso-8859-1] Hans-Jürgen Schönig wrote: > Is there any possibility to make PostgreSQL use indexes when working > with regular expressions? > > performance=# EXPLAIN SELECT * FROM perftest WHERE id=100; > NOTICE: QUERY PLAN: > > Index Scan using idx_id_perftest on perftest

Re: [SQL] Alter Table problems

2001-04-27 Thread Stephan Szabo
On Fri, 27 Apr 2001, Scott David Walter wrote: > I am attempting to add a few attributes to an existing table that already > contains data. The problem that I am having is that the new attributes > that I want to add need to be forgein key references to other tables. I > can't figure out how to

Re: [SQL] Dateadd

2001-05-04 Thread Stephan Szabo
On Wed, 2 May 2001, Ligia Pimentel wrote: > I need to know if there is a sql function implemented in postgres that gives > me a date plus any number of days, months or years (the traditional dateadd > function) or how to do it in sql? Just add a date and an interval. Something like: date + '1

Re: [SQL] 7.1 REFERENCES contstraints

2001-05-06 Thread Stephan Szabo
On Sun, 6 May 2001, Michael Richards wrote: > I see that the REFERENCES constraint is a little more restrictive in > 7.1. I need to have a table with a constraint so one of it's columns > must exist in a second table. This is not a key, since there may be N > columns in the second table that m

Re: [SQL] Constraints...

2001-05-12 Thread Stephan Szabo
Yes. It depends on what exactly you want for the update/delete cases on permissions. I believe that in any cases you can use the check function that's used by the fk implementation to do the insert/update check on objects. If you don't mind update/deletes on permission failing if the row being

Re: [SQL] [Fwd: [Gborg-bugs] BUG: reference error when using inheritedtables (ID: 269) (new)]

2001-05-16 Thread Stephan Szabo
> I have a problem with inherited refences. > For example : > CREATE TABLE A(LNR integer Primary key blabla); > CREATE TABLE B () INHERITS(A); > CREATE TABLE C(LNR integer primary key blabla, RNR Intger not null, > unique(RNR), FOREIGN KEY(RNR) REFERENCES A.LNr ON DELETE CASCADE); > will throw a

Re: [SQL] sequence problem

2001-05-21 Thread Stephan Szabo
On Mon, 21 May 2001, gabi munteanu wrote: > I have the following problem. > > I have a table [friends] and it looks like this: >id serial >name varchar(25) >phone varchar(15) > After I created it tehre is also a sequence that generates me the ids > friens_id_s

Re: [SQL] Select question

2001-05-23 Thread Stephan Szabo
I'm not sure, but... Does it work if you say cdate > '2001-05-18' ? (Possibly ::date too) I'd guess your date value you're trying to put there is getting treated as an integer expression. On Wed, 23 May 2001, Chris Ruprecht wrote: > Hi all, > > although not new to databases, I'm new to the wo

RE: [SQL] primary key scans in sequence

2001-05-30 Thread Stephan Szabo
On Wed, 30 May 2001, Koen Antonissen wrote: > Now this one doesn't: > Table "teams" > Attribute | Type | Modifier > ---+-+-- > id| integer | not null

Re: [SQL] Case Insensitive Queries

2001-05-30 Thread Stephan Szabo
On Wed, 30 May 2001, Tom Lane wrote: > Mark <[EMAIL PROTECTED]> writes: > > It appears that the behavior of a bpchar compare with a string literal > > is not implicitly trimming the bpchar before the compare, which IMHO is > > incorrect behavior. Is my opinion valid? > > regression=# create tab

Re: [SQL] Case Insensitive Queries

2001-05-30 Thread Stephan Szabo
On 30 May 2001, Mark wrote: > On 30 May 2001 11:16:35 -0700, Stephan Szabo wrote: > > On Wed, 30 May 2001, Tom Lane wrote: > > > > > Mark <[EMAIL PROTECTED]> writes: > > > > It appears that the behavior of a bpchar compare with a string literal >

RE: [SQL] primary key scans in sequence

2001-05-31 Thread Stephan Szabo
It really depends on the number of rows. If the number of rows in the tables are small or the number of rows returned is a reasonable percentage, the index scan is currently more expensive. What does (for example) select count(*) from classes; give? On Thu, 31 May 2001, Koen Antonissen wrote:

Re: [SQL] query on two databases ..

2001-06-05 Thread Stephan Szabo
There is currently no ability to span databases in a single query. On Wed, 30 May 2001, Muhammed Yazici wrote: > hi, > i'am really new to postgresql and i try it with php .. > > Now i have following question : > > is it possible to make one query on two databases. I have a database calles > d

Re: [SQL] Distinct Values

2001-06-05 Thread Stephan Szabo
On Wed, 30 May 2001, Nicolas wrote: > Hi, > > I'm trying to retreive DISTINCT Values from a two colomn table called > "Books". The colomns are named "Author" and "URL". > DISTINCT values should be retieved from the "Author" Colomn , and then I > should be able to retrieve the corresponding URL.

Re: [SQL] Tutorial : using foreign keys, retrictions etc

2001-06-06 Thread Stephan Szabo
On Sat, 2 Jun 2001, Mario Bittencourt wrote: > Hi, > > I've decided to switch from mysql to postgresql as my database server. I > do mostly web programming (who doesnt these days?) with more than a 100 > sites developed (using mysql). > > I've read about postgresql and it's fe

Re: [SQL] audit trail and system catalogs

2001-06-06 Thread Stephan Szabo
On Wed, 6 Jun 2001, Markus Wagner wrote: > The problem is, how to get the names of all tables and their attributes? I > looked into the system tables ("pg_*"), but there were many tables and > many attributes for *my* tables, and I did not figure out how to > distinguish my tables and my attr

Re: [SQL] Cascade constraint gone!!!

2001-06-06 Thread Stephan Szabo
On Wed, 6 Jun 2001, Linh Luong wrote: > I recently wipe my database away. And some of the tables have a UPDATE > CASCADE on it to another table. > When I reload the data from my backup that I did with pg_dumpall. My > code started to give me an error because I tried to modify a table that > w

Re: [SQL] behavior of ' = NULL' vs. MySQL vs. Standards

2001-06-06 Thread Stephan Szabo
On Wed, 6 Jun 2001, Mark Stosberg wrote: > > Hello, > > I'm a long time Postgres user who uses MySQL when I have to. I recently > ran into an issue with MySQL where this construct didn't do what I expect: > > WHERE date_column = NULL > > I expected it to work like "date_column IS NULL" like i

Re: [SQL] dropping constraints

2001-06-07 Thread Stephan Szabo
You probably need to make sure to double quote the tgname in your drops. On Thu, 7 Jun 2001, Linh Luong wrote: > Hi, > > Is there to drop a constraint when you add it separately with an alter > statement. > > alter table failuretypecategory1 add constraint fk_failuretypecategory1 > FOREIGN K

Re: [SQL] Are SQL commands "atomic" ?

2001-06-07 Thread Stephan Szabo
On Thu, 7 Jun 2001, Gerald Gutierrez wrote: > > I'm using 7.1.1 right now, and have the following table: > > id | s > +--- >1 | alpha >2 | beta >3 | gamma >4 | delta > (4 rows) > > I'd like to switch the id of "beta" to 3 and the id of "gamma" to 2 ("flip" > them).

Re: [SQL] UPDATE with concatenate

2001-06-07 Thread Stephan Szabo
Maybe this? update table set col = col || '$val'; On Thu, 7 Jun 2001, Laurent Patureau wrote: > Hy, > > I try to update a table:col with take the valueof this col and concatenate > it with $val. > I don't want to select all value of table:col and addition $val at each one > > I try : > > UP

Re: [SQL] Index usage

2001-06-08 Thread Stephan Szabo
On Fri, 8 Jun 2001, Subra Radhakrishnan wrote: > Hi All, > > The index created by me is not being used while doing > select. I found that out by using the EXPLAIN. For > example: > > Table department has > > dept_num > dept_desc > > > Table 'employee' looks like this: >

Re: [SQL] Integrity and Inheritance

2001-06-09 Thread Stephan Szabo
On 10 Jun 2001, Christophe Labouisse wrote: > I wanted to build the following schema : > > - one "generic" document table with a column doc_id ; > - a couple of "specific" document tables inheriting from doc ; > - a table refering a document by it's id with and integrity constraint > on it. > >

Re: [SQL] Integrity and Inheritance

2001-06-10 Thread Stephan Szabo
On Sun, 10 Jun 2001, Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > > One problem is that for update isn't supported across inheritance trees > > AFAICS and the triggers use for update for the appropriate locking. > > It's possible (maybe

Re: [SQL] cascading delete - recursivity

2001-06-12 Thread Stephan Szabo
On Sat, 9 Jun 2001, Postgresql wrote: > Hi, > > I have a table of categories (it's pseudo-sql...) : > > CATEGORIES > ( > id_category PRIMARY KEY, > id_category_parent (FOREIGN KEY ? CONSTRAINT ??) , > cat_text > ) > > There is recursivity : id_category_parent is -1 (= no parent cat

Re: [SQL] Foreign key to base table with rows in inherited tables

2001-06-12 Thread Stephan Szabo
Yes, you cannot currently do this. Check past discussions on mailing lists for more details. Inheritance and constraints is pretty dodgy right now (for instance, Reservationfile.datafileNr is not unique). On Tue, 5 Jun 2001, Mikael Kjellström wrote: > I've declared a foreign key in table File

Re: [SQL] calling user defined function with parameters..

2001-06-16 Thread Stephan Szabo
What version are you using and what error are you getting? Your example works for me on 7.2devel once i made a dpts table with an id_dpt column. The function code is not checked for plpgsql until its first use, so if there was a syntax error, it wouldn't be seen until you tried to use it. On S

Re: [SQL] LEFT JOIN ...

2001-06-18 Thread Stephan Szabo
I think that using INNER JOIN between nl and n (on n.nid=nl.nid) or joining those tables in a subquery might work. On Mon, 18 Jun 2001, The Hermit Hacker wrote: > Is there some way to write the above so that it evaluates: > > WHERE (n.type = 'A' OR n.type = 'N' OR n.type = 'H' OR n.ty

Re: [SQL] Referential Integrity Question (Delete/Insert duringTransaction)

2001-06-18 Thread Stephan Szabo
On Mon, 18 Jun 2001, Stef Telford wrote: > > I seem to have hit what i -think- may be a bug (but i am not crying > wolf jst yet ;). > > I have three tables. action, client and order_details. action has a primary > key 'order', client references action (along with adding the cli

Re: [SQL] possible to lock a single row in table?

2001-06-20 Thread Stephan Szabo
On Wed, 20 Jun 2001, Bruno Boettcher wrote: > i have a lots of threads that work on a table, making insertions, > updates removes. > > now i certain cases its important to keep data integrity, so i looked > into locks What kind of data integrity are you trying to implement? > all i fo

Re: [SQL] How to check if a table exists from functions.

2001-06-20 Thread Stephan Szabo
On Tue, 19 Jun 2001, Mikael Kjellström wrote: > > Maybe I am doing this the wrong way, but how do I check if a table exist? > > This works from psql: > > select > relname > from > pg_class > where > relname = 'tablename' > > > But if I try to do the same from a PL/PGSQL stored procedu

Re: [SQL] case, new column not found

2001-06-21 Thread Stephan Szabo
On Thu, 21 Jun 2001, [iso-8859-1] Martín Marqués wrote: > I'm trying somethings here and I get strange errors: > > select *,( > (CASE WHEN titulo LIKE '%Matematica%' THEN 1 ELSE 0 END) + > (CASE WHEN descripcion LIKE '%Matematica%' THEN 1 ELSE 0 END) + > (CASE WHEN incumbenci

Re: [SQL] distinguishing different database connections

2001-06-22 Thread Stephan Szabo
How about creating a temporary table with the data? That'll be persistant for the session. On Fri, 22 Jun 2001, Markus Wagner wrote: > Hi, > > can I access information on the current connection from within a trigger > function? > I need to identify different server connections somehow. Someth

Re: [SQL] Foreign key problem

2001-06-25 Thread Stephan Szabo
On 25 Jun 2001, Itai Zukerman wrote: > According to the documentation for CREATE TABLE: > > In addition, the referenced columns are supposed to be the columns > of a UNIQUE constraint in the referenced table, however Postgres > does not enforce this. > > Well, it looks like PostgreSQL *do

Re: [SQL] how can we change definition of a table once created?

2001-07-08 Thread Stephan Szabo
On Mon, 9 Jul 2001, Bhuvan A wrote: > can any one say how can we change the table definition once > created? > > say, we have a table with 1000s of records. if one needs > to change the data type of particular column or if he > needs to change the width of a column what should be > done? > > A

Re: [SQL] Referencing a view?

2001-07-12 Thread Stephan Szabo
On Thu, 12 Jul 2001, James Orr wrote: > Hi, > > Is there anyway that you can reference a column in a view for > referential integrity? The problem is with the unique thing, > obviously I can't create a unique index on a view. Here is what I > have: Not right now, and actually you still wouldn

Re: [SQL] Date Validation?

2001-07-13 Thread Stephan Szabo
On Fri, 13 Jul 2001, Josh Berkus wrote: > Folks, > > Pardon me for asking this again, but I received *no* responses last > week. > > Question: Is there any function or method which will allow me, in SQL > or PL/pgSQL, to validate dates without raising an error for invalid > dates? Not as far

Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Stephan Szabo
Something like? select employee.* from employee where not exists (select * from salesorder where salesorder.emp_id=employee.emp_id); On Fri, 13 Jul 2001 [EMAIL PROTECTED] wrote: > > > Hi, > > Consider the below... > > table 'employee' with unique 'emp_id', > table 'salesorder' wi

[SQL] Re: [BUGS] No subselects in constraint (bug?)

2001-07-13 Thread Stephan Szabo
On Fri, 13 Jul 2001, Alexey V. Neyman wrote: > Hello there! > > [Please Cc: me in followups.] > > I tried the following: > > CREATE TABLE a ( > int4 id > ); > CREATE TABLE b ( > int4 id > CHECK (id = ANY(SELECT a.id FROM a)) > ); > > Tables are created ok, checking with '\d table' confi

[SQL] Re: [GENERAL] trigger on DELETE

2001-07-11 Thread Stephan Szabo
On Wed, 11 Jul 2001, Phuong Ma wrote: > I'm trying to define a trigger that copies the row to be deleted into > another table (which is the inventory_audit table) before it does the > delete from the original table (which is the inventory table). > > CREATE FUNCTION inv_audit_mod () RETURNS OPA

Re: [SQL] Unknown values in int8 fields?

2001-07-15 Thread Stephan Szabo
Have you tried "where recno IS NULL"? - Original Message - From: "Chris Ruprecht" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Sunday, July 15, 2001 7:05 PM Subject: [SQL] Unknown values in int8 fields? > Hi Chris, > > When I load records with copy from ... And one of the fields (

Re: [SQL] Query optimizing - paradox behave

2001-07-19 Thread Stephan Szabo
What version are you using? (dbPG95GetIndex?) On Thu, 19 Jul 2001, David M. Richter wrote: > Hallo ! > > I want to tune a database. There a many redundant datas in the database > , because of all the relations were consider as n:m relations. But the > most of them are 1:n Relations. So my appr

Re: [SQL] unique index on more than one field using functions

2001-07-23 Thread Stephan Szabo
On 22 Jul 2001, Domingo Alvarez Duarte wrote: > I'm trying create a unique index using more than one field and > applying a function in one field to achieve case insensitive > uniqueness but postgresql doesn't accept. > > create table a( > > id int primary key, > id2 int not null, > na

Re: [SQL] Re: Get the tables names?

2001-07-23 Thread Stephan Szabo
On Mon, 23 Jul 2001, dado feigenblatt wrote: > > system tables all ~ '^pg', which is probably a better check than > > user=postgresql. > > You never know when someone will name their tables starting with "pg". > Well, you never know when someone will create their tables as user postgres > eithe

Re: [SQL] Table scan instead of index scan

2001-07-24 Thread Stephan Szabo
On Tue, 24 Jul 2001, [ISO-8859-1] Mário Sérgio G Antunes wrote: > I use PostgreSQL 7.1.2.4 in two servers under RedHat 7.0. > Our database has a table like that: > create table tb_client > ( >id_client varchar(32), >client_name varchar(40), >bdate date, > ... > ); > > create index

Re: [SQL] Meta integrity

2001-07-25 Thread Stephan Szabo
On Wed, 25 Jul 2001, Renato De Giovanni wrote: > I'm working on a project based on an unusual data model. Some entities > aren't represented by separate tables, they're grouped in the same table > just like the following simplified model shows: > > CREATE TABLE class ( >id CHAR(8)

Re: [SQL] What is the syntax turn off auto commit?

2001-07-18 Thread Stephan Szabo
On Wed, 18 Jul 2001, Raymond Chui wrote: > > > The Subject says its all. > > To speed up a bulk of INSERTs, I need to turn-off the auto commit 1st. > Then > at the end of INSERTs, issue COMMIT; > What is the syntax to turn off the auto commit? Thank you! Put them in an explicit transaction

Re: [SQL] Why does this plpgslq always return 1?

2001-07-27 Thread Stephan Szabo
On Fri, 27 Jul 2001, John Oakes wrote: > Can anyone tell me why this always return 1? Thanks! > > CREATE FUNCTION passrate(date, date, text) RETURNS float AS ' > > DECLARE > begindate ALIAS FOR $1; > enddate ALIAS FOR $2; > passfail ALIAS FOR $3; > ret float; > countp float; > counttota

Re: [SQL] Who do I make _ not a wildcard?

2001-07-28 Thread Stephan Szabo
On Sat, 28 Jul 2001, Roy Souther wrote: > In PG the _ is a wildcard that means any singal char. I need to do a search > for the actual _ char and not get back thousands of wrong matches. Is there > and escape char that I could use? This needs to work with PG 7.0.3 & 7.1.2. \\_ should work for

Re: [SQL] Creating foreign key constraint to child table?

2001-08-05 Thread Stephan Szabo
On Sun, 5 Aug 2001, Allan Engelhardt wrote: > test=# create table baz(bar integer, constraint fk_bar foreign key (bar) >references foo(id)); > NOTICE: CREATE TABLE will create implicit trigger(s) for FOREIGN KEY check(s) > CREATE > > but this is not exactly what I want: I need to e

Re: [SQL] Delete Trigger Issue

2001-08-06 Thread Stephan Szabo
On Tue, 7 Aug 2001, Sundararajan wrote: > I am developing a db application in postgresql and i need to write a delete > trigger on one of the tables. > > I need a delete trigger on the table 1, so that if I delete a row from table > 1 , the corresponding rows from table 2 should also be deleted.

Re: [SQL] Are circular REFERENCES possible ?

2001-08-07 Thread Stephan Szabo
On Tue, 7 Aug 2001, Josh Berkus wrote: > Denis, > > > I have a case where I wanted to do circular REFERENCES, is this > > impossible ? > > It can be done. It's just a bad idea. > > > We deliver to the *shops* of our *customers*. > > We have therefore two tables : > > - customers (enterpris

Re: [SQL] REFERENCES constraint

2001-08-08 Thread Stephan Szabo
On Wed, 8 Aug 2001, Cedar Cox wrote: > > Two questions (maybe they are silly..) > > 1. Can a column reference more than one table? (This assumes you use a > single sequence to generate the IDs for both "tbla" and "tblb". I guess > you would also have the problem of enforcing a unique index.

Re: [SQL] Strange DISTINCT !

2001-08-20 Thread Stephan Szabo
On Mon, 20 Aug 2001, Jean-Christophe Boggio wrote: > Hello, can someone explain to me why this query is so slow : > > select distinct t.idmembre,p.datecrea > from tmp_stat t,prefs p > where p.idmembre=t.idmembre > limit 5; > > And this one is so fast : > > select t.idmembre,p.datecrea > fr

Re: [SQL] exists

2001-08-20 Thread Stephan Szabo
On Mon, 20 Aug 2001, Joseph Shraibman wrote: > I want to select a boolean if there exists a row in another table that matches this >one. > So I did select ..., (select count(*) from table2 where ...) > 0 ... > but that count(*) was taking forever. I know there is a better way to do it, but >

Re: [SQL] exists

2001-08-21 Thread Stephan Szabo
hat the inner query (on the exists) or the entire explain? I guess it'd be useful to see the whole query and explain and maybe schema. > Stephan Szabo wrote: > > On Mon, 20 Aug 2001, Joseph Shraibman wrote: > > > > > >>I want to select a boolean if there exists

Re: [SQL] exists

2001-08-21 Thread Stephan Szabo
> Stephan Szabo wrote: > > On Tue, 21 Aug 2001, Joseph Shraibman wrote: > > > > > >>Thank you, I was missing the parens. > >> > >>If I do an explain I see: > >> > >>-> Index Scan using m_u_and_p_key on m (cost=0.00..303

Re: [SQL] WHERE on an alias

2001-08-27 Thread Stephan Szabo
On Mon, 27 Aug 2001, Joseph Shraibman wrote: > OK my query was like: > select u.field1, ... , d.field1, ... (select ml.field from ml WHERE ml.key = u.key >order > by ml.keyfield desc limit 1) as lastml FROM utable u, dtable d, WHERE u.key = d.key >and > ... and (sublectect again) = 2; > > OK

Re: [SQL] WHERE on an alias

2001-08-27 Thread Stephan Szabo
On Mon, 27 Aug 2001, Joseph Shraibman wrote: > Stephan Szabo wrote: > > I think you'd want to move the entire query excepting the lastml where > > condition into a single subselect in the outer from with the lastml > > condition on the outside: > > select * from

Re: [SQL] changes to table creation syntax in 7.1.2?

2001-08-29 Thread Stephan Szabo
On Wed, 22 Aug 2001, Jayson Callaway wrote: > In postgres 7.0.x I had some working code that lookes something like: > > CREATE TABLE category > ( > uid int4 PRIMARY KEY, > description text NOT NULL, > parent int4 NULL REFERENCES category(uid) > ) > > After upgrading to postgres 7.1.

Re: [SQL] Create table syntax

2001-08-30 Thread Stephan Szabo
On 28 Aug 2001, satish rao wrote: > Entered below is the SQL create table syntax: > > CREATE TABLE lists ( > [listid] [int] IDENTITY (1, 1) NOT NULL , > [listname] [varchar] (200) NULL , > [listcreator] [varchar] (200) NULL , > [listdesc] [text] NULL) create table lists

Re: [SQL] Help On Postgresql

2001-08-30 Thread Stephan Szabo
On Thu, 23 Aug 2001, Jaydip wrote: > a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a >Date/DateTime variable. > > For Example : i> In Oracle to_char(dt,'') - for extracting the year value >from a date variable dt > ii> In SqlServer datepart(hh,

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Stephan Szabo
On Thu, 30 Aug 2001, Marc [iso-8859-1] André Paquin wrote: > Hello, > > Here is 2 tables: > > airport > - > airport_id > name > code > city_id > > destination > --- > destination_id > dest_name > ... > airport_dep_id // using airport.airport_id (departure) > airport_arr_id //

Re: [SQL]

2001-09-03 Thread Stephan Szabo
On Mon, 3 Sep 2001, Joseph Syjuco wrote: > im new in postgresql (actually came from SQL Server) and i was trying a > script like this > > insert into table1(field1,field2) values (select field1, field2 from table > 2); > > i dont know if this is possible (inserting a set of entries via results

Re: [SQL] duplicated oid

2001-09-06 Thread Stephan Szabo
On Fri, 7 Sep 2001, Carolyn Lu Wong wrote: > anyone knows if duplicated oid is possible?? > > is there a possible way to remove the duplicate row, now that i don't > know which ID to use? any suggestions? Hmm, that's wierd. AFAIK that should only occur in cases like copy with oids and oid wrap

Re: [SQL] optimizing queries and indexes...

2001-09-09 Thread Stephan Szabo
On Sun, 9 Sep 2001, Josh Berkus wrote: > > i have several friends that are DBA's by profession and work on > > oracle > > and/or ms sql server. they have all told me that while there are some > > general rules to follow that each database is different. > > Yup. They told ya right. > > > for e

Re: [SQL] optimizing queries and indexes...

2001-09-09 Thread Stephan Szabo
On Sun, 9 Sep 2001, Josh Berkus wrote: > Ah. Well, you answer optimization questions so often that I'd assumed > that you had a hand in it. Is the optimizer all Tom and Bruce's work? Mostly Tom I believe. > > At least on 7.1 and below, if you have a dummy value that is very > > common > > bu

Re: [SQL] row level locking?

2001-09-10 Thread Stephan Szabo
On Mon, 10 Sep 2001, Jeff Barrett wrote: > I have an update statement (no transaction controls surround these > statements): > > update sessions set sessdate = 0 where sessid in ( long list of ids); > > How long will the rows being updated be locked for this statement? Will all > be locked unti

Re: [SQL] calling a shell script from pl/pgsql

2001-09-10 Thread Stephan Szabo
On Mon, 10 Sep 2001, Jeff Barrett wrote: > How can I call a shell script from within a pl/pgsql function that is called > as from a trigger. I do not want to interact with the script I just want it > to run. I do want the trigger to wait for the script it called to complete > before returning a v

Re: pl/sh (was Re: [SQL] calling a shell script from pl/pgsql)

2001-09-10 Thread Stephan Szabo
On Mon, 10 Sep 2001, Alex Pilosov wrote: > On Mon, 10 Sep 2001, Stephan Szabo wrote: > > > On Mon, 10 Sep 2001, Jeff Barrett wrote: > > > > > How can I call a shell script from within a pl/pgsql function that is called > > > as from a trigger. I do not wan

Re: [SQL] table inheritance and foreign key troubles

2001-09-11 Thread Stephan Szabo
(hopefully this doesn't double post... stupid mail system) On Tue, 11 Sep 2001, Christof Glaser wrote: > On Tuesday, 11. September 2001 10:04, Kevin Way wrote: > > I'm having a little trouble with some inherited tables and a foreign > > key. Here's a simplified case, to show the trouble. > > >

Re: [SQL] referencing oid impozsible ?

2001-09-11 Thread Stephan Szabo
On Tue, 11 Sep 2001 [EMAIL PROTECTED] wrote: > hello all > I tried recently (pgsql 7.1.2) to establish the oid of one table as foreign key > in another. > To no avail : there was no uniqueness constraint on that column > Naturally, it seems impossible to add a uniqueness constraint to such a sys

Re: [SQL] trigger trouble -- procedure not found

2001-09-13 Thread Stephan Szabo
On Fri, 14 Sep 2001, Kevin Way wrote: > I'm having trouble creating a trigger. First i'm creating a function, > add_to_search in PL/pgSQL. > > \df verifies the existance of this function: > smallint | add_to_search | text, text, text, integer > > but when I call: > > C

Re: [SQL] Intentional, or bug?

2001-09-16 Thread Stephan Szabo
On Mon, 17 Sep 2001, Tod McQuillin wrote: > On Sun, 16 Sep 2001, Kovacs Baldvin wrote: > > > select NULL = NULL; > > > > The answer is: true!!! > > This has got to be a bug. NULL is not equal to anything (nor is it > unequal to anything). This is because of a hack due to a broken MS client th

Re: [SQL] table restruct...

2001-09-20 Thread Stephan Szabo
On Thu, 20 Sep 2001, David M. Richter wrote: > Hi! > > Thanks, to You! > > Yes I have to do . Now I solved that problem with rename the original > table study to _study > then create the new right structured table study , Insert into study > (chilioid,...,...) SELECT * FROM _study; > Ok not el

Re: [SQL] Selecting latest value

2001-09-20 Thread Stephan Szabo
On Thu, 20 Sep 2001, Patrik Kudo wrote: > On Thu, 20 Sep 2001, Haller Christoph wrote: > > > Try > > create NEWtable (userid text, val integer, ts timestamp); > > insert into NEWtable > > select userid, val, max(ts) from table group by userid, val; > > That won't work. That will give me multipl

Re: [SQL] Stored prosedure last run

2001-09-18 Thread Stephan Szabo
On 17 Sep 2001, Pasha wrote: > Hello to Every1. > I'm trying to find if anyone knows how to find out when the stored > procedure was used last time (not created). I don't think there's any real way to do that apart from having your procedure keep track of that itself. -

Re: [SQL] COUNT func

2001-10-18 Thread Stephan Szabo
On Thu, 18 Oct 2001, Oleg Lebedev wrote: > Hi, > I am trying to count the number or rows in a table with similar field > values. I want to do it in one table scan. > In other words, say I want to count the number of rows in Person table, > having age equal to 40, and the number of rows with stat

Re: [SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Stephan Szabo
Well, the easiest general way is probably a plperl function, but I think the following may work for your specific case: update mytable set property_id=substr(property_id, 1, position('-' in property_id)-1) where position('-' in property_id)!=0; On Thu, 18 Oct 2001, Steve Frampton wrote: >

Re: [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-22 Thread Stephan Szabo
On Sat, 20 Oct 2001, Joel Burton wrote: > On Sat, 20 Oct 2001, Aasmund Midttun Godal wrote: > > > Can a rule see the where statement in a query which it has been > > triggered by? or is it simply ignored?? what happens? > > > > Looking over your question, I wanted to clarify the problem a bit,

Re: [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-22 Thread Stephan Szabo
> Don't think so. I think the rule doesn't make any sense. > NEW.id and OLD.id are probably dbl values, so saying OLD.id=id (where id > is raw.id since that's the update table) isn't correct. It probably > should be OLD.id=id*2 (which seems to work for me, btw) It's editing > a different row t

Re: [SQL] dropping foreign key

2001-10-24 Thread Stephan Szabo
On Wed, 24 Oct 2001, Joseph Shraibman wrote: > Can I just set tgenabled to false? I'm not sure if it works now (in 7.2 devel) but I'm pretty sure that doesn't work in past versions unfortunately. ---(end of broadcast)--- TIP 5: Have you checked

Re: [SQL] cast

2001-10-22 Thread Stephan Szabo
On Mon, 22 Oct 2001, Esteban Gutierrez Abarzua wrote: > > hi. > > I wanna to make a query on this table(postgres system catalog): > > Attribute | Type| Modifier > --+---+-- > relname | name | > reltype | oid | > relowner | in

Re: [SQL] Primary key with oid + name : error, which solution ?

2001-10-31 Thread Stephan Szabo
On Wed, 31 Oct 2001, [ISO-8859-1] Stéphane Chomat wrote: > I create two table repertory and person. And i have an error : > > > CREATE TABLE repertory (name_rep name, attribut text[], PRIMARY > KEY(name_rep)); > > CREATE TABLE person (nam_rep repertory, name_pers text, url text, eadr > text, te

<    1   2   3   4   5   6   7   8   >