Re: [SQL] trecherous subselect needs warning?

2006-02-07 Thread Tom Lane
george young writes: > How about a *documentation* suggestion that sub-queries can be > very dangerous if one doesn't qualify all column references? > Maybe with an example like the one that bit me? I have no objection to a documentation example, but there isn't any obvious place where it would f

Re: [SQL] trecherous subselect needs warning?

2006-02-07 Thread george young
On Tue, 07 Feb 2006 12:45:53 -0500 Tom Lane <[EMAIL PROTECTED]> threw this fish to the penguins: > george young writes: > > This query returns zero rows: > > > newschm3=# select run_id from s_bake where opset_id not in (select opset_id > > from opset_steps); > > run_id > > > > (0 rows

Re: [SQL] trecherous subselect needs warning?

2006-02-07 Thread Tom Lane
george young writes: > This query returns zero rows: > newschm3=# select run_id from s_bake where opset_id not in (select opset_id > from opset_steps); > run_id > > (0 rows) > But, by my mistake, table opset_steps has no column "opset_id"! > Surely it should return an error, or at lea

Re: [SQL] Filtering data based on timestamp

2006-02-07 Thread Richard Huxton
Panos Kassianidis wrote: Thanks very much for the answer. Could you also please tell me how am I supposed to write such a function? How is date_trunc implemented so that I can extend it? In C in SQL? I'd probably write it in plpgsql unless you need the speed. And where can I find its source c

[SQL] trecherous subselect needs warning?

2006-02-07 Thread george young
[PostgreSQL 8.1.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1] This query returns zero rows: newschm3=# select run_id from s_bake where opset_id not in (select opset_id from opset_steps); run_id (0 rows) But, by my mistake, table opset_steps has no column "opset_id"! Surely i

Re: [SQL] executing dynamic commands

2006-02-07 Thread codeWarrior
In your function why not create a temporary table then use that for your processing ? CREATE TEMPRORARY TABLE tabledest AS (SELECT * FROM tblsrc WHERE condition); <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > I user PostgreSQl 8.0.4 on Win2003 Server and write a functio

Re: [SQL] Filtering data based on timestamp

2006-02-07 Thread Richard Huxton
Panos Kassianidis wrote: and I would like to retrieve values recorded in the last 2 hours but with an interval of 5 minutes, which means that my query should return one tuple for every 5 tuples in the table and the value of this tuple should be an average of 5 values. Does anyone have any clue ho

[SQL] Filtering data based on timestamp

2006-02-07 Thread Panos Kassianidis
Hello everybody, I am building a data logging application and I am facing the following problem. I have a table which holds timestamp-value pairs for a recorded variable. I would like to be able to select a range of values between a starting and an ending timestamp but also specify an interval

Re: [SQL] problem referencing an attrib which is not unique

2006-02-07 Thread Vic Rowan
Thanks a lot Patrick and Richard for the help! Especially about the details that I hadnt even asked for, like 2 chars for language and I guess it makes very much sense in considering these for situations like EN-US or EN-UK. It was really insightful. On 2/7/06, Patrick JACQUOT <[EMAIL PROTECTED]> w

Re: [SQL] problem referencing an attrib which is not unique

2006-02-07 Thread Patrick JACQUOT
Vic Rowan wrote: -- Forwarded message -- From: *Vic Rowan* <[EMAIL PROTECTED] > Date: Feb 7, 2006 2:31 PM Subject: problem referencing an attrib which is not unique To: pgsql-sql@postgresql.org hello everybody, I ne

Re: [SQL] problem referencing an attrib which is not unique

2006-02-07 Thread Richard Huxton
Vic Rowan wrote: CREATE TABLE event_msg ( event_id varchar(30) NOT NULL, language char(2) NOT NULL, predefined_msg varchar(250) NOT NULL, PRIMARY KEY (event_id, language) ); CREATE TABLE logs ( id int NOT NULL, event_id varchar(30) REFERENCES event_msg (event_id) NOT NULL, placehol

[SQL] problem referencing an attrib which is not unique

2006-02-07 Thread Vic Rowan
-- Forwarded message --From: Vic Rowan <[EMAIL PROTECTED]>Date: Feb 7, 2006 2:31 PM Subject: problem referencing an attrib which is not uniqueTo: pgsql-sql@postgresql.orghello everybody,I need some thing like this below for an application which stores log messages in multiple langua

Re: [SQL] passing array to database function

2006-02-07 Thread Achilleus Mantzios
O Richard Huxton έγραψε στις Feb 7, 2006 : > padmanabha konkodi wrote: > > Β hi everybody, > > > > i want to pass Integer array to database function from java > > precompiled statement. > > > > java gives java.sql.Array interface but i dont know which > > implementing class i have to use in post

Re: [SQL] passing array to database function

2006-02-07 Thread Richard Huxton
padmanabha konkodi wrote: Â hi everybody, i want to pass Integer array to database function from java precompiled statement. java gives java.sql.Array interface but i dont know which implementing class i have to use in postgre I don't really "do" java, but have you tried an array of integers

[SQL] passing array to database function

2006-02-07 Thread padmanabha konkodi
 hi everybody, i want to pass Integer array to database function from java precompiled statement. java gives java.sql.Array interface but i dont know which implementing class i have to use in postgre regards ptrashantha.k.p

Re: [SQL] query

2006-02-07 Thread Richard Huxton
superboy143 (sent by Nabble.com) wrote: Hello, I have a table in which I have a field with format like 100101. It has many values like 100101, 100102, 100103, 100201, 100202, 100301. OK - so they look like numbers but aren't. I have to write a query such that I have to get only distinct valu

[SQL] query

2006-02-07 Thread superboy143 (sent by Nabble.com)
Hello, I have a table in which I have a field with format like 100101. It has many values like 100101, 100102, 100103, 100201, 100202, 100301. I have to write a query such that I have to get only distinct values such that they contain only the substring I need. If I give 10 as substring, then it