[SQL] SQL - update table problem...

2006-11-13 Thread Marko Rihtar
Hi, first i'm sorry if this message appears twice. first time didn't get through because i wasn't registered. i'm trying to do update on multiple tables but don't know how. is something like this posible with postgresql? update table1 join table2 on (table1.id=table2.t1) join table3 on (table

[SQL] Inserting data in composite types!

2006-11-13 Thread Rodrigo Sakai
  Hi, I have a question about how to insert data in composite types!     Imagine the exemple:   CREATE TYPE t_time AS (   a date,   b date );   CREATE TABLE salary (    salary numeric(10,2),    t_date t_time );   I know that if I want to insert data in the table SALARY I just

Re: [SQL] Inserting data in composite types!

2006-11-13 Thread Markus Schiltknecht
Hi, Rodrigo Sakai wrote: How can I insert a single row in this table??? INSERT INTO employee (emp_salary) VALUES ((1000.00, '(2006/10/10, 2006/12/10)')); BTW: are you sure you don't want to use foreign keys instead? Something like: CREATE TABLE salaries ( id SERIAL PRIMARY KEY, sala

Re: [SQL] Inserting data in composite types!

2006-11-13 Thread Shane Ambler
Rodrigo Sakai wrote: Hi, I have a question about how to insert data in composite types! Imagine the exemple: CREATE TYPE t_time AS ( a date, b date ); CREATE TABLE salary ( salary numeric(10,2), t_date t_time ); I know that if I want to insert data in the t

[SQL] hiding column values for specific rows

2006-11-13 Thread Luca Ferrari
Hi, I don't know if this's possible but I'd like to hide column values for specific rows within a query. Imagine I've got a table with columns username and password: users(username,password). Now I'd like the user registered in the table to see her password, to see who is registered but not to s

Re: [SQL] hiding column values for specific rows

2006-11-13 Thread A. Kretschmer
am Mon, dem 13.11.2006, um 14:11:50 +0100 mailte Luca Ferrari folgendes: > Hi, > I don't know if this's possible but I'd like to hide column values for > specific rows within a query. Imagine I've got a table with columns username > and password: users(username,password). Now I'd like the user r

[SQL] max (timestamp,timestamp)

2006-11-13 Thread T E Schmitz
I tried the following query but the query fails as "function max (timestamp w. timezone,timestamp w. timezone) does not exist" SELECT id, MAX(last_updated, (SELECT MAX (last_updated) FROM product_category_member WHERE product_category_member.id = product_category.id)) FROM product_category

Re: [SQL] max (timestamp,timestamp)

2006-11-13 Thread A. Kretschmer
am Mon, dem 13.11.2006, um 13:46:00 + mailte T E Schmitz folgendes: > I tried the following query but the query fails as > "function max (timestamp w. timezone,timestamp w. timezone) does not exist" > > SELECT id, > > MAX(last_updated, > (SELECT MAX (last_updated) FROM product_category_memb

Re: [SQL] Inserting data in composite types!

2006-11-13 Thread imad
I am able to do this thing with the following query: insert into employee (a, name, s) values(1, 'emp name', ((1, '(01/01/2000, 01/01/2000)'))); --Imad www.EnterpriseDB.com On 11/13/06, Rodrigo Sakai <[EMAIL PROTECTED]> wrote: Hi, I have a question about how to insert data in composi

Re: [SQL] max (timestamp,timestamp)

2006-11-13 Thread imad
max (timestamptz, timestamptz) does not exist already. You need to create a simple function in PLpgSQL something like if a > b return a; else return b; Even an sql function will do the job here using case statement. --Imad www.EntepriseDB.com On 11/13/06, A. Kretschmer <[EMAIL PROTECTED]> wr

Re: [SQL] max (timestamp,timestamp)

2006-11-13 Thread Michael Fuhr
On Mon, Nov 13, 2006 at 07:29:09PM +0500, imad wrote: > max (timestamptz, timestamptz) does not exist already. You need to > create a simple function in PLpgSQL something like > > if a > b > return a; > else > return b; Since PostgreSQL 8.1 you can use GREATEST: test=> SELECT greatest(1, 2); gr

[SQL] COALESCE and GROUP BY and AGGREGATES

2006-11-13 Thread Erik Jones
Ok, here's a sample table for the question I have: CREATE TABLE sales_table ( sale_type varchar default 'setup' not null, sale_amount numeric not null sale_date timestamp without timezone default now()); So, let's say there are 3 different sale_types: 'setup', 'layaway', 'the_hookup' and I want

Re: [SQL] COALESCE and GROUP BY and AGGREGATES

2006-11-13 Thread Volkan YAZICI
On Nov 13 10:49, Erik Jones wrote: > Ok, here's a sample table for the question I have: > > CREATE TABLE sales_table ( > sale_type varchar default 'setup' not null, > sale_amount numeric not null > sale_date timestamp without timezone default now()); > > So, let's say there are 3 different sale_t

RES: [SQL] Inserting data in composite types!

2006-11-13 Thread Rodrigo Sakai
Thanks, It works! I have tried: insert into employee (c, nome, sal) values(1, 'emp name', '(1, (01/01/2000, 01/01/2000))' ); And it doesn't work! -Mensagem original- De: imad [mailto:[EMAIL PROTECTED] Enviada em: segunda-feira, 13 de novembro de 2006 11:10 Para: [EMAIL PROTECTED] Cc

[SQL] drop a check

2006-11-13 Thread ivan marchesini
Dear all... I have created a check constraint without giving it a name.. now I have a check named "$25" in my table that I need to drop or modify!!! How can I do??? with names is simple alter table tablename drop constraint constraintname; but without name?? :-) many thanks... Ivan -- Iv

[SQL] Another question about composite types

2006-11-13 Thread Rodrigo Sakai
  Hi, I need to create a table like:     CREATE TYPE t_salary AS (     Value numeric(10,2),     Validity date   );     CREATE TABLE employee ( id int, name varchar(30), salary t_salary[]   );       That is, I need an array of composite type and searching on goog

Re: RES: [SQL] Inserting data in composite types!

2006-11-13 Thread Richard Broersma Jr
> Thanks, It works! I have tried: > > insert into employee (c, nome, sal) values(1, 'emp name', '(1, (01/01/2000, > 01/01/2000))' ); > > And it doesn't work! What is the error message? Regards, Richard Broersma Jr. ---(end of broadcast)---

Re: [SQL] drop a check

2006-11-13 Thread Volkan YAZICI
On Nov 13 05:32, ivan marchesini wrote: > I have created a check constraint without giving it a name.. > now I have a check named "$25" in my table that I need to drop or > modify!!! > How can I do??? > with names is simple > > alter table tablename drop constraint constraintname; > > but without

Re: [SQL] Another question about composite types

2006-11-13 Thread Richard Broersma Jr
> CREATE TYPE t_salary AS (Value numeric(10,2), Validity date); > CREATE TABLE employee (id int, name varchar(30), salary t_salary[]); > > That is, I need an array of composite type and searching on google I found > that is impossible to do it! Is it really impossible? Anyone have do it ? Why

RES: [SQL] Another question about composite types

2006-11-13 Thread Rodrigo Sakai
I know that if I create a table salary that references my employee table works! But I'm trying to work with the composite type concept! Thinking in Object-Oriented Programming (OOP) I have a class employee that is composed by the class salary among other things! Like: Class salary { private

Re: [SQL] COALESCE and GROUP BY and AGGREGATES

2006-11-13 Thread Erik Jones
Volkan YAZICI wrote: On Nov 13 10:49, Erik Jones wrote: Ok, here's a sample table for the question I have: CREATE TABLE sales_table ( sale_type varchar default 'setup' not null, sale_amount numeric not null sale_date timestamp without timezone default now()); So, let's say there are 3 diffe

Re: [SQL] drop a check

2006-11-13 Thread Andreas Kretschmer
ivan marchesini <[EMAIL PROTECTED]> schrieb: > Dear all... > I have created a check constraint without giving it a name.. > now I have a check named "$25" in my table that I need to drop or > modify!!! > How can I do??? Can you see the name with \d within psql? An example: test=# create table

Re: [SQL] drop a check

2006-11-13 Thread ivan marchesini
Dear Volkan, thank you for your answer... I have tried to verify the table information_schema.constraint_column_usage, but, and I was really surprised, I have found nothing inside it.. it seems there are not checks!!! I have also seen the manual page you suggested but I can't understand why I don'

Re: [SQL] drop a check

2006-11-13 Thread ivan marchesini
. or it depend on the fact I'm using postgres 7.4.13 many thanks... Ivan On lun, 2006-11-13 at 19:41 +0200, Volkan YAZICI wrote: > On Nov 13 05:32, ivan marchesini wrote: > > I have created a check constraint without giving it a name.. > > now I have a check named "$25" in my table that I

Re: [SQL] drop a check

2006-11-13 Thread Volkan YAZICI
On Nov 13 06:38, ivan marchesini wrote: > thank you for your answer... > I have tried to verify the table > information_schema.constraint_column_usage, but, and I was really > surprised, I have found nothing inside it.. > it seems there are not checks!!! > I have also seen the manual page you sugg

Re: [SQL] Another question about composite types

2006-11-13 Thread imad
There is always an _typname created for arrays like we have _int4 for _int4, _varchar for varchar and _timestamp for timestamp etc. May be you have to write some _typname for your type to use it in arrays. We always use array_in and array_out for _typenames BTW. This may be helpful to you. --I

Re: [SQL] drop a check

2006-11-13 Thread Andreas Kretschmer
ivan marchesini <[EMAIL PROTECTED]> schrieb: > . > or it depend on the fact I'm using postgres 7.4.13 > many thanks... Maybe, the information-schema can be different in different versions. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional sid