Re: [SQL] How does postgres handle non literal string values

2002-12-03 Thread Vernon Wu
In general, it isn't a good idea to have SQL statements in JSP files. A good practise is using Mode 2. The Struts is a popular Mode 2 framework. If your application is very small and it won't grow into a big one, you can get around using Mode 1. In the situation, the SQL tags of JSTL will be a

Re: [SQL] Query for filtering records

2002-12-03 Thread eric soroos
> SELECT * ... > FROM ... > WHERE NOT IN (SELECT contactnum FROM groups WHERE groupnum='c' or > groupnum='d' OR ... ) > > is bound to be _much_ faster! Yeah, that's an obvious optimization. Unfortunately, due to needing to match semantics of a previous non-sql version and some pathological g

Re: [SQL] recreating table and foreign keys

2002-12-03 Thread Stephan Szabo
On Tue, 3 Dec 2002, Tomasz Myrta wrote: > > You'll probably end up using ALTER TABLE ADD CONSTRAINT to add the > > constraints to the new master_table. It's possible that you might > > be able to hack something with the system tables, but that sounds > > dangerous. Or you can upgrade to 7.3 whi

Re: [SQL] Query for filtering records

2002-12-03 Thread Jean-Luc Lachance
Eric try: select num, p1,p2 ... from contacts inner join groups using (contacts.num=groups.contactNum) where groups.groupNum=a and contact.p3=b and not exists ( select 1 from groups g2 where g2.contactNum = groups.contactNum and g2.groupNum != a); or select num, p1,p2 .

Re: [SQL] Query for filtering records

2002-12-03 Thread Joel Burton
On Tue, Dec 03, 2002 at 11:01:33AM -0800, eric soroos wrote: > I'm having trouble subtracting groups from other groups. > > > I've got a data model that has the following essential features: > > create table contacts (num int, properties); > create table groups (groupNum int, contactNum int

Re: [SQL] recreating table and foreign keys

2002-12-03 Thread Tomasz Myrta
> You'll probably end up using ALTER TABLE ADD CONSTRAINT to add the > constraints to the new master_table. It's possible that you might > be able to hack something with the system tables, but that sounds > dangerous. Or you can upgrade to 7.3 which lets you run alter table > drop column. :) I

[SQL] Large Query Question. (Slow Select while using 'IN')

2002-12-03 Thread Mike Winter
Hi all, I hope someone can help me out. I'm doing single-table select statements on a large table and I could use some help in speeding it up. My query is of the form: SELECT col, count(col) FROM tab WHERE id IN (3, 4,7,2, ...) GROUP BY COL ORDER BY count for a very large number of rows. I have

[SQL] problem with view in 7.3

2002-12-03 Thread Alphasoft
Hi , I am Hristo Neshev From Bulgaria   In Version 7.2 this statement works :   create view v_impr_check(ead_no,ead_date, e_no,e_date,sid,number, s_order,cdt,cdt_description, original_qty,used_qty,waste_qty,rest_qty,original_used_qty)ASselect distinct md_custom_number, md_custom_date, md_nu

Re: [SQL] [OT] Inventory systems (private)

2002-12-03 Thread Dan MacNeil
You might create a seperate attribute tables. table: items id name table: attributes id description table: item_attributes item_id attribute_id SELECT items.name, attributes.description FROM items, attributes, item_attributes WHERE items.id=item_attributes.item_i

[SQL] Analyzing the 7.3 SQL92 Schema

2002-12-03 Thread Christian Gausepohl
I needed theses Statements, and i think tey could be usefull to others. I hate the non-oracle outer joins, so i implemented the the nullable fields wit a subselect. If someone will rewrite that, please mail the new statements to c.gausepohl(at)arcusx.com so here comes the script: --list of tables

[SQL] Query for filtering records

2002-12-03 Thread eric soroos
I'm having trouble subtracting groups from other groups. I've got a data model that has the following essential features: create table contacts (num int, properties); create table groups (groupNum int, contactNum int); Where not all contacts will be in a group, some groups will contain mos

Re: [SQL] recreating table and foreign keys

2002-12-03 Thread Stephan Szabo
On Tue, 3 Dec 2002, Tomasz Myrta wrote: > Hi > I use Postgresql 7.2.2. > Sometimes I have to remove a column from my tables (psql): > 1. alter table master_table rename to x; > 2. \i tables.sql > 3. insert into master_table select f1,f2,... from x > 4. drop table x > > I think, foreign keys refer

Re: [SQL] [OT] Inventory systems (private)

2002-12-03 Thread Troy
Ries, One solution is to create a table such as follows: CREATE TABLE inventory (id serial, product text, PRIMARY KEY (id) ) ; CREATE TABLE attributes (prodid int4, textkey text, textvalue text, int4value int4, FOREIGN KEY (prodid) REFERENCES inventory (id) MATCH FULL ON DELETE C

[SQL] recreating table and foreign keys

2002-12-03 Thread Tomasz Myrta
Hi I use Postgresql 7.2.2. Sometimes I have to remove a column from my tables (psql): 1. alter table master_table rename to x; 2. \i tables.sql 3. insert into master_table select f1,f2,... from x 4. drop table x I think, foreign keys referring from detail_table(s) to master_table have gone. How t

[SQL] Backend message type 0x50 arrived while idle

2002-12-03 Thread Berman, Phil
To all- I am using Postgres version 6.5.1 in a multithreaded program which is written in C. All inserts and updates into any tables are done within the child process, and there are retrieves from tables both in the parent and child processes. Additionally, the child process will insert into and u

Re: [SQL] problem with view in 7.3

2002-12-03 Thread Tom Lane
"Alphasoft" <[EMAIL PROTECTED]> writes: > In 7.3 when i am trying to recreate the view I received the folowing error : > find_expr_references_walker: bogus varno 8=20 This is a bug, but I can't fix it unless you give me a complete test case. I don't have time to try to reverse-engineer your schem

[SQL] problem with view in 7.3

2002-12-03 Thread Alphasoft
Hi , I am Hristo Neshev From Bulgaria   In Version 7.2 this statement works :   create view v_impr_check(ead_no,ead_date, e_no,e_date,sid,number, s_order,cdt,cdt_description, original_qty,used_qty,waste_qty,rest_qty,original_used_qty)ASselect distinct md_custom_number, md_custom_date, md_n

Re: [SQL] [OT] Inventory systems (private)

2002-12-03 Thread Ries van Twisk
Troy, Andy, you both are right and it was my first tought. My only concern is that would this system be fast enough for large tables (for me large is around 250.000 unique items) and thus my attribute table would be around 2.500.000 and 5.000.000 entrys. A record for one attribute is small I think

Re: [SQL] [OT] Inventory systems (private)

2002-12-03 Thread Andy Tawse
While I'm not expert what I would do is something like this Items table fields: item_id item_name Attributes table fields: attribute_id attribute_name Item_Attr table fields: item_id attribute_id attribute_value Now an item can be associated with any number of attributes. 03/12/2002 13:17

Re: [SQL] SQL QUERY

2002-12-03 Thread Achilleus Mantzios
On Tue, 3 Dec 2002, Pedro Igor wrote: > But i want implement a trigger that auto-increments the id field. This > options is personal, i don´t like to depend from the database. > Then use table name as parameter to your function. But trully its an error prone policy the one you try to follow, what

[SQL] [OT] Inventory systems (private)

2002-12-03 Thread Ries van Twisk
Hi All, is there any whitepaper, document or website that can point me to how to setup a inventory system? I'm particulary interested how other people solve the problem of a unknown number of attributes to a inventory item. example: BAL<-- Inventory Item - Color <- At

Re: [SQL] SQL QUERY

2002-12-03 Thread Achilleus Mantzios
On Tue, 3 Dec 2002, Pedro Igor wrote: > I have the following function: > CREATE FUNCTION public.auto_incremento() RETURNS trigger AS ' > begin > new.id = (select (max(id) + 1) from teste); > return new; > end;' LANGUAGE 'plpgsql' > > I created a trigger that uses this function, but i want to the f

[SQL] SQL QUERY

2002-12-03 Thread Pedro Igor
I have the following function: CREATE FUNCTION public.auto_incremento() RETURNS trigger AS 'beginnew.id = (select (max(id) + 1) from teste);return new;end;' LANGUAGE 'plpgsql' I created a trigger that uses this function, but i want to the function be usefull for all tables and not only to

Re: [SQL] Date trunc in UTC

2002-12-03 Thread Thrasher
Hi all Finally, I am using a plpgsql procedure that accomplish that in PostgreSQL 7.2.1. The code follows: CREATE OR REPLACE FUNCTION utc_date_trunc (TEXT, TIMESTAMP) RETURNS TIMESTAMP AS ' DECLARE utcts TIMESTAMP WITHOUT TIME ZONE; utcdt TIMESTAMP WITHOUT TIME ZONE; BEGIN --> First get

Re: [SQL] EXIST / NOT EXIST

2002-12-03 Thread Rachel.Vaudron
> EXISTS is supported (ie. trailing 'S'). I'm a little shamefull ;) Thanks a lot. Rachel ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] EXIST / NOT EXIST

2002-12-03 Thread Rachel.Vaudron
> it is EXISTS I'm a very little shamefull !!! But Thanks at all. Rachel ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] EXIST / NOT EXIST

2002-12-03 Thread Achilleus Mantzios
On Tue, 3 Dec 2002, Rachel.Vaudron wrote: > Hi, > > I would like to know if the keyword EXIST can be used with PostgreSQL ? > I have search in the Reference Manuel et tried a query using EXIST in > pgsql, but no result... it is EXISTS . > > Thanks a lot > > Rachel > > ***

Re: [SQL] EXIST / NOT EXIST

2002-12-03 Thread Philip Warner
At 09:01 AM 3/12/2002 +0100, Rachel.Vaudron wrote: I would like to know if the keyword EXIST can be used with PostgreSQL ? EXISTS is supported (ie. trailing 'S'). Philip Warner| __---_ Albatross Cons

[SQL] EXIST / NOT EXIST

2002-12-03 Thread Rachel.Vaudron
Hi, I would like to know if the keyword EXIST can be used with PostgreSQL ? I have search in the Reference Manuel et tried a query using EXIST in pgsql, but no result... Thanks a lot Rachel ** [EMAIL PROTECTED] Laboratoire de prehistoire du Lazaret 33 bis