Re: [GENERAL] numeric to ipv6 inet

2013-08-23 Thread Osvaldo Kussama
2013/8/23, Mikhail Puzanov : > Hello, > > I need to convert the set of ipv6 addresses stored as numerics > (by historical reasons mostly) to inet type. > > Something like > '0:0:0:0:0:0:0:0'::inet + 55831599345971591062080247067748335616::bigint > apparently doesn't work as the number added is too

Re: [GENERAL] Query to return every 1st Sat of a month between two dates

2011-05-16 Thread Osvaldo Kussama
2011/5/11 Alex - : > Hi, > is there an easy way to return the date of every first Saturday of a month > in a data range i.e. 2011-2013 > Any help would be appreciated > Thanks > Alex Try: SELECT s.a::date+(6-(extract(dow from s.a)::int%7)) FROM generate_series(to_date('2011',''),to_date('2012

Re: [GENERAL] Website code Pl/pgsql

2011-02-26 Thread Osvaldo Kussama
2011/2/26, franco egizii : > Hello, > do you know some website about Pl/pgsql stored procedure , function and > other resource (example, code ecc.) ? > regards and thanks > Frank > Like this? http://www.postgres.cz/index.php/PL/pgSQL_%28en%29 http://wiki.postgresql.org/wiki/Category:Snippets Osv

Re: [GENERAL] How to determine server version inside select statement

2010-10-31 Thread Osvaldo Kussama
2010/10/31 Andrus : > I tried > > SELECT (SHOW server_version) AS Contents > > but got > > ERROR:  syntax error at or near "server_version" at character 14 > > > how to get server version inside select statement ? > SELECT current_setting('server_version') AS Contents; Osvaldo -- Sent via pgsq

Re: [GENERAL] How to search ignoring spaces and minus signs

2010-10-14 Thread Osvaldo Kussama
2010/10/13 Andrus : > CHAR(20) columns in 8.4 database may contains spaces and - signs like > > 13-333-333 > 12 3-44 > 33 33 333 > 12345 > > User enters code to search without spaces and - signs, like 12344 > How to search for product code ignoring spaces and - signs? > > For example searching for

Re: [GENERAL] How to import *.sql file to postgresql database

2010-07-18 Thread Osvaldo Kussama
2010/7/18 Andre Lopes : > If I do this command gives me the same error: > > [quote] > ERROR:  invalid byte sequence for encoding "UTF8": 0xff > HINT:  This error can also happen if the byte sequence does not match the > encoding expected by the server, which is controlled by "client_encoding". > [/

Re: [GENERAL] How to import *.sql file to postgresql database

2010-07-18 Thread Osvaldo Kussama
2010/7/18 Andre Lopes : > Hi, > > I have a DUMP file with INSERT's commands. I need to import this data to > postgresql database with the "psql" command. > > How can I do this task? > > Best Regards, > >From manual [1] 24.1.1. Restoring the dump: psql dbname < infile Osvaldo [1] http://www.post

Re: [GENERAL] ERROR: character 0x90 of encoding "WIN1252" has no equivalent in "UTF8"

2010-06-05 Thread Osvaldo Kussama
2010/6/4 Wang, Mary Y : > Hi, > > I'm getting this error from postgres " ERROR:  character 0x90 of encoding > "WIN1252" has no equivalent in "UTF8"  " and from a dump file when I tried to > use psql command to restore the dump. > > I have SET client_encoding = 'win1252' in the dump file. > > Any

Re: [GENERAL] timestamp configuration

2010-05-24 Thread Osvaldo Kussama
2010/5/25 Dennis Gearon : > is there anyway with a running instance of postgres to find out if it was > compiled with: > >   BIGINT > vs >   DOUBLE PRECISION > > timestamps? > SHOW INTEGER_DATETIMES; Osvaldo -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes

Re: [GENERAL] regexp_replace puzzle

2010-03-10 Thread Osvaldo Kussama
2010/3/10 Harald Fuchs : > I've got a problem with regexp_replace which I could reduce to the following: > >  CREATE FUNCTION digest(text, text) RETURNS bytea >      LANGUAGE c IMMUTABLE STRICT >      AS '$libdir/pgcrypto', 'pg_digest'; > >  CREATE FUNCTION sha224enc(text) RETURNS text AS $$ >  BEG

Re: [GENERAL] regexp_replace: LF, CR, or tab

2010-02-27 Thread Osvaldo Kussama
2010/2/27 : > Hi! > > I am trying to replace characters '\r', '\n', or '\t' with space character ' > '. As an example, I want string "A\t\n\rB" becomes "AB".  The following > statement seems to be not working. What mistake have I made? > > TIA > > CN > > > select regexp_replace(E'A\r\n\

Re: [GENERAL] cross-database time extract?

2009-12-29 Thread Osvaldo Kussama
2009/12/29 Adrian Klaver : > On Tuesday 29 December 2009 5:01:03 am Osvaldo Kussama wrote: >> 2009/12/24 Israel Brewster : >> > This is sort of a PostgreSQL question/sort of a general SQL question, so >> > I apologize if this isn't the best place to ask. At any rat

Re: [GENERAL] cross-database time extract?

2009-12-29 Thread Osvaldo Kussama
2009/12/24 Israel Brewster : > This is sort of a PostgreSQL question/sort of a general SQL question, so I > apologize if this isn't the best place to ask. At any rate, I know in > PostgreSQL you can issue a command like 'SELECT "time"(timestamp_column) > from table_name' to get the time part of a t

Re: [GENERAL] Converting each item in array to a query result row

2009-05-29 Thread Osvaldo Kussama
2009/5/29 Grzegorz Jaśkiewicz : > 2009/5/29 Adam Ruth : >> Always test your performance assumptions. The plpgsql function is faster >> than the sql function, a lot faster on smaller arrays. >> >> unnest - 10 element array - 100,000 times: 6701.746 ms >> unnest - 100 element array - 100,000 times: 1

Re: [GENERAL] How to pass parameters into a sql script ?

2009-05-28 Thread Osvaldo Kussama
2009/5/28 Atul Chojar : > We are unable to pass parameters into any sql script. Could anyone look at > the test below and give any suggestions? PostgreSQL version is 8.2.7, > running on Linux. > > > > Test Script > > > > $ cat chk_param.sql > > select ||:p_date::char(8)||; > > sele

Re: [GENERAL] weird problem with PG 8.1

2009-03-31 Thread Osvaldo Kussama
2009/3/31 Marcin Krol : > Hello everyone, > > I'm having this completely weird problem that ORDER BY doesn't seem to work > correctly in PG 8.1 as bundled in RedHat 5. > > When I issue: > > SELECT * FROM virtualization; > > I get all the fields: > > reservations=# SELECT * FROM virtualization; >  i

Re: [GENERAL] Optimization Wizard

2009-03-30 Thread Osvaldo Kussama
2009/3/30 Jennifer Trey : > Hi, > During the development of my application I once, somehow through an > installed postgresql software got me to a page where I could find > information on how to tune my db. > I can't seem to find to that link again. I think it was to a page within the > EnterpriseDB

Re: [GENERAL] How to split timestamps values by 24h slices ?

2009-03-29 Thread Osvaldo Kussama
2009/3/29 Bruno Baguette : > > I have a table that contains two timestamps (and some other fields that does > not matter here). > > the_table > -- > pk_planning_id  ==> INT8 (primary key) > timestamp_start ==> (not null timestamp without time zone) > timestamp_stop  =+> (not null timestamp

Re: [GENERAL] NOVALIDATE in postgresql?

2009-02-19 Thread Osvaldo Kussama
2009/2/19 SHARMILA JOTHIRAJAH : > Hi > In Oracle I can use the NOVALIDATE for constraints... like this > ALTER TABLE employee ADD > CONSTRAINT emp_ck > CHECK (married IN ('Y','N')) NO VALIDATE; > > When the table is already populated this will be faster. Can you do the same > in Postgresql? > >

Re: [GENERAL] Extended ability to alter column type when empty

2009-02-19 Thread Osvaldo Kussama
2009/2/17 David Andersen : > Hi, > > I am a real newbee and I hope this is the right place to post a feature > request. > > I am receiving data from a csv file where one column has a strange data > format. It would be nice if I could use Copy From with to_timestamp to > transform the date. As far a

Re: [GENERAL] Array in nested query

2009-02-15 Thread Osvaldo Kussama
2009/2/15 Fernando Moreno : > What error are you getting? > > I tried your query and I had to add an explicit cast to smallint[] to > make it work. Like this: > > ... a.attnum = any ((select conkey FROM pg_catalog.pg_constraint WHERE >> oid = 3708025)::smallint[]); > > It seems strange to me, I did

Re: [GENERAL] Elapsed time between timestamp variables in Function

2009-02-04 Thread Osvaldo Kussama
2009/2/4 Nico Callewaert : > Hi ! > > I saw previous postings about elapsed time between 2 timestamps, using > SELECT EXTRACT... > I have similar question, but it's not in a select statement, but between 2 > variables in a function. > > To keep it simple, I have 2 variables, let's say A and B, both

Re: [GENERAL] ALTER TABLE with TYPE serial does not work

2009-02-01 Thread Osvaldo Kussama
2009/2/1 Scott Marlowe : > On Sat, Jan 31, 2009 at 9:04 PM, Richard Broersma > wrote: >> On Sat, Jan 31, 2009 at 3:16 PM, Andreas Wenk >> wrote: >> >>> Why does this not work: >>> >>> postgres=# ALTER TABLE tab1 ALTER COLUMN nr TYPE serial; >>> ERROR: type "serial" does not exist >> >> serial is

Resp.: [GENERAL] How to catch the id in a INSERT INTO ... RETURNING function?

2009-02-01 Thread Osvaldo Kussama
2009/2/1, A B : > Hi. > I have a table foo(id serial primary key, b int); and I want an insert > function > > create or replace function insert_to_foo(bvalue integer) returns integer as > declare >newindex integer; > begin > ... insert into foo (a,b) values (default,bvalue) returning id >

Resp.: [GENERAL] Problem defining deferred check constraints

2009-01-25 Thread Osvaldo Kussama
2009/1/25, Thomas Kellerer : > Hi, > > I'm playing around with deferred constraints and according to the manual, it > should be possible to declare a check constraint as deferred. > > At least that's how I read the definition of /column_constraint/ at > http://www.postgresql.org/docs/8.3/static/sql

Resp.: [GENERAL] Using null or not null in function arguments

2009-01-23 Thread Osvaldo Kussama
2009/1/23, Igor Katson : > I have a row search function, smth like > > CREATE OR REPLACE FUNCTION user_func.search_users > (i_city_id int, i_edu_id int, i_first_name text, i_last_name text, > limit_ int, offset_ int) RETURNS SETOF user.user AS $$ > . SELECT * FROM user WHERE > city_id = i

Resp.: [GENERAL] difference between current_timestamp and now() in quotes

2009-01-22 Thread Osvaldo Kussama
2009/1/22, Adrian Klaver : > On Thursday 22 January 2009 8:16:46 am Alvaro Herrera wrote: >> Grzegorz Jaśkiewicz escribió: >> > test2=# insert into dupa(a) select 'current_timestamp' from >> > generate_series(1,100); >> > ERROR: date/time value "current" is no longer supported >> > LINE 1: insert

Resp.: [GENERAL] Automatic insert statement generator?

2008-12-05 Thread Osvaldo Kussama
2008/12/4, Rob Richardson <[EMAIL PROTECTED]>: > ... > The problem, of course, is that the inventory table has a unique key > constraint that gets violated. So, to do this, I'm going to have to > write an insert query that lists every field in this table (all 62 of > them), except for the primary

Resp.: [GENERAL] text array accumulate to multidimensional text array

2008-10-22 Thread Osvaldo Kussama
2008/10/14, Rainer Zaiss <[EMAIL PROTECTED]>: > > I would like to aggregate a text array into a multidimensional text array. > > Let us say I have one table with two collumns > > IDARRAY > A{"A1","B1","C1"} > A{"A2","B2","C2"} > B {"A3","B3","C3"} > > If I use a GROUP BY ID, I would

Re: [GENERAL] question about join

2008-05-01 Thread Osvaldo Kussama
2008/5/1 Ottavio Campana <[EMAIL PROTECTED]>: > Osvaldo Kussama ha scritto: > > > > > > > To further explain, the following query selects both the rows from the > join > > > where id_ref_first_tab has the desired value and default_value = true, > while

Re: [GENERAL] question about join

2008-05-01 Thread Osvaldo Kussama
2008/5/1 Ottavio Campana <[EMAIL PROTECTED]>: > Hi, I'm having a problem trying to write a query using join, and I hope you > can give me a hint. > > suppose you have a three tables like these: > > create table first_table ( > id serial primary key, > description1 text); > > crea

Re: [GENERAL] joining on concatonation?

2008-02-23 Thread Osvaldo Kussama
2008/2/22, blackwater dev <[EMAIL PROTECTED]>: > I have a query that is driving me nuts. In one table we have data that is > split between two columns and I'm trying to pull in all values from another > table where that column is represented by one piece of data. Also, all the > info in column2 i