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] 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] 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] [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] 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] 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] 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] 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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] possible bug with group by?

2000-05-24 Thread Stephan Szabo
> Is this a bug or am I just misunderstanding something? > > playpen=> create table tablea ( a int,b int , c int ); > CREATE > playpen=> insert into tablea(a, b) values (1 ,2); > INSERT 28299 1 > playpen=> insert into tablea(a, b, c) values (2 ,3, 4); > INSERT 28300 1 > playpen=> select a, b, case

Re: [SQL] Problem with subquery in CHECK constraint.

2000-06-08 Thread Stephan Szabo
> CONSTRAINT TYPE_CD_OK CHECK ( > EXISTS (SELECT 1 FROM XREF WHERE > XREF_GROUP = 'CUST_TYPE' AND > XREF_CD = TYPE_CD) > ) > > > > There seems to be more serious problems. > > 1) The constraint is not only for the defined table but also for referenced > > tables in the subquery. > > I don't un

Re: [SQL] Re: Simple search question

2000-06-20 Thread Stephan Szabo
> This brings me back to another unanswered question recently posted up,maybe > it is impossible... > I declared a new table with one of the types as serial (which is really just a > sort of macro I believe, which automates the creation of a few things for your > convenience), which initialises th

Re: [SQL] Finding entries not in table..differnce?

2000-07-10 Thread Stephan Szabo
Assuming that you don't have nulls in prodlang.prodlsku, this should probably work, although I haven't tried it for real. SELECT prodlang.prodlsku FROM prodlang WHERE NOT EXISTS (SELECT * FROM prodlang2 WHERE prodlang2.prodlsku=prodlang.prodlsku); If you do have nulls, the inner select proba

Re: [SQL] Order by in Select

2000-07-19 Thread Stephan Szabo
> What can I add to the above sql statement so that is fetches the > specified id first in a sorted list? > > eg: if $specified_id=5; > I want: 5,5,5,1,2,3,3,4,4,4,6,6,7 > > I could have done it in two different sql statements where one fetches > specified_id and the other fetches and sorts othe

Re: [SQL] Why do I need to set UPDATE permissions for fkey check?

2000-07-21 Thread Stephan Szabo
It's a known problem in the foreign key code. The reason is that the fk triggers use SELECT FOR UPDATE to select the matching rows that it is checking and the reason for using FOR UPDATE is to lock those rows so that someone cannot delete/change them out from under your nose while you're looking

Re: [SQL] copy from

2000-08-15 Thread Stephan Szabo
Well, if you define your main table to have a serial, or an explicit default nextval(seqid), you won't even need to do that. Just leave the column off the insert list and the default should fill it for you. Stephan Szabo [EMAIL PROTECTED] On Tue, 15 Aug 2000, Adam Lang wrote: > I ge

<    3   4   5   6   7   8