Re: [SQL] value from max row in group by

2013-07-25 Thread Marc Mamin
ution with distinct on: select distinct on (stts_id, stts_offset) stts_id, stts_offset+stts_duration from table order by stts_id, stts_offset desc Marc Mamin From: pgsql-sql-ow...@postgresql.org on behalf of Gary Stainburn Sent: Thursday, July 25, 2013 10:

Re: [SQL] delete where not in another table

2013-07-14 Thread Marc Mamin
1.user_id ) regards, Marc Mamin -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] reduce many loosely related rows down to one

2013-05-29 Thread Marc Mamin
lement ); regards, Marc Mamin > -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Torsten Grust > Sent: Dienstag, 28. Mai 2013 17:08 > To: pgsql-sql@postgresql.org > Subject: Re: [SQL] reduce many loosely

Re: [SQL] Advice on re-writing a SELECT query.

2013-05-25 Thread Marc Mamin
n b ON ((a.a,a.b,a.c)<>(b.a,b.b,b.c)) but beware if null values are involved( 1<>NULL => NULL). In this case you can use : select * from a join b ON ((a.a,a.b,a.c) IS DISTINCT FROM (b.a,b.b,b.c)) regards, Marc Mamin

Re: [SQL] reduce many loosely related rows down to one

2013-05-25 Thread Marc Mamin
your "raw" data are as following: id | rspid | nspid | cid | iac | newp | oldp | ppv | tppv +---+---+-+-+--+--+-+- 1 | 2 | 3 | 4 | t | | | | 1 | 2 | 3 | 5 | t | | | | 1 | 2 | 3

Re: [SQL] Prevent double entries ... no simple unique index

2012-07-11 Thread Marc Mamin
same, but requires less space: create unique index on log(state) WHERE state IN (0,1); best regards, Marc Mamin -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] checking for the existence of a current_setting ?

2011-05-03 Thread Marc Mamin
ay to make the check more smoothly, i.e. without relying on the exception ? maybe some undocumented internal function ? many thanks, Marc Mamin CREATE OR REPLACE FUNCTION public.var_get_check(int,text) RETURNS text AS $BODY$ BEGIN return current_setting('publ

Re: [SQL] conditional aggregates

2010-12-08 Thread Marc Mamin
something like ? Select min (case when X > 0 then X end) HTH, Marc Mamin From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Marcin Krawczyk Sent: Mittwoch, 8. Dezember 2010 14:20 To: Pavel Stehule Cc: pgsql-sql@postgresql.org Subject:

[SQL] First aggregate with null support

2010-12-06 Thread Marc Mamin
fault init condition of the aggregate :-( I also have a working one using an array function (first_wnull_a, below) , but I wonder if there is a simpler solution ... best regards, Marc Mamin CREATE OR REPLACE FUNCTION first_element_state(anyarray, anyelement) RETURNS anyarray AS $$ SELECT CASE

Re: [SQL] Overlapping Ranges- Query Alternative

2010-11-12 Thread Marc Mamin
or: Select Groups, generate_series FROM ranges JOIN generate_series(10,50,10) on ( ColumnA < generate_series) ORDER by Groups , generate_series ; regards, Marc Mamin From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Andr

[SQL] Controlling join order with parenthesis

2010-09-09 Thread Marc Mamin
s=2400 width=4) Sort Key: t1.i -> Seq Scan on t1 (cost=0.00..34.00 rows=2400 width=4) best regards, Marc Mamin -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] workaround for missing ROWNUM feature with the help of GUC variables

2010-08-06 Thread Marc Mamin
nately still using 8.3. sorry not to have mentioned that. Marc Mamin

[SQL] workaround for missing ROWNUM feature with the help of GUC variables

2010-08-04 Thread Marc Mamin
Hello, here my two pence on this recurring thema. (just a workaround) regards, Marc Mamin The PG parameter must be set to allow defining own configuration variables

Re: [SQL] record to columns: syntax question and strange behaviour

2009-10-27 Thread Marc Mamin
Hello, Your proposal unfortunately does not work if you try to query more than one value and want additional columns in the results, like in select column1,test(column1) FROM (values(1),(2)) foo cheers, Marc Mamin >IMO easiest would be to include a RETURNS SETOF record in

[SQL] record to columns: syntax question and strange behaviour

2009-10-27 Thread Marc Mamin
lumn1, (test(column1)).* FROM (values(1),(2)) foo => 1,2,3 2,3,4 NOTICE: done: 1 NOTICE: done: 1 NOTICE: done: 2 NOTICE: done: 2 Is there a way to avoid it ??? Thanks, Marc Mamin

Re: [SQL] Ask To Optimize Looping

2009-08-19 Thread Marc Mamin
be used is not readily predictable. Because of this indeterminacy, referencing other tables only within sub-selects is safer, though often harder to read and slower than using a join. " HTH, Marc Mamin

[SQL] select regexp_matches('a a a', '([a-z]) a','g');

2009-05-07 Thread Marc Mamin
ches the first 2 'a', only the trailing ' a' will be used to seek for further matching... Cheers, Marc Mamin -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] aggregation problem: first/last/count(*)

2009-01-26 Thread Marc Mamin
hives/68-More-Aggreg ate-Fun-Whos-on-First-and-Whos-on-Last.html But its is slightly slower as my solution. I'll still make a test with more data As I guess that swapping will grow fatser mith my query than with the first/last aggregate functions. cheers, Marc Mamin -Original

[SQL] aggregation problem: first/last/count(*)

2009-01-26 Thread Marc Mamin
set? This would allow to make a single scan of the table. something like select a_group, first(category) as first_category, last(category) as last_category, ... from test order by a_group,time Many thanks for any hints. Marc Mamin Here are some dummy values if you'd like to play with

Re: [SQL] Query how-to

2008-10-03 Thread Marc Mamin
n 1 else 0 end) as openedCount from Yourtable where status in ('Closed','New') group by case when status ='Closed' then stop_date else start_date end order by adate Marc > Hi, > What about something like that ? > select adate, sum(openedCount) as o

Re: [SQL] Query how-to

2008-10-03 Thread Marc Mamin
osedCount sum(case when status ='New' then 1 else 0 end) as openedCount from Yourtable where status in ('Closed','New') )x group by adate order by adate HTH, Marc

[SQL] varchar::timezone conversion

2008-09-22 Thread Marc Mamin
(varchar,varchar) RETURNS int8 AS $body$ SELECT EXTRACT(EPOCH FROM $1 AT TIME ZONE $2)::int8*1000; $body$ LANGUAGE 'sql' IMMUTABLE RETURNS NULL ON NULL INPUT SECURITY INVOKER; Thanks for your help, Marc Mamin; -- Sent via pgsql-sql mailing list (pgsql-sql@postgres

Re: [SQL] exclude part of result

2008-06-27 Thread Marc Mamin
, p.b, p.c HTH, Marc Mamin -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] dynamic events categorization

2008-06-26 Thread Marc Mamin
ruct and at least part of the tests should happen on indexes only. If the query is run very often, you may want to add a boolean column is_past on show_date, and have a separate job that put the concerned records to true every x minutes ... HTH, Marc Mamin SELECT s.id_event_subtype,

Re: [SQL] SQL stored function inserting and returning data in a row.

2008-01-14 Thread Marc Mamin
> What about > $$ > INSERT INTO ; > select currval('seq_matchmaking_session_id'); > $$ language sql; > > ? Hello, I'm not sure that this would return the correct id in case of concurrent calls to your function. I'm using following kind of functio

Re: [SQL] SQL question: Highest column value of unique column pairs

2008-01-14 Thread Marc Mamin
order by date desc,name regards, Marc Mamin -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kevin Jenkins Sent: Saturday, January 12, 2008 1:10 AM To: pgsql-sql@postgresql.org Subject: [SQL] SQL question: Highest column value of unique column pai

[SQL] slow query - only uses indices

2007-12-24 Thread Marc
Hey Folks, This query is running really slowly. Sometimes much slower then others. I have a feeling that there may be contention on one of the indices it is using. In the explain plan, it looks like it estimates 2 rows but actually finds 228 rows? Is that really bad? Query and explain plan a

Re: [SQL] EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?

2007-09-05 Thread Marc Mamin
, much time is lost in i/o wait) Cheers, Marc ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

[SQL] EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?

2007-09-04 Thread Marc Mamin
0 * 1031 20 1132 21 In the following function, I would like to use a prepared statement for the update command but I get stuck with the tho different meanings of EXECUTE ... Is there a way to achieve this ? Thanks, Marc CREATE OR REPLACE FUNCTION tes

[SQL] a way to generate functions dynamically ?

2007-01-11 Thread Marc Mamin
BEGIN return p2 + ' || p1 || '; END; $BODY$ LANGUAGE ''plpgsql'' VOLATILE '; ERROR: syntax error at or near "BEGIN" SQL state: 42601 Character: 156 Thanks, Marc

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Marc Mamin
://www.omegahat.org/RSPostgres/ This may be a solution to implement complex cross-rows aggregation. But I never got the time to test it; I'd be interested to know which concerns this solution can show (stability, memory & cpu load, concurent requests) Cheers, Marc

Re: [SQL] get_next_billing_date() ...

2006-10-20 Thread Marc G. Fournier
--On Monday, October 16, 2006 09:53:56 -0400 Tom Lane <[EMAIL PROTECTED]> wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: In fact, more info to work with ... it likes the date, just not when I use it as part of a SELECT query of a table ... I suspect it's n

Re: [SQL] Recursive pl/pgsql function ...

2006-10-15 Thread Marc G. Fournier
--On Sunday, October 15, 2006 23:27:34 -0400 Tom Lane <[EMAIL PROTECTED]> wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: More then one Record: # select get_next_billing_date(activated, 12) from company_details; ERROR: control reached end of function without RET

[SQL] Recursive pl/pgsql function ...

2006-10-15 Thread Marc G. Fournier
12) from company_details; ERROR: control reached end of function without RETURN CONTEXT: PL/pgSQL function "get_next_billing_date" Something I've written wrong in the function, or just not something that is doable? Thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.h

[SQL] Way to reverse ordering of an IP ... ?

2006-09-05 Thread Marc G. Fournier
ight allow this, but can't seem to figure out a proper format for it ;( If I have to write a function to do it, fine ... just wanted to make sure I wasn't missing something first ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Emai

Re: [SQL] DBD::Pg ... how would I format this prepare?

2006-07-26 Thread Marc G. Fournier
On Wed, 26 Jul 2006, Jim Buttafuoco wrote: try now() + (? || ' day')::interval Perfect ... had thought of that, but put my ) after ::interval instead of before ;( Thx ... -- Original Message --- From: "Marc G. Fournier" <[EMAIL PROTECTED]> To

[SQL] DBD::Pg ... how would I format this prepare?

2006-07-26 Thread Marc G. Fournier
I need to do: NOW() + '2 day'::interval where 2 is a variable ... if I do: NOW() + '? day'::interval it, of course, takes the ? as a literal ... so is there some way I can do this such that I can do the placeholder? Thx Marc G. Fournier Hub.Org Netwo

Re: [SQL] timestamp query doesn't use an index ...

2006-05-21 Thread Marc G. Fournier
On Sun, 21 May 2006, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: I'm trying to figure out some way to speed up the following query: select ps2.page_id, ps2.template_component_id, max(ps2.start_time) from page_schedule ps2 where ps2.st

Re: [SQL] timestamp query doesn't use an index ...

2006-05-20 Thread Marc G. Fournier
On Sun, 21 May 2006, Michael Glaesemann wrote: On May 21, 2006, at 10:42 , Marc G. Fournier wrote: -> Seq Scan on page_schedule ps2 (cost=0.00..2364.95 rows=33110 width=16) (actual time=0.021..623.363 rows=94798 loops=1) I don't know about rewriting the query, but it appe

[SQL] timestamp query doesn't use an index ...

2006-05-20 Thread Marc G. Fournier
<= to just =, the index is used, but that is expected ... Is there some other way I can either write above query *or* do an index, such that it will use the index? thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email . [EMAIL PROTECTE

[SQL] Ignore, test of an alias

2006-04-29 Thread Marc G. Fournier
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664 ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your

Re: [SQL] Reverse Index ... how to ...

2006-04-05 Thread Marc G. Fournier
On Wed, 5 Apr 2006, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: I'm still searching through Google and whatnot, but not finding anything off the bat ... is there some way of creating a 'REVERSE INDEX' on a column in a table? For instance,

[SQL] Reverse Index ... how to ...

2006-04-05 Thread Marc G. Fournier
verse order, so would need the INDEX to go from 'GREATEST to LOWEST', vs 'LOWEST to GREATEST' ... Thx Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 761

[SQL] Update counter when row SELECT'd ... ?

2006-03-20 Thread Marc G. Fournier
27;ve checked CREATE TRIGGER, and that doesn't work 'ON SELECT' ... is there anything that I *can* do, other then fire back an UPDATE based on the records I've received? Thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL P

Re: [SQL] FOREIGN KEYs ... I think ...

2006-01-05 Thread Marc G. Fournier
was havin gto figure out the 'active remark record' doing a 'max(create_time)' ... On Wed, 4 Jan 2006, Marc G. Fournier wrote: I'm not sure if I'm looking at (for) the right thing or not, but if I am, then I'm not finding any useful examples :( I

Re: [SQL] FOREIGN KEYs ... I think ...

2006-01-04 Thread Marc G. Fournier
On Wed, 4 Jan 2006, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: Now, what I want to do is add a FOREIGN KEY (again, I think) that when incident_summary.status is changed (either closed, or reopened), the associated records in incident_comments are changed t

[SQL] FOREIGN KEYs ... I think ...

2006-01-04 Thread Marc G. Fournier
ld I be searching on / reading for this one? Pointers preferred, especially one with some good examples :) Thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664 --

[SQL] # of 5 minute intervals in period of time ...

2005-12-13 Thread Marc G. Fournier
Is there a simpler way of doing this then: select (date_part('epoch', now()) - date_part('epoch', now() - '30 days'::interval)) / ( 5 * 60 ); Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECT

Re: [SQL] pl/* overhead ...

2005-10-26 Thread Marc G. Fournier
On Wed, 26 Oct 2005, Michael Fuhr wrote: On Wed, Oct 26, 2005 at 12:58:13AM -0300, Marc G. Fournier wrote: Does anyone know of, or have, any comparisions of the overhead going with something like pl/perl or pl/php vs using pl/pgsql? Benchmark results will probably depend on the type of

[SQL] pl/* overhead ...

2005-10-25 Thread Marc G. Fournier
Does anyone know of, or have, any comparisions of the overhead going with something like pl/perl or pl/php vs using pl/pgsql? Thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ

[SQL] padding an integer ...

2005-10-25 Thread Marc G. Fournier
ble to find, I suspect I'm not going to have much of a choice ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664 ---(end of broadcast)---

Re: [SQL] convert timezone to string ...

2005-10-25 Thread Marc G. Fournier
On Tue, 25 Oct 2005, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: I know that the server knows that ADT == -0400, and AST == -0300 ... Other way around isn't it? Unless Canada observes a pretty strange variety of daylight saving time ;-) I knew I

[SQL] convert timezone to string ...

2005-10-24 Thread Marc G. Fournier
I know that the server knows that ADT == -0400, and AST == -0300 ... is there any way of reversing that? Basically, I want to say: SELECT timezone_str(-0400, 'not dst'); and have it return ADT ... I've got a method of doing it right now, using a function, but just find it looks so messy, ju

[SQL] a "catch all" type ... such a thing?

2005-09-08 Thread Marc G. Fournier
Are there any data types that can hold pretty much any type of character? UTF-16 isn't supported (or its missing from teh docs), and UTF-8 doesn't appear to have a big enough range ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL

[SQL] Last access date for databases/users

2005-09-01 Thread Marc McIntyre
Is there anyway to determine when a database was last accessed, or when a user last connected to the database using the pg_* views? I'm trying to determine what databases in my system are currently active. ---(end of broadcast)--- TIP 9: In vers

Re: [SQL] [HACKERS] ALTER TABLE ( smallinto -> boolean ) ...

2005-09-01 Thread Marc G. Fournier
Moved off of -hackers, since its long gotten out of that realm :) On Thu, 1 Sep 2005, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: On Mon, 29 Aug 2005, Tom Lane wrote: No, because there's no built-in cast from smallint to bool. 'k, I just took

[SQL] PL/SQL Function: self-contained transaction?

2005-08-22 Thread Marc G. Fournier
de of it) are considered one transaction, can you do a begin/end within the function itself to 'force' commit on a specific part of the function? Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy

[SQL] pl/PgSQL: Samples doing UPDATEs ...

2005-08-18 Thread Marc G. Fournier
ld be great) online? Thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664 ---(end of broadcast)--- TIP 6: explain analyze is your friend

[SQL] ARRAYs and INDEXes ...

2005-08-15 Thread Marc G. Fournier
)[12] ); Is it possible to create an INDEX on customers.monthly_balance such that I could do something like: SELECT * FROM customers WHERE monthly_balance[6] = 0.00; As an example ... or SELECT * FROM customers WHERE 0.00 = any (monthly_balance); Marc G. Fournier Hub.Org Netw

[SQL] using 'zoneinfo' to manipulate dates ...

2005-06-25 Thread Marc G. Fournier
id = table.timezone )) = '2004-12-12'; Something like this, but that works: # select ( now() || ' ' || 'PST8PDT' )::timestamp; ERROR: invalid input syntax for type timestamp: "2005-06-26 00:23:29.789703-03 PST8PDT" Marc G. Fournier Hu

Re: [SQL] Returning a Cross Tab record set from a function

2005-06-18 Thread Marc Wrubleski
d like to have a function defined at the database level. Many Thanks, Marc Wrubleski On Mon, 2005-06-06 at 12:20 +0200, KÖPFERL Robert wrote: |-Original Message- |From: Marc Wrubleski [mailto:[EMAIL PROTECTED]] |Sent: Mittwoch, 01. Juni 2005 16:15 |To: pgsql-sql@postgresql.org |Subject

Re: [SQL] Putting an INDEX on a boolean field?

2005-06-16 Thread Marc G. Fournier
On Fri, 17 Jun 2005, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: Does that make sense? Would it ever get used? It could get used if one of the two values is far less frequent than the other. Personally I'd think about a partial index instead ... H

[SQL] Putting an INDEX on a boolean field?

2005-06-16 Thread Marc G. Fournier
Does that make sense? Would it ever get used? I can't see it, but figured I'd ask ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664 ---(end of

[SQL] UPDATEABLE VIEWS ... Examples?

2005-06-16 Thread Marc G. Fournier
Reading through the docs, both the CREATE VIEW and CREATE RULE pages refer to how you can use a RULE to 'simulate' an updateable VIEW ... but I can't seem to find any examples of this ... Does anyone know of an online example of doing this that I can read through? Thanks .

[SQL] Returning a Cross Tab record set from a function

2005-06-05 Thread Marc Wrubleski
igher level language, but it drives me crazy that I can't perform this operation as a function inside of Postgres... Thanks for any thoughts you might have... -- Marc Wrubleski ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

[SQL] Major flood of mail to lists ...

2005-05-31 Thread Marc G. Fournier
Do to moderator error (namely, mine), several hundred messages (spread across all the lists) were just approved ... Sorry for all the incoming junk :( Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy

[SQL] Order of columns in a table important in a stored procedure?

2005-02-13 Thread Marc SCHAEFER
Hi, I use a FOR one_row IN loop where one_row is of type saisies%ROWTYPE. The loop does a SELECT on a table, bennes, changing a few values. The idea is that the function should return some bennes rows, but with additional information, which makes the returned rows a saisies table-like row set. I

Re: [SQL] PL/PgSQL - returning multiple columns ...

2005-02-03 Thread Marc G. Fournier
Perfect, worked like a charm ... but the RETURNS still needs to be a SETOF, other then that, I'm 'away to the races' ... thanks :) On Wed, 2 Feb 2005, George Weaver wrote: Hi Marc, One option is to create a simple data type and return the rowtype of the datatype eg CREATE TYPE

[SQL] PL/PgSQL - returning multiple columns ...

2005-02-02 Thread Marc G. Fournier
two fields of a table, or, in the case of the above, one column and oen 'group by' column? thanks ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED] Yahoo!: yscrappy ICQ: 7615664

[SQL] Easier way to 'strip' on multiple matches?

2005-01-09 Thread Marc G. Fournier
I need to strip out all spaces, and all \' from a string ... is there an easier way then doing: select lower(replace(replace(name, ' ', ''), '\\\'', '')) from business; Thanks ... Marc G. Fournier Hub.Org Networking Ser

[SQL] INSERT INTO VIEW - Replacement

2004-11-09 Thread marc ratun
,'c2'); (here a row in "a" with aval 'a1' should not be created but referenced.) (Same for "b"). "Insert into view" would't work, how could I do my INSERTS efficiently in postgres without having eache time an extra query which asks whether th

Re: [SQL] How do FKs work?

2004-10-09 Thread Marc G. Fournier
On thing I failed to note here, that is probably critical ... its a 7.3 database ... On Sat, 9 Oct 2004, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: Have a table with two FKs on it ... 2 different fields in the table point to the same field in another table .

Re: [SQL] How do FKs work?

2004-10-09 Thread Marc G. Fournier
On Sat, 9 Oct 2004, Tom Lane wrote: "Marc G. Fournier" <[EMAIL PROTECTED]> writes: Have a table with two FKs on it ... 2 different fields in the table point to the same field in another table ... When I do an 'EXPLAIN ANALYZE DELETE FROM table WHERE field = #;', it n

[SQL] How do FKs work?

2004-10-09 Thread Marc G. Fournier
le, to make sure it exists ... Is this correct? So, its effectively having to do 3278 "SELECTS" against the REFERENCED table? (two fields have contraints on them, 1639 rows to be deleted) ... ? Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) E

Re: [SQL] Ok, what am I doing wrong here?

2004-06-03 Thread Marc G. Fournier
; is invalid > inside the values part of the definition. > > SQL's language specification says otherwise, as does "\h insert" from the > command line. > > The query stand-alone returns a table with values that are valid for the > table I wish to insert into. > > Wh

[SQL] Skip dups on INSERT instead of generating an error ...

2003-12-12 Thread Marc G. Fournier
that it just skips over those records. First thought would be to write a quite plpgsql function that would do a SELECT first, to see if the value already exists, and if not, then do the INSERT ... but am wondering if maybe there is a cleaner way that I'm not thinking of? Marc G

Re: [SQL] simple LEFT JOIN giving wrong results ...

2003-12-11 Thread Marc G. Fournier
On Thu, 11 Dec 2003, Tom Lane wrote: > "Marc G. Fournier" <[EMAIL PROTECTED]> writes: > > So, I'm doing my LEFT JOIN wrong *somehow*, but its eluding me as to > > what/how .. :( > > > ams=# select ct.ip_id, sum(ct.bytes) as traffic, >

[SQL] simple LEFT JOIN giving wrong results ...

2003-12-11 Thread Marc G. Fournier
16900355 1088 | 246166684 1227 | 44816947957 1179 | 3867502285 (8 rows) the storage/avg values come out right in the JOIN, but the traffic/sum values get royally screwed ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED]

Re: [SQL] [ADMIN] Field Size

2003-12-09 Thread Marc A. Leith
If you define the field as CHAR, 1000 bytes will be consumed. If you define the field as VARCHAR, on sufficient bytes to store the contents will be used. Marc --Original Message Text--- From: Ganesan Kanavathy Date: Mon, 8 Dec 2003 20:56:06 +0800 Clean Clean DocumentEmail

Re: [SQL] off subject - pg web hosting

2003-11-08 Thread Marc G. Fournier
http://www.hub.org http://www.pghoster.com http://www.commandprompt.com On Thu, 6 Nov 2003, chester c young wrote: > can anybody recomend web hosting that provides postgresql? I have > found a couple, but their pricing is several times the going rate using mySql. > > ___

[SQL] removing precision from timestamp (microseconds) ..

2003-10-14 Thread Marc G. Fournier
>From the docs, if you do: traffic=# select CURRENT_TIMESTAMP(0); timestamptz 2003-10-13 11:04:09-03 (1 row) the 0 reduces the precision of the time to get rid of the microseconds ... is there a way of having this done by default on, if anything, a per connection

[SQL] Testing gateway

2003-08-14 Thread Marc G. Fournier
In theory, the news2mail gateway is back in place ... ---(end of broadcast)--- TIP 8: explain analyze is your friend

[SQL] retrieving specific info. from one column and locating it in another

2002-11-26 Thread MARC BEDOIS
tewith info in it similar to 'UPS NS Ground' How do I create a second column called 'Delivery' and pull only the 'NS' out of the Route column and put it into the 'Reciever' column? Similarly how woul

[SQL] pgsql-performance mailing list / newsgroup created

2002-09-09 Thread Marc G. Fournier
Morning all ... Josh Berkus the other day shook my cage a bit and reminded me to create the -performance list that had been discussed awhile back ... so I did :) [EMAIL PROTECTED] or comp.databases.postgresql.performance archives wont' show it up yet,

Re: [SQL] slowing down too fast - why ?

2002-08-11 Thread Marc Spitzer
select speed, it does other stuff. Try something like this: echo 'select now() ; select count(*) from yourtable; select now()'|psql dbname to try to localize the problem. good luck marc > On Sun, 11 Aug 2002 [EMAIL PROTECTED] wrote: > > > > > and I forgot to me

Re: [SQL] Triggers for inserting on VIEWS

2002-08-03 Thread Marc SCHAEFER
On Sat, 3 Aug 2002, Marc SCHAEFER wrote: > is there any replacement so that inserting somewhere acts on multiple > tables ? Thanks for the suggestion to use RULES. My solution (comments welcome): DROP RULE r_entree_rapide_ecriture_insert; DROP FUNCTION f_entree_rapide_ecriture_inser

[SQL] Triggers for inserting on VIEWS

2002-08-03 Thread Marc SCHAEFER
Hi, at least with PostgreSQL 7.1 it was possible to create a trigger on a view. 7.2 seems to fail with: psql:t:25: ERROR: CreateTrigger: relation "egg_view" is not a table is there any replacement so that inserting somewhere acts on multiple tables ? Thank you. Code reference: (stupid, re

Re: [SQL] 1 milion data insertion

2002-07-26 Thread Marc Spitzer
zakal$ > zakal$ DEBUG: recycled transaction log file 0001 > -- > > the log has overflowed. > > Ok, this was a test. I'd like to know what would be happen. > But,

[SQL] convert a bigint into a timestamp

2002-07-24 Thread marc sturm
Hello, Does anyone know how to convert a bigint into a date or timestamp in a SQL query. Thanks a lot. Marc __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com ---(end of broadcast

Re: [SQL] Editor for pgsql

2002-07-22 Thread Marc Spitzer
gt; > - James James, That sounds very ugly, I will usually have 1-4 files per db. Either everything goes into 1 file, drops at the front then creates. Or 2 files, 1 for ddl( create/drop table) and another for plpgsql procedures and triggers. Sometimes I will split each of those i

Re: [SQL] XML to Postgres conversion

2002-07-12 Thread Marc Spitzer
there is middleware available to perform this, but am having some > > difficulty in finding the actual applications. I am trying to stay > > with open source applications, if possible. Can anyone give me any > > suggestions or resources to pull from? > > > >

Re: [SQL] Slow SELECT -> Growing Database

2002-06-27 Thread Marc Spitzer
if I remember correctly update is handled by inserting a new row and deleteing the old row. So it looks like 540,000 index entries changed per day. good luck marc > I've two other ones, that were mentioned in my previous emails, that > have 12.000 records each, and: > - insert 48 re

Re: [SQL] Index of a table is not used (in any case)

2001-10-23 Thread Marc Spitzer
pecial thing I do is every few days I reindex the table involved to reclame the space burned by the indexes not reclaiming space on deletion of rows. What other good and useful things could I do? Thanks marc > > -Josh > > __AGLIO DATABASE SOLUTIONS_

[SQL] 2 tables, joins and same name...

2001-08-31 Thread Marc André Paquin
dest.dest_name, air.name as airport1, air.name as airport2 from destination, airport air where dest.airport_dep_id_id=air.airport_id and dest.airport_arr_id=air.airport_id; This is not good... Any help? Thanks! -- Marc Andre Paquin ---(end of broadcast

[SQL] List archives moved and cleaned up ...

2001-08-28 Thread Marc G. Fournier
Finally figuring that enough is enough, I've been spending the past few days working on the list archives ... I've reformatted, so far, the following lists into a cleaner format: pgsql-hackers pgsql-sql pgsql-bugs pgsql-general pgadmin-hackers pga

RE: [SQL] Select most recent record?

2001-06-21 Thread Marc Sherman
From: Mark Hamby [mailto:[EMAIL PROTECTED]] > > Marc, > Did you ever get your problem solved to your satisfaction? > We have a very simular problem with a historical database > containing typically 5K id and updates to data every few > seconds. We tried unsuccessfully to optim

RE: [SQL] Select most recent record?

2001-05-16 Thread Marc Sherman
From: Tom Lane [mailto:[EMAIL PROTECTED]] > > "Marc Sherman" <[EMAIL PROTECTED]> writes: > > I'd like to select the newest (max(timestamp)) row for each id, > > before a given cutoff date; is this possible? > > select * from log order by timestamp d

[SQL] Select most recent record?

2001-05-16 Thread Marc Sherman
y id); There must be a better way to do this; any tips? Thanks, - Marc ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] Problem using IP functions

2001-05-12 Thread Marc Lamothe
ing everything to type text, but that didn't do the trick. ipdb=> select texteq(host('216.46.13.0/24')::text, '216.46.13.0'::text); texteq f (1 row) Any insight would be greatly appreciated. Marc ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://www.postgresql.org/search.mpl

[SQL] a tricky one

2001-02-24 Thread Olaf Marc Zanger
re-clause. what's wrong can anybody help, this goes over my know-how :-) happy weekend and thanks for the great help lately from the list olaf -- soli-con Engineering Zanger, Dipl.-Ing. (FH) Olaf Marc Zanger Lorrainestrasse 23, 3013 Bern / Switzerland fon:+41-31-332 9782, mob:+41-76-572 9782 mailto:[EMAIL PROTECTED], http://www.soli-con.com

  1   2   >