Re: [SQL] need some magic with generate_series()

2013-01-22 Thread Filip Rembiałkowski
or even select m from generate_series( '20121101'::date, '20130101'::date, '1 month'::interval) m; On Tue, Jan 22, 2013 at 3:49 PM, jan zimmek wrote: > hi andreas, > > this might give you an idea how to generate series of dates (or other > datatypes): > > select g, (current_date + (g||' month

Re: [SQL] How to convert SQL store procedure to Postgresql function

2012-02-28 Thread Filip Rembiałkowski
On Tue, Feb 28, 2012 at 9:50 AM, Rehan Saleem wrote: > hi , > how can i convert this sql store procedure to postgresql function , i shall > be very thankful to you, as i am new to postgresql and i dont know how to > handle this kind of store procedure in postgresql Most people handle this with u

Re: [SQL] How to split up phone numbers?

2012-02-20 Thread Filip Rembiałkowski
At 2012-02-20 15:50, Andreas wrote: Hi, is there a way to split up phone numbers? I know that's a tricky topic and it depends on the national phone number format. I'm especially interested in a solution for Germany, Swizerland and Austria. I've got everything in a phone number column that mak

Re: [SQL] Wrong query plan when using a left outer join

2012-01-17 Thread Filip Rembiałkowski
On Tue, Jan 17, 2012 at 7:54 AM, Feike Steenbergen wrote: > I have the following setup: > > A table called hand: > > >                                        Table "stage.hand_meta" >    Column     |           Type           | > Modifiers > ---+--+--

Re: [SQL] Call a external app on postgreSQL start-up (windows)

2011-12-27 Thread Filip Rembiałkowski
2011/12/27 Maurício Cruz : > > I need to execute it after the postgreSQL started service. OK, so the method I described should be good for you. The script could be put in Task Scheduler every 15 minutes, or minimal delay that is acceptable. It can be written in windos batch language, or Perl, or P

Re: [SQL] Call a external app on postgreSQL start-up (windows)

2011-12-27 Thread Filip Rembiałkowski
2011/12/27 Maurício Cruz : > Hi all, > > I need to execute some rotines on windows every time that postgreSQL is > start at the server machine, before it's started or just after it's started? > I was thinking to create a PL/PGSQL to call this executable, or something > like... there are no trigg

Re: [SQL] Natural sort order

2011-12-17 Thread Filip Rembiałkowski
If you use btrsort(column) from the example, you can just create a functional index on this expression. CREATE INDEX mytable_column_btrsort_idx ON mytable( btrsort(column) ); this can help. 2011/12/17 Richard Klingler : > Morning... > > What is the fastest way to achieve natural ordering fro

Re: [SQL] plpgsql: how to get the exception's detail information?

2011-12-01 Thread Filip Rembiałkowski
2011/11/29 Muiz : >    I write a function to execute a sql string. E.g. "update tableA set > field1='abc' where name='123'; deletee from tableB where id=333;" >    The following is my function: > ---

Re: [SQL] handling duplicate row exception

2011-09-26 Thread Filip Rembiałkowski
W dniu 22 września 2011 08:11 użytkownik Amar Dhole napisał: > ** > > Hi Filip, > > ** ** > > No not sure 100% when this can happen. This approach will not be possible > as in our application we are programmatically handling these cases and going > in other route to add the record with increas

Re: [SQL] a spatial table's bounding box

2011-09-23 Thread Filip Rembiałkowski
2011/9/22 Asli Akarsakarya > > I want to get the extensions of spatial table. Say that there is a spatial > table named 'roads', and a some road geometry inside. I want to fetch the > bounding box (envelope or extension) for that table, that means for all the > roads that it has. > > Accordin

Re: [SQL] help with xpath namespace

2011-09-23 Thread Filip Rembiałkowski
2011/9/22 Brian Sherwood > > select (xpath('/chassis-inventory/chassis/serial-number/text()', >data_xml, >ARRAY[ARRAY['junos', > 'http://xml.juniper.net/junos/9.6R4/junos-chassis']] > )) from xml_test; > > Can anyone suggest how I would go about getting the serial-number wit

Re: [SQL] handling duplicate row exception

2011-09-21 Thread Filip Rembiałkowski
Hi There is no IGNORE_DUP_KEY equivalent in PostgreSQL. If you are 100% sure that you want to ignore unique key violations, you can wrap your INSERT code in PL/PgSQL block and handle the exception yourself. I mean: DO $$ BEGIN INSERT INTO foo (bar,baz) SELECT 42, 666; EXCEPTION WHEN unique_vio

Re: [SQL] loosing data in postgres database

2011-01-24 Thread Filip Rembiałkowski
2011/1/24 victor katemana : > hi everyone, i have a problem of loosing data in my postgres database > whenever i restart my machine what could be the possible problem help me > out? can you please adjust your question to this http://wiki.postgresql.org/wiki/Guide_to_reporting_problems How exactl

Re: [SQL] help needs in converting db2 function in postgresql.

2011-01-11 Thread Filip Rembiałkowski
2011/1/11 Amar Dhole > Hi, > I need helping converting following db2 function in postgresql function. > Any pointer will be great help in proceeding me ahead. > > CREATE FUNCTION in_liststring ( string CLOB(64K) ) > RETURNS TABLE ( ordinal INTEGER, index INTEGER ) > LANGUAGE SQL > DETERMINI

Re: [SQL] Translate Function PL/pgSQL to SQL92

2010-12-16 Thread Filip Rembiałkowski
2010/12/16 serviciotdf > Hello, > > I have a Function in PL/pgSQL and I need to translate it to SQL92, but I'm > stuck. > > ### > CREATE OR REPLACE FUNCTION pruebas(varchar, varchar, integer) > RETURNS SETOF personal AS > $delimiter$ > BEGIN > PERFORM id from documentos WHERE descripcion = $1; >

Re: [SQL] Aggregating by unique values

2010-12-14 Thread Filip Rembiałkowski
try select zip, count(distinct id) from customer_service_date group by zip; 2010/12/14 Lee Hachadoorian > Hello, > > I'm trying to count customers who have received services by ZIP code, > but I want to count each customer only once even though customers may > have received services on multiple

Re: [SQL] Sorting router interfaces

2010-11-01 Thread Filip Rembiałkowski
| 0/1 | {0,1} eth0/10 | eth | 0/10 | {0,10} eth1 | eth | 1 | {1} GigabitEthernet1/0/2 | GigabitEthernet | 1/0/2| {1,0,2} GigabitEthernet1/0/20 | GigabitEthernet | 1/0/20 | {1,0,20} irb.

Re: [SQL] help

2010-05-07 Thread Filip Rembiałkowski
ntheses. > > that is > 1 > 2 > 3 > > > Thank You > Nicholas I > > -- Filip Rembiałkowski JID,mailto:filip.rembialkow...@gmail.com http://filip.rembialkowski.net/ -- 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] How to cascade information like the user roles ?

2010-01-19 Thread Filip Rembiałkowski
_has_option opt join role_inherits_role inh on inh.parent_role_fk = opt.role_fk where inh.child_role_fk = 2 ? > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > -- Filip Rembiałkowski JID,mailto:filip.rembialkow...@gmail.com http://filip.rembialkowski.net/

Re: [SQL] short-cutting if sum()>constant

2009-12-22 Thread Filip Rembiałkowski
With plain SQL, no. With a user defined function in PL/PgSQL, yes. > > > -- > Ivan Sergio Borgonovo > http://www.webthatworks.it > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.post

Re: [SQL] get distinct + group by then filter

2009-12-18 Thread Filip Rembiałkowski
+ interval '1 > days') > order by esid, track_time >) > and th.aid='someaid' > and th.track_time between > ('2009-12-01'::timestamp) >and > ('2009-12-01'::timestamp + interval '1 months

Re: [SQL] Client-side compression

2009-06-24 Thread Filip Rembiałkowski
ecompress(compressed_data) LIKE 'whatever' ??? of course it will be a great penalty. I assume we're pretty much on our own to prevent such actions (i.e. the app > can never query against this column via sql). certainly. -- Filip Rembiałkowski JID,mailto:filip.rembialkow...@gmail.com http://filip.rembialkowski.net/

Re: [SQL] Extract week from date

2009-05-18 Thread Filip Rembiałkowski
u want. why not just something like SELECT EXTRACT( week from statistics_date ) as week, SUM( total_duration) as total_duration_sum FROM statistics_daily GROUP BY 1; ? -- Filip Rembiałkowski JID,mailto:filip.rembialkow...@gmail.com http://filip.rembialkowski.net/

Re: [SQL] Collapsing (select) row values into single text field.

2008-12-10 Thread Filip Rembiałkowski
EGATE syntax, maybe you need something fancy here ); -- and finally: SELECT location, min(lowest_temp) as lowest_overall_temp, agg_varbit_concat(location_bit_data) as overall_location_bit_data FROM temp; -- Filip Rembiałkowski

Re: [SQL] psql: FATAL: Ident authentication failed for user "postgres"

2008-09-08 Thread Filip Rembiałkowski
:36 PG_VERSION > drwx-- 3 postgres postgres 4096 2008-09-06 00:36 pg_xlog > -rw--- 1 postgres postgres 15336 2008-09-06 00:36 postgresql.conf > -rw--- 1 postgres postgres49 2008-09-08 21:44 postmaster.opts > -rw--- 1 postgres postgres46 2008-09-08 21:44 postmaster.pid

Re: [SQL] Check a column value not in Array.

2008-08-14 Thread Filip Rembiałkowski
2']; > select * from test where test.col <> ALL ( ARRAY['val1', 'val2'] ); see http://www.postgresql.org/docs/current/static/functions-comparisons.html be careful with NULLs in this type of comparisons. -- Filip Rembiałkowski -- Sent via pgsql-sql

Re: [SQL] transaction and triggers

2008-01-18 Thread Filip Rembiałkowski
lation on remote databases, you have no problem. Any changes made to remote databases, for example if you call some dblink functions, are not transactional, and will not be rolled back. In this case you have to rethink your design, as there is no "ON COMMIT" trigger (yet?)

Re: [SQL] ERROR: failed to re-find parent key in "pk_ep07"

2007-10-25 Thread Filip Rembiałkowski
erver - replace binaries - start servar ) Detrailed upgrade procedures are described either in manual or somewhere on the net. cheers -- Filip Rembiałkowski ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire t

Re: [SQL] Finding broken regex'es

2007-10-03 Thread Filip Rembiałkowski
2007/10/3, Dawid Kuroczko <[EMAIL PROTECTED]>: > CREATE TABLE rx_check ( > rx text CHECK ('' ~ rx IN ('t','f')) > ); wow. This is beautiful :) ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] How pull

2007-09-23 Thread Filip Rembiałkowski
); create aggregate first ( numeric ) ( SFUNC = first, STYPE = numeric ); select rating_group(rating), count(*) as num_ratings, first(item_id) as best_rated_item_id, first(rating) as best_rating from ( select * from rating order by rating desc ) ordered_ratings group by rating_group order by rating_group desc; note: if you can, get rid of null ratings. what are they supposed to mean? they make things a bit more complicated. -- Filip Rembiałkowski ---(end of broadcast)--- TIP 6: explain analyze is your friend