Re: [SQL] Existential quantifier

2009-10-09 Thread Stephan Szabo
On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm??rgrav wrote: > Stephan Szabo writes: > > Not at all tested as I don't have access to my db right now, but I think > > something like one of these would work: > > > > select fs.film.title, fs.film.year > > from f

Re: [SQL] Existential quantifier

2009-10-09 Thread Stephan Szabo
On Sat, 10 Oct 2009, [utf-8] Dag-Erling Sm??rgrav wrote: > Consider the attached schema (filmstars.sql), which is a poorly designed > database of films and actors. The following query gives me a list of > films in which either Charlie or Martin Sheen starred: > > select fs.film.title, fs.film.yea

Re: [SQL] JOIN and aggregate problem

2009-02-20 Thread Stephan Szabo
On Fri, 20 Feb 2009, Tarlika Elisabeth Schmitz wrote: > I have 2 tables T1 and T2 > > T1 has the columns: D, S, C. The combination of D,S,C is unique. > T2 has the columns: D, S, C, and boolean X. The combination of D,S,C is > not unique. > > I need to produce the following result for every occurr

Re: [SQL] Must I use DISTINCT?

2009-02-05 Thread Stephan Szabo
On Thu, 5 Feb 2009, Michael B Allen wrote: > Please consider the following SQL > > SELECT e.eid, e.name > FROM entry e, access a > WHERE e.eid = 120 > AND (e.ownid = 66 OR e.aid = a.aid) > > The intent is to match one entry with the eid of 120. However I would > like to impose an addition

Re: [SQL] prepared query plan did not update

2008-09-17 Thread Stephan Szabo
On Wed, 17 Sep 2008, Emi Lu wrote: > Stephan Szabo wrote: > > On Wed, 17 Sep 2008, Emi Lu wrote: > > > >> Good morning, > >> > >> I tried to use prepared query plan to update columns, but it did not > >> update at all. > >> > >&

Re: [SQL] prepared query plan did not update

2008-09-17 Thread Stephan Szabo
On Wed, 17 Sep 2008, Emi Lu wrote: > Good morning, > > I tried to use prepared query plan to update columns, but it did not > update at all. > > PREPARE pname(varchar) AS > UPDATE t1 > SETcol1 = false > WHERE col1 AND > col2 = '$1' ; I don't think you want those quotes in the second

Re: [SQL] Aggregates in WHERE clause?

2008-09-10 Thread Stephan Szabo
On Wed, 10 Sep 2008, Ruben Gouveia wrote: > I tried to do the following and got the following error message: > > select employee,count(distinct tasks) > from job > where greatest(max(last_job_date),max(last_position_date)) < > 2008-08-28 + integer '1' > group by employee; >

Re: [SQL] What is wrong with this PostgreSQL UPDATE statement??

2008-08-22 Thread Stephan Szabo
On Fri, 22 Aug 2008, Steve Johnson wrote: > update certgroups > set termgroupname = tg.termgroupname > from certgroups c, termgroup tg > where (c.days >= tg.mindays) and (c.days <= tg.maxdays); In recent PostgreSQL versions I believe this is properly written: update certgroups c set termgroupnam

Re: [SQL] Strange query duration

2008-07-22 Thread Stephan Szabo
On Tue, 22 Jul 2008, Fernando Hevia wrote: > I just enabled log duration in a 8.3.1 database and got puzzling > information. > I have a daemon shell-script run every 10 seconds the following: > >psql -c "select f_tasador();" > > The 'f_tasador' procedure is quite fast. As per log output I can

Re: [SQL] Whassup with this? (create table .... like ... fails)

2008-07-19 Thread Stephan Szabo
On Sat, 19 Jul 2008, Karl Denninger wrote: > childrensjustice=# create table petition_new like petition_bail; > ERROR: syntax error at or near "like" > LINE 1: create table petition_new like petition_bail; As far as I can tell from the syntax description, the LIKE petition_bail should be in the

Re: [SQL] Query question

2008-05-22 Thread Stephan Szabo
On Thu, 22 May 2008, Medi Montaseri wrote: > Hi, > I can use some help with the following query please. > > Given a couple of tables I want to do a JOIN like operation. Except that one > of the columns might be null. > > create table T1 ( id serial, name varchar(20) ); > create table T2 ( id seria

Re: [SQL] Joining with result of a plpgsql function

2008-05-07 Thread Stephan Szabo
On Wed, 7 May 2008, Matthew T. O'Connor wrote: > I have a pl/pgsql function, defined as: > > CREATE FUNCTION tms.get_tms_summary(id integer) >RETURNS tms.tms_summary > > get_tms_summary returns a composite type, tms_summary, which is > comprised of several numerics. > > What I would like to d

Re: [SQL] trim(both) problem?

2008-04-25 Thread Stephan Szabo
On Fri, 25 Apr 2008, Emi Lu wrote: > Hi, > > Isn't this a bug about trim both. > > select trim(both '' from 'ROI Engineering Inc.'); > btrim > - > OI Engineering Inc. > (1 row) > > > "R" is missing? How? Trim doesn't do what you think it does. The '' in the above

Re: [SQL] apparent RI bug

2008-04-03 Thread Stephan Szabo
On Thu, 3 Apr 2008, chester c young wrote: > --- Stephan Szabo <[EMAIL PROTECTED]> wrote: > > > Is it possible you ever had a before delete trigger that just did a > > return > > NULL rather than raising an exception? IIRC, explicitly telling the > > system t

Re: [SQL] apparent RI bug

2008-04-03 Thread Stephan Szabo
On Thu, 3 Apr 2008, chester c young wrote: > > Stephan Szabo <[EMAIL PROTECTED]> wrote: > > > On Wed, 2 Apr 2008, chester c young wrote: > > > > > it appears I have a broken RI in my db. > > > Yeah, that looks pretty broken. Can you reproduce this f

Re: [SQL] apparent RI bug

2008-04-03 Thread Stephan Szabo
On Wed, 2 Apr 2008, chester c young wrote: > it appears I have a broken RI in my db. > > call_individual.clh_id references call_household.clh_id > > \d call_individual > ... > Foreign-key constraints: > "call_individual_clh_id_fkey" FOREIGN KEY (clh_id) REFERENCES > call_household(clh_id) ON D

Re: [SQL] difference between EXCEPT and NOT IN?

2008-04-01 Thread Stephan Szabo
On Tue, 1 Apr 2008, Raphael Bauduin wrote: > The 2 following statements don't give the same result. I expected the > second ti give the exact same result as the first one. If any entree_id can be NULL they aren't defined to give the same result. EXCEPT is defined in terms of duplicates based on

Re: [SQL] trap for any exception

2007-11-15 Thread Stephan Szabo
On Thu, 15 Nov 2007, Sabin Coanda wrote: > Hi there, > > I'd like to build a PL/pgSQL function which is able to generic trap any > error, and interpret it. > > I read 37.7.5. Trapping Errors, but the syntax requires to write explicitly > the exception condition, and not a generic one. > > Is it po

Re: [SQL] trap for any exception

2007-11-15 Thread Stephan Szabo
On Thu, 15 Nov 2007, Sabin Coanda wrote: > > > > I read 37.7.5. Trapping Errors, but the syntax requires to write > > explicitly the exception condition, and not a generic one. > > > > Is it possible to build a generic trap or do you know a workaround for > > that ? > > > Sorry, I found the OTHERS

Re: [SQL] Why does the sequence skip a number with generate_series?

2007-10-03 Thread Stephan Szabo
On Tue, 2 Oct 2007, Jeff Frost wrote: > I expected these numbers to be in sync, but was suprised to see that the > sequence skips a values after every generate series. > > CREATE TABLE jefftest ( id serial, num int ); > INSERT INTO jefftest (num) values (generate_series(1,10)); > INSERT INTO jefft

Re: [SQL] Alternative to INTERSECT

2007-07-31 Thread Stephan Szabo
On Tue, 31 Jul 2007, Andreas Joseph Krogh wrote: > Hi all. I have the following schema: > > CREATE TABLE test ( > id integer NOT NULL, > field character varying NOT NULL, > value character varying NOT NULL > ); > > ALTER TABLE ONLY test > ADD CONSTRAINT test_id_key UNIQUE (id, fiel

Re: [SQL] How to cast, if type has spaces in the name

2007-07-26 Thread Stephan Szabo
On Thu, 26 Jul 2007, Bryce Nesbitt wrote: > How do I specify a cast, if the type name has spaces? foo::integer is > easy, > but foo::'timestamp without time zone' is more murky. foo::timestamp without time zone should work (no quotes). Another alternative if you don't like the way that looks is

Re: [SQL] hi

2007-04-24 Thread Stephan Szabo
On Tue, 24 Apr 2007, Penchalaiah P. wrote: > Hi > > I have the data like this in temp table > > SQL> Select sno, value from temp; > > SNO Value > > 1 650.00 > > 2 850.00 > > 3 640.00 > > 3 985

Re: [SQL] [ADMIN] Another question in functions

2007-04-09 Thread Stephan Szabo
On Sun, 8 Apr 2007, Karthikeyan Sundaram wrote: > > Hi team, > > I have a requirement like this. > create table valid_lovs (code_id int not null,lov_value int not null > ,description varchar(256),status bit(1) not null default '1',constraint > lov_pk primary key (code_id,lov_value)); > I n

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-25 Thread Stephan Szabo
On Thu, 25 Jan 2007, Mario Splivalo wrote: > When I try to use TEMPORARY TABLE within postgres functions (using 'sql' > as a function language), I can't because postgres can't find that > temporary table. Consider this example: > > CREATE FUNCTION func1() RETURNS SETOF v_messages_full AS $BODY$ >

Re: [SQL] Help ... Unexpected results when using limit/offset with

2007-01-18 Thread Stephan Szabo
On Thu, 18 Jan 2007, Barbara Cosentino wrote: > Then I perform the following selects > > SELECT host_id, host_datum_type_id, host_datum_source_id, data > FROM nc_host_datum INNER JOIN nc_host USING (host_id) > WHERE audit_id=2041 > ORDER BY host_id > LIMIT 49 OFFSET 1372; > > And > > SELECT host_

Re: [SQL] Problem inserting composite type values

2006-12-01 Thread Stephan Szabo
On Fri, 1 Dec 2006, Chris Dunworth wrote: > Hi all -- > > (huge apologies if this is a duplicate post -- I sent from an > unsubscribed email account before...) > > I have a problem trying to INSERT INTO a table by selecting from a > function that returns a composite type. (I'm running version 8.1.

Re: [SQL] SQL command join question

2006-11-29 Thread Stephan Szabo
On Wed, 29 Nov 2006, Ehab Galal wrote: > I have three tables t1(a, b, c, d), t2(a, b, c, k), and t3(c, e). I need to > outer join them as shown below, but only have all tuples from t1 as output. > But the following syntax does not allow me to do so. > > SELECT t1.* > FROM (t1 outer join t2 on (t1.

Re: [SQL] Subselects in CHECK clause ...

2006-11-29 Thread Stephan Szabo
On Wed, 29 Nov 2006, James Robinson wrote: > I see that subselects are not directly supported in check clauses, > but one can work around that by writing a stored function which > returns boolean and performs the subselect. Are there any known > gotchas with doing this? To completely get the con

Re: [HACKERS] [SQL] Case Preservation disregarding case

2006-10-31 Thread Stephan Szabo
On Tue, 31 Oct 2006, Chuck McDevitt wrote: > We treated quoted identifiers as case-specific, as the spec requires. > > In the catalog, we stored TWO columns... The column name with case > converted as appropriate (as PostgreSQL already does), used for looking > up the attribute, > And a second col

Re: [SQL] delete on cascade

2006-10-23 Thread Stephan Szabo
On Mon, 23 Oct 2006, Luca Ferrari wrote: > Hi all, > I guess this is an already asked question, but I didn't found an answer, so > apologize me. Imagine I've got two tables: > skill(id,description) // primary key => id > family(id,description)// primary key => id > and I want to a

Re: [SQL] age() vs. timestamp substraction

2006-10-06 Thread Stephan Szabo
On Fri, 6 Oct 2006, Jean-Paul Argudo wrote: > Hi all, > > > Where did you get that idea? age's reference point is current_date (ie, > > midnight) not now(). There are also some differences in the calculation > > compared to a plain timestamp subtraction. > > I'm jumping on this thread to point o

Re: [SQL] Is it possible to left join based on previous joins result

2006-09-07 Thread Stephan Szabo
On Thu, 7 Sep 2006, Emi Lu wrote: > Hello, > > Is it possible to do something like: > > select ... > from t1 > inner join t2 ... > left join t2.colN > > When t1 inner join with t2 I got unique result for t2.colN( colN's value > is table name). > > Can I continue to left join with the column "colN"

Re: [SQL] Problem with FOR UPDATE

2006-09-07 Thread Stephan Szabo
On Thu, 7 Sep 2006, Kaloyan Iliev wrote: > Hi All, > I have a query in which I want to SELECT FOR UPDATE same rows but only > from one table. > Firs I try just with SELECT FOR UPDATE but I receive an error > because of the LEFT JOIN - "ERROR: SELECT FOR UPDATE/SHARE cannot be > applied to the nu

Re: [SQL] help with pagila

2006-09-01 Thread Stephan Szabo
On Fri, 1 Sep 2006, Walter Cruz wrote: > Hi all. I'm with a little doubt. > > I'm testing the pagila (the postgres port of mysql sakila sample). > > Well, I was trying to translate the query: > > select > film.film_id AS FID, > film.title AS title, > film.description AS description

Re: [SQL] joining VIEWs

2006-08-22 Thread Stephan Szabo
On Tue, 22 Aug 2006, Brian Cox wrote: > Given a view like: > > create view view1 as > select g.id as UserGroupId, s.uid as UserId, s.time as StartTime from stats > s join groups g on g.uid = s.uid > > and a SELECT like: > > select a.UserGroupId,b.UserGroupId from view1 a > full outer join vi

Re: [SQL] CREATE TABLE AS inside of a function

2006-07-24 Thread Stephan Szabo
On Mon, 24 Jul 2006, Kevin Nikiforuk wrote: > So, I've changed my code as Erik suggested: > > CREATE OR REPLACE FUNCTION rgio() RETURNS INTEGER as $$ > DECLARE > lv RECORD; > > BEGIN > FOR lv IN SELECT DISTINCT rg > FROM ldevrg > LOOP > >

Re: [SQL] Error when trying to use a FOR loop

2006-07-21 Thread Stephan Szabo
On Fri, 21 Jul 2006, Kevin Nikiforuk wrote: > Many thanks to Stephan, Richard and George. When I was reading the > documentation about FOR loops, I didn't realize that I was in the plpgsql > section! > > CREATE OR REPLACE FUNCTION rgio() RETURNS integer as $$ > BEGIN > DECLARE lv RECORD

Re: [SQL] Error when trying to use a FOR loop

2006-07-20 Thread Stephan Szabo
On Thu, 20 Jul 2006, Kevin Nikiforuk wrote: > Sorry if this is in the archives, but I've done a search and couldn't > find anything relevant. I'm running HP's precompiled version of 8.1.3.1 > as part of their Internet Express offering, and I can't seem to run a > for loop. Here's what I'm seeing:

Re: [SQL] Help with privilages please

2006-07-20 Thread Stephan Szabo
On Thu, 20 Jul 2006, Hilary Forbes wrote: > Dear All > > We are running pg v 7.4.1 and importantly the database has been > converted from earlier versions of pg (6.5 I seem to recall). > > I have an existing table suppliers and I have created a new user 'hilary' > > REVOKE ALL on TABLE suppliers F

Re: [SQL] Atomar SQL Statement

2006-07-07 Thread Stephan Szabo
On Fri, 7 Jul 2006, Michael Glaesemann wrote: > > On Jul 7, 2006, at 7:55 , Weber, Johann (ISS Kassel) wrote: > > > My concern: in a multi threaded environment, can a second thread > > interrupt this statement and eventually insert the same email > > address in > > the table with a different id?

Re: [SQL] Problem with SET CONSTRAINTS ALL DEFERRED;

2006-05-19 Thread Stephan Szabo
On Fri, 19 May 2006, Kaloyan Iliev wrote: > Hi Friends, > > I am trying to postpone the foreign key constraint check till the end of > transaction but it doesn't work. > Can anyone help me with a tip what I am doing wrong. Was the constraint created as deferrable (which is not the default)? ALL D

Re: [SQL] problem with uniques and foreing keys

2006-05-06 Thread Stephan Szabo
On Sat, 6 May 2006, kernel.alert kernel.alert wrote: > I create the follow tables... > > > > CREATE TABLE empresa ( > id_empresa integer NOT NULL primary key, > nombre varchar(45), > ); > CREATE TABLE casino ( > i

Re: [SQL] is an explicit lock necessary?

2006-05-04 Thread Stephan Szabo
On Thu, 4 May 2006, Ash Grove wrote: > Hi, > > Does beginning a transaction put locks on the tables > queried within the transaction? > > In the example below, is #2 necessary? My thought was > that I would need to use an explicit lock to make sure > that the sequence value I'm selecting in #4 is

Re: [SQL] Outer joins?

2006-04-28 Thread Stephan Szabo
On Fri, 28 Apr 2006, Emils wrote: > I am trying to do simple self-joins. > > The table structure is: > > object_values > == > obj_id > att_id > value > > namely, each object can have arbitrary number of attributes each of > them with a value. > > What I want, is a simple table of objects w

Re: [SQL] trigger to enforce FK with nulls?

2006-04-12 Thread Stephan Szabo
On Wed, 12 Apr 2006, George Young wrote: > [PostgreSQL 8.1.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.1] > > I'm starting to use lots of foreign key constraints to keep my > data clean. In one case, however, I need to allow null values > for the key. E.g.: > > create table opset_steps

Re: [SQL] have you feel anything when you read this ?

2006-04-06 Thread Stephan Szabo
On Thu, 6 Apr 2006, Eugene E. wrote: > Stephan Szabo wrote: > >>>What would you expect it to do given a single result format argument? > >>> > >>>If you want to propose a new function (set of functions) that have > >>>different behavior, make

Re: [SQL] have you feel anything when you read this ?

2006-04-06 Thread Stephan Szabo
On Thu, 6 Apr 2006, Stephan Szabo wrote: > On Thu, 6 Apr 2006, Eugene E. wrote: > > If you meant that you must retrieve them in a separate query, you're > incorrect, since you *could* use the binary form for the others. I can't > understand if you don't realize t

Re: [SQL] have you feel anything when you read this ?

2006-04-06 Thread Stephan Szabo
r values, I don't see how that's relevant until you've proven the rest of the argument (*). > Stephan Szabo wrote: > > > What would you expect it to do given a single result format argument? > > > > If you want to propose a new function (set of functions) tha

Re: [SQL] have you feel anything when you read this ?

2006-04-05 Thread Stephan Szabo
On Thu, 6 Apr 2006, Eugene E. wrote: > Stephan Szabo wrote: > > On Wed, 5 Apr 2006, Eugene E. wrote: > > > > > >>Stephan Szabo wrote: > >> > >>>On Tue, 4 Apr 2006, Eugene E. wrote: > >>> > >>> > >>&g

Re: [SQL] have you feel anything when you read this ?

2006-04-05 Thread Stephan Szabo
On Wed, 5 Apr 2006, Eugene E. wrote: > Stephan Szabo wrote: > > On Tue, 4 Apr 2006, Eugene E. wrote: > > > > > >>Stephan Szabo wrote: > >> > >>>On Fri, 31 Mar 2006, Eugene E. wrote: > >>> > >>&g

Re: [SQL] have you feel anything when you read this ?

2006-04-04 Thread Stephan Szabo
On Tue, 4 Apr 2006, Eugene E. wrote: > Stephan Szabo wrote: > > On Fri, 31 Mar 2006, Eugene E. wrote: > > > > > >>Peter Eisentraut wrote: > >> > >>>Eugene E. wrote: > >>> > >>> > >>>>th

Re: [SQL] have you feel anything when you read this ?

2006-03-31 Thread Stephan Szabo
On Fri, 31 Mar 2006, Eugene E. wrote: > Peter Eisentraut wrote: > > Eugene E. wrote: > > > >>the problem is: you'll get this four byte sequence '\000' _instead_ > >>of NUL-byte anyway. > > > > > > What you seem to be missing is that PostgreSQL data can be represented > > in textual and in binary f

Re: [SQL] results being col wise rather than row wise

2006-03-29 Thread Stephan Szabo
On Wed, 29 Mar 2006, Hrishikesh Deshmukh wrote: > HI All, > > I have 5 tables which have different columns as shown below, each table has > a different case column, > i want to retrieve sample related information as follows: > > pid | xindex | yindex | height Index | flag | case1 | case 2.etc

Re: [SQL] Problem using set-returning functions

2006-03-27 Thread Stephan Szabo
On Mon, 27 Mar 2006, Markus Schaber wrote: > Hi, John, > > John DeSoi wrote: > > > With SRFs, you need to specify what you want to select. In other words > > if you are calling generate_x(bar) you need "select * from > > generate_x(bar)" -- "select generate_x(bar)" will not work. > > So, then, wh

Re: [SQL] SQL Query Newbie Help

2006-03-24 Thread Stephan Szabo
On Fri, 24 Mar 2006, Julie Robinson wrote: > This works, but is there a better solution? > > select * > from quality_control_reset T > where date = ( > select max(date) > from quality_control_reset > where qualitycontrolrange = T.qualitycontrolrange); If you can use PostgreSQL extens

Re: [SQL] Using a parameter in Interval

2006-03-21 Thread Stephan Szabo
On Tue, 21 Mar 2006, Davidson, Robert wrote: > No matter how I try to concatenate, I can't seem to get a parameter to be > used by INTERVAL in a function: > > CREATE OR REPLACE FUNCTION Testing(TrailingWeeks int) RETURNS date AS $$ > BEGIN > RETURN current_date - INTERVAL (CAST(TrailingWeek

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread Stephan Szabo
On Tue, 21 Mar 2006 [EMAIL PROTECTED] wrote: > I mistakenly swapped the tables in my email. Here they are, corrected: > > Table "url": > id SERIAL > CONSTRAINT pk_url_id PRIMARY KEY > > Table "bookmark": > url_id INTEGER >

Re: [SQL] Referential integrity broken (8.0.3), sub-select help

2006-03-21 Thread Stephan Szabo
On Tue, 21 Mar 2006 [EMAIL PROTECTED] wrote: > I've got 2 tables, "url" (U), and "bookmark" (B), with "bookmark" pointing to > "url" via FK. That's not what your schema below has. Your fragment below has URL pointing to bookmark. > Somehow I ended up with some rows in B referencing non-existen

Re: [SQL] functions in WHERE clause

2006-03-05 Thread Stephan Szabo
On Sun, 5 Mar 2006 [EMAIL PROTECTED] wrote: > On Sun, Mar 05, 2006 at 11:38:46AM -0800, Stephan Szabo wrote: > > > But imagine instead that this function is more generic. You know > > > that you're trying to get something that's equal to x and equal to > &g

Re: [SQL] functions in WHERE clause

2006-03-05 Thread Stephan Szabo
On Sun, 5 Mar 2006 [EMAIL PROTECTED] wrote: > On Sun, Mar 05, 2006 at 01:16:40PM -0500, Tom Lane wrote: > > [EMAIL PROTECTED] writes: > > That would work fine if you said RETURNS SETOF ltree. > > > > That should work too, except that you are trying to return a record > > not an ltree value. Try "

Re: [HACKERS] [SQL] Interval subtracting

2006-03-01 Thread Stephan Szabo
On Wed, 1 Mar 2006, Hannu Krosing wrote: > Ühel kenal päeval, K, 2006-03-01 kell 15:18, kirjutas Bruce Momjian: > > Stephan Szabo wrote: > > > > justify_days doesn't currently do anything with this result --- it > > > > thinks its charter is only to red

Re: [SQL] Help with trigger that updates a row prior to a potentially

2006-03-01 Thread Stephan Szabo
On Wed, 1 Mar 2006, Simon Kinsella wrote: > Hi all, > > I have a situation where a DELETE operation may (correctly) fail due to a > RESTRICT FK constraint. If so, I need to set a flag in the row indicating > that it has been marked for deletion so that I can disregarded in subsequent > queries. >

Re: [SQL] how to add primary key to existing table with multiple

2006-02-28 Thread Stephan Szabo
On Thu, 23 Feb 2006, Daniel Joo wrote: > I am trying to add another primary key to an existing table with two > other primary keys. I got the following error when I tried this > command: You only can have one primary key. The table you gave has a single primary key with two columns. Are you tr

Re: [SQL] After Trigger assignment to NEW

2006-02-25 Thread Stephan Szabo
On Sat, 25 Feb 2006, Achilleus Mantzios wrote: > O Owen Jacobson ?? Feb 24, 2006 : > > > Achilleus Mantzios wrote: > > > > > O Tom Lane ?? Feb 24, 2006 : > > > > > > > By definition, an AFTER trigger is too late to change what was > > > > stored. Use a BEFORE trigger. > > > > > >

Re: [SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-19 Thread Stephan Szabo
On Sun, 19 Feb 2006, Henry Ortega wrote: > I was able to find a suitable 7.3.2 plpgsql.so and now plpgsql works. > (supposedly) > > I am trying out some really basic function creation such as this: > > create function dng2(start_date DATE) returns setof date as $$ > declare > aa date:=start_date;

Re: [SQL] Interval subtracting

2006-02-18 Thread Stephan Szabo
On Sat, 18 Feb 2006, Tom Lane wrote: > "Milen A. Radev" <[EMAIL PROTECTED]> writes: > > Milorad Poluga : > >>> SELECT '10 years 1 mons 1 days'::interval - '9 years 10 mons 15 > >>> days'::interval > >>> ?column? > >>> --- > >>> 3 mons -14 days > >>> > >>> Why not '2 mons

Re: [SQL] alter table

2006-02-15 Thread Stephan Szabo
On Wed, 15 Feb 2006, Owen Jacobson wrote: > Maciej Piekielniak wrote: > > > > Wednesday, February 15, 2006, 8:31:17 PM, you wrote: > > OJ> Note that prior to 8.0 PostgreSQL does not support > > multiple ALTER actions in a single query. To get an > > equivalent effect, wrap separate ALTER TABLE qu

Re: [SQL] Trigger/Sequence headache

2006-02-12 Thread Stephan Szabo
On Sun, 12 Feb 2006, Foster, Stephen wrote: > This is going to be one of those stupid problems of mine. I have an > insert trigger setup to verify that duplicate or repeating information > isn't storage in the table. If trigger function finds the information > as a duplicate it returns a NULL a

Re: [SQL] executing dynamic commands

2006-02-01 Thread Stephan Szabo
On Wed, 1 Feb 2006 [EMAIL PROTECTED] wrote: > Hi, > > I user PostgreSQl 8.0.4 on Win2003 Server and write a function to copy rows > from one table into another table with the same column definition. > My first approach was to use something like: > > query_value := 'INSERT INTO ' || tabledest ||

Re: [SQL] Question about check constraints

2006-01-27 Thread Stephan Szabo
On Fri, 27 Jan 2006, Kashmira Patel (kupatel) wrote: > Both concerns. > 1) There are actually more than two columns with such checks, and each > one calls a few functions which execute some more queries. So I would > like to invoke these checks only when necessary. > 2) The bigger concern is the

Re: [SQL] Changing the transaction isolation level within the stored

2006-01-26 Thread Stephan Szabo
On Thu, 26 Jan 2006, Markus Schaber wrote: > AFAIK, in PostgreSQL normal SQL commands cannot create deadlocks at all, > the only way to introduce deadlocks is to issue LOCK commands to take > locks manually. And for this rare case, PostgreSQL contains a deadlock > detection routine that will abo

Re: [SQL] How to get a count() where column < ''?

2005-12-04 Thread Stephan Szabo
On Sun, 4 Dec 2005, Joost Kraaijeveld wrote: > Hi Stephan, > > On Sun, 2005-12-04 at 13:33 -0800, Stephan Szabo wrote: > > > SELECT COUNT(customers.objectid) FROM prototype.customers, > > > prototype.addresses > > > WHERE > > > customers.

Re: [SQL] How to get a count() where column < ''?

2005-12-04 Thread Stephan Szabo
On Sun, 4 Dec 2005, Joost Kraaijeveld wrote: > Hi, > > I want the number of customers that have a zipCode smaller tha a given > value. The foolowing query doe snot work : I get an error (ERROR: > column "addresses.zipcode" must appear in the GROUP BY clause or be used > in an aggregate function) a

Re: [SQL] argument type problem with plpgsql function

2005-11-22 Thread Stephan Szabo
On Tue, 22 Nov 2005, Luca Pireddu wrote: > I wrote a little function that has to work with big numbers > > CREATE OR REPLACE FUNCTION blast_evalue(seq_len bigint, db_size bigint, > bit_score double precision) > RETURNS double precision AS $$ > BEGIN > RETURN 2^(bit_score) * db_size * seq_len;

Re: [SQL] Problem with "NOT IN (subquery)

2005-11-13 Thread Stephan Szabo
On Sun, 13 Nov 2005, Steve SAUTETNER wrote: > Hi, > > I have a table named "famille" whose structure and content is : > > famille_code | famille_mere_famille_code | famille_libelle | > famille_niveau > --+---+---+- > --- > 00

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Stephan Szabo
On Wed, 26 Oct 2005, Mario Splivalo wrote: > Consider this function: > > CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4, > "varchar") > RETURNS SETOF "varchar" AS > $BODY$ > DECLARE > aRecordID ALIAS FOR $1; > aSubFieldId ALIAS FOR $2; > > returnValue record; >

Re: [SQL] NULL in IN clause

2005-10-19 Thread Stephan Szabo
On Wed, 19 Oct 2005, [iso-8859-2] Havasv?lgyi Ott? wrote: > Hi, > > I have just run this command on 8.0.4 : > > SELECT 'foo' WHERE 0 NOT IN (NULL, 1); > > And it resulted is zero rows. > Without NULL it is OK. > Is this a bug, or the standard has such a rule? This is standard behavior. Seeing if

Re: [SQL] pg, mysql comparison with "group by" clause

2005-10-11 Thread Stephan Szabo
On Tue, 11 Oct 2005, Rick Schumeyer wrote: > I'm not sure what I was thinking, but I tried the following query in pg: > > SELECT * FROM t GROUP BY state; > > pg returns an error. > > Mysql, OTOH, returns the first row for each state. (The first row with > "AK", the first row with "PA", etc.) > >

Re: [SQL] Use of partial index

2005-10-05 Thread Stephan Szabo
On Wed, 5 Oct 2005, Leif B. Kristensen wrote: > I'm a little confused about partial indexes. I have a couple of tables, > like this: > > CREATE TABLE events ( > event_idINTEGER PRIMARY KEY, > tag_type_fk INTEGER REFERENCES tag_types (tag_type_id), > place_fkINTEGER REFERENCES

Re: [SQL] plpgsql function not accepting NULL value

2005-09-16 Thread Stephan Szabo
On Fri, 16 Sep 2005, Kenneth Dombrowski wrote: > I can't get this one to work at all: > > create or replace function update_rate (integer, integer, integer, > integer, numeric, integer) > returns void > as ' > declare > x_admin_id alias for $1; >

Re: [SQL] ERROR: syntax error at or near "select" at character 9

2005-09-06 Thread Stephan Szabo
On Tue, 6 Sep 2005, Harald Fuchs wrote: > In article <[EMAIL PROTECTED]>, > Stephan Szabo <[EMAIL PROTECTED]> writes: > > > On Fri, 2 Sep 2005, [ISO-8859-2] Graf László wrote: > > >> > >> CREATE FUNCTION test_verif() RETURNS trigger AS $test

Re: [SQL] ERROR: syntax error at or near "select" at character 9

2005-09-05 Thread Stephan Szabo
On Fri, 2 Sep 2005, [ISO-8859-2] Graf L?szl? wrote: > >CREATE FUNCTION test_verif() RETURNS trigger AS $test_verif$ >BEGIN >NEW.id := select nextval('test_azon_seq'); I think you want to remove select here, you're already effectively doing a select of the right hand side

Re: [SQL] Weird Trigger Behaviour using IF ... THEN ... ESLEIF...

2005-09-05 Thread Stephan Szabo
On Mon, 5 Sep 2005, Antony Sohal wrote: > Please can you help me with the following trigger I have written in > PostgreSQL 7.4.8 running under Fedora Linux, using pgAdmin III as > client. > Now I create a trigger on event table as : > > CREATE OR REPLACE FUNCTION fn_event() > RETURNS "trigger"

Re: [SQL] Table Constraint CHECK(SELECT()) alternative?

2005-09-05 Thread Stephan Szabo
On Sat, 3 Sep 2005, Robert D. Kennedy wrote: > I have seen in another thread that sub-queries in a CHECK > constraint have implementation ramifications that make them awkward to > implement and support. OK, fair enough, c'est la vie. > > ERROR: cannot use subquery in check constraint > > is

Re: [SQL] Why Doesn't SQL This Expression Work?

2005-08-22 Thread Stephan Szabo
On Mon, 22 Aug 2005, Lane Van Ingen wrote: > Hi, am trying to do a simple computation on two views, but for some reason > the current_util_in computation always returns zero. All fields being used > are integer. > > select a.if_id, > a.in_count, > a.time_incr, > b.speed, > ((a.t

Re: [SQL] Problem calling stored procedure

2005-08-22 Thread Stephan Szabo
On Mon, 22 Aug 2005 [EMAIL PROTECTED] wrote: > Hi all, > > I've written a stored procedure but am having trouble calling it. > > The procedure name is called "insert_period" and I am calling using: > > SELECT > insert_period(1::INTEGER,'2005-09-13'::DATE,'2005-09-15'::DATE,'unavailable_periods');

Re: [SQL] Parentheses in FROM clause and evaluation order.

2005-08-15 Thread Stephan Szabo
On Mon, 15 Aug 2005, Dario Bahena Tapia wrote: > The final result seems to be the same, I just was curious about the > standard behavior. Does the SQl says something about this execution > order? I believe SQL defines the order to pay attention to parens, so A join (B join C) style clauses result

Re: [SQL] Parentheses in FROM clause and evaluation order.

2005-08-15 Thread Stephan Szabo
On Wed, 10 Aug 2005 [EMAIL PROTECTED] wrote: > I thought that the parenthesis in the table expression > (FROM clause), could be used to indicate the desired > evaluation order. But, I tried with a couple of samples > and the explain command returned me the same result; no matter > what parentheses

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Stephan Szabo
On Wed, 22 Jun 2005, Tom Lane wrote: > Stephan Szabo <[EMAIL PROTECTED]> writes: > >> CREATE TRIGGER u_test1 BEFORE DELETE ON portfolio.test1 FOR EACH ROW > >> EXECUTE > >> PROCEDURE resort_test1(); > > > I think this will work in an after delete tr

Re: [SQL] after delete trigger behavior

2005-06-22 Thread Stephan Szabo
On Wed, 22 Jun 2005, Russell Simpkins wrote: > Hello, > > I have created a trigger function to update the sort_order column of a > mapping table. I have table a that has a many to many relation ship with > table b that is mapped as a_b where a_id, and b_id are the pk columns and > there is a sort

Re: [SQL] rule or trigger?

2005-06-07 Thread Stephan Szabo
On Tue, 7 Jun 2005, M.D.G. Lange wrote: > It is not possible to create a constraint Foreign key for "wordid". No > problem there, but I want to be certain that a given wordid exists in > tbldictionary. > Would I have to create a "RULE" or a "TRIGGER" to be certain that the > wordid is existing in

Re: [SQL] Discordance between the way select is called.

2005-05-07 Thread Stephan Szabo
> Hi, > > I have a java app that uses hibernate to do queries. > > One query on a 6.5 millions records takes about 15 seconds while the > same one (take from the sql that shows in the consol - I configured > hibernate to show_sql) takes about 50 ms when done with pgadmin3. We could answer better w

Re: [SQL] multi-column unique constraints with nullable columns

2005-04-30 Thread Stephan Szabo
On Sat, 30 Apr 2005, Tornroth, Phill wrote: > >I believe you can add partial unique indexes to cover the case where a > >column is null, but if you have multiple nullable columns you need to > >worry about you end up with a bunch of indexes. > > Hmmm. I hadn't thought of that, thanks. Yes, the ind

Re: [SQL] multi-column unique constraints with nullable columns

2005-04-29 Thread Stephan Szabo
On Fri, 29 Apr 2005, Tornroth, Phill wrote: > I have many tables who's natural key includes a nullable column. In this > cases it's a soft-delete or 'deprecated' date time. I'd like to add a > table constraint enforcing this constraint without writing a custom > procedure, but I've found that post

Re: [SQL] Division in Postgre

2005-04-29 Thread Stephan Szabo
On Sun, 24 Apr 2005, tuan wrote: > In sql server my division select cast(3 as float)/10 is 0.299. > But in postgres select cast(3 as float8)/10 is 0.3. How to get result like > sql server? I believe you can control what precision is used in printing the float results with extra_float_digi

Re: [SQL] Question about update syntaxt

2005-04-29 Thread Stephan Szabo
On Fri, 29 Apr 2005, Michael M Friedel wrote: > I am trying to use an application (Through ODBC) that uses the > following update syntax > > UPDATE MyTable SET MyTable.id=2 WHERE id=1 > > unfortunatly I get an error message > > ERROR: column "mytable" of relation "mytable" does not exist > > Ques

Re: [SQL] "Money" Data Type Problem

2005-04-19 Thread Stephan Szabo
On Tue, 19 Apr 2005, sreejith s wrote: > Hai friends, > I have a field with data type 'Money' with my table. I select this > field a select query and displays the same in a textbox. While doing > this a dollar ($) is prefixed to the actual table value. How to avoid > this symbol so as to display

Re: [SQL] Order of items in FROM causes error?

2005-04-01 Thread Stephan Szabo
On Fri, 1 Apr 2005, Rosser Schwarz wrote: > A colleague has the following query, which errors with: relation "dl" > does not exist. (See the second item in the FROM clause.) If that > item is moved to immediately precede the first JOIN item however, the > query works as expected. > > select u.u

Re: [SQL] Query performance problem

2005-03-18 Thread Stephan Szabo
On Fri, 18 Mar 2005, Kenneth Gonsalves wrote: > On Thursday 17 Mar 2005 7:35 pm, Richard Huxton wrote: > > > Not necessarily. NOT NULL here helps to ensure you can add values > > together without the risk of a null result. There are plenty of > > "amount" columns that should be not-null (total spe

  1   2   3   4   5   6   7   8   >