[GENERAL] change array dimension

2010-07-01 Thread Gerhard Heift
Hello, is it possible to change the dimension of an array? I am looking for something like this: SELECT change_array_dims('[1:2][1:2]', '{1,2,3,4}'::int[]); change_array_dims --- {{1,2},{3,4}} and the other way around: SELECT change_array_dims('[1:4]', '{{1,2},{3,4}}'::int[]);

[GENERAL] Temporal data storage

2010-04-05 Thread Gerhard Heift
Hello, I have person to group mapping in which I want to store the time, when this mapping is valid. I can store the valid time in an array or in seperate rows. in rows: create table group_mapping ( group name not null, person integer not null, valid_since timestamptz not null, valid_unt

Re: [GENERAL] Naming conventions for lots of stored procedures

2010-03-11 Thread Gerhard Heift
On Thu, Mar 11, 2010 at 08:38:46AM -0800, Chris Travers wrote: > > On 3/10/2010 11:52 PM, Chris Travers wrote: > > Which > > i'm at a loss why nesting would help solve any problem what so ever. I > > imagine the search path on some connections would be all inclusive so > > ambiguous names is not s

[GENERAL] PANIC: hash table "LOCK" hash corrupted

2009-10-04 Thread Gerhard Heift
Hello, I'm playing with postgres in OpenVZ. When I migrate my machine with the database from one host to another I get following errors: 2009-10-04 20:20:43 CEST PANIC: hash table "LOCK hash" corrupted 2009-10-04 20:20:43 CEST STATEMENT: begin 2009-10-04 20:20:43 CEST @ LOG: server process (P

Re: [GENERAL] Select data for current week only

2009-08-27 Thread Gerhard Heift
On Thu, Aug 27, 2009 at 11:09:36AM -0700, BlackMage wrote: > > Hey all, > > I've been trying to figure this problem out with just using sql but I'm not > sure how too. I have a table that holds events for each week but I only want > to select events happening for the current week(Mon-Sun). So can

Re: [GENERAL] How to create a multi-column index with 2 dates using 'gist'?

2009-08-26 Thread Gerhard Heift
On Mon, Aug 24, 2009 at 05:24:59PM +0800, Fred Janon wrote: > Hi, > > I am using 8.3 and pgAdmin III. I have a couple of tables using 2 DATE columns > like 'startdate' and 'enddate' (just date, not interested in time in these > columns). I have some queries (some using OVERLAPS) involving both 'st

[GENERAL] unique index for periods

2009-08-19 Thread Gerhard Heift
Hello, I try to create an unique index for a (time)period, and my goal is to prevent two overlapping periods in a row. For this I created a type with following command: CREATE TYPE period AS ("first" timestamp with time zone, "next" timestamp with time zone); To use the btree index I add

Re: [GENERAL] Grouping Question

2009-07-31 Thread Gerhard Heift
On Fri, Jul 31, 2009 at 12:09:51PM -0400, Ketema Harris wrote: > I have a table defined as > > CREATE TABLE mytable > ( > carrier varchar, > start_time timestamp with time zone, > call_date date, > cost numeric, > call_length numeric > ) > > I want to create a query that will generate a

[GENERAL] size of data stored in gist index

2009-07-31 Thread Gerhard Heift
Hello, I try to index histograms in my table. For this I uses the cube contrib module in which I removed the dimension check. If the cube has more than 255 dimensions, for example 256 ^= 4 + 4 + 256 * 2 * 8 = 4104 bytes, this data can not be stored in the gist index any more. If I try it, I get th

Re: [GENERAL] Array in nested query

2009-02-15 Thread Gerhard Heift
On Sat, Feb 14, 2009 at 05:36:11PM -0500, Ken Winter wrote: >I'm trying to look up the columns in a constraint in pg_catalog (of >PostgreSQL 8.0.x). I can't figure out how to "join" the elements of the >array that lists the `attnum's of the columns in the table to the `conkey' >arr

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

2009-02-01 Thread Gerhard Heift
On Sun, Feb 01, 2009 at 11:37:52AM +0100, A B wrote: > 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)

[GENERAL] Returning old value on update

2009-01-31 Thread Gerhard Heift
Hello, is it possible to get the old value of an update, something like this: INSERT INTO my_table (col) VALUES (2); UPDATE my_table SET col = 4 RETURNING old.col; Should give me the 2. Regards, Gerhard signature.asc Description: Digital signature

Re: [GENERAL] CREATE parametric partial INDEX within a function body

2009-01-19 Thread Gerhard Heift
On Mon, Jan 19, 2009 at 08:19:06PM +0100, Reg Me Please wrote: > Hi all. > > I have a maintenance PL/pgSQL function that needs to recreate a partial index > (not a REINDEX, though). > In the WHERE condition of the index I have one of the function arguments. > A plain "CREATE INDEX ... WHERE ..." w

[GENERAL] fire trigger for a row without update?

2009-01-14 Thread Gerhard Heift
Hello, is it possible to call a trigger for a row in a table without updating the row? I want to do it in plpgsql. Something like UPDATE table WHERE id = 10; or PERFORM table.trigger('UPDATE', row) WHERE id = 10; Regards, Gerhard signature.asc Description: Digital signature

Re: [GENERAL] stable function called for every row?

2009-01-07 Thread Gerhard Heift
I isolated my problem a little bit: CREATE FUNCTION get_array() RETURNS integer[] AS $BODY$ BEGIN RAISE INFO 'get_array'; RETURN ARRAY[1, 2]; END $BODY$ LANGUAGE 'plpgsql' STABLE; And now SELECT * FROM generate_series(1,3) a(b) where array[b] <@ core.get_array(); gives me: INFO: get_array

[GENERAL] stable function called for every row?

2009-01-07 Thread Gerhard Heift
Hello, I have a query like this: SELECT * FROM table WHERE has_permission('permission_name'); and the function CREATE FUNCTION has_permission(IN pname text, OUT is_ok boolean) RETURNING boolean AS $BODY$ BEGIN SELECT has_perm INTO is_ok FROM permission WHERE title = pname; RAISE INFO 'fun

[GENERAL] Solution for tranaction independent logging in same database?

2009-01-02 Thread Gerhard Heift
On Thu, Jan 01, 2009 at 02:41:08PM +0100, Gerhard Heift wrote: > Hello, > > I want to log with triggers or in functions, and these logs should be > independet of the transaction. Beside i want to have the information > which action was commited and which not. > > So my ide

[GENERAL] How to cast a general record?

2009-01-01 Thread Gerhard Heift
Hello, I want to log with triggers or in functions, and these logs should be independet of the transaction. Beside i want to have the information which action was commited and which not. So my idea was to log into the same database with dblink, return the primary keys and add them into a commit t

[GENERAL] infinity interval

2008-12-20 Thread Gerhard Heift
Hello, how can I store an infinity value into an interval? I want to store offsets to a timestamp, and for some cases i need +infinity and -infinity as result. I want to make something like this: SELECT now() + 'infinity'::interval; This should return 'infinity'::timestamp. Is it possible? Tha

Re: [GENERAL] cumulative count

2008-12-04 Thread Gerhard Heift
On Thu, Dec 04, 2008 at 07:32:59PM +0100, Harald Fuchs wrote: > In article <[EMAIL PROTECTED]>, > Carson Farmer <[EMAIL PROTECTED]> writes: > > > date | user > > --+- > > 20050201 | Bill > > 20050210 | Steve > > 20050224 |

Re: [GENERAL] [Q]updating multiple rows with Different values

2008-11-23 Thread Gerhard Heift
On Sat, Nov 22, 2008 at 10:04:48PM -0500, V S P wrote: > Hello, > searched documentation, FAQ and mailing list archives > (mailing list archive search is volumous :-) ) > > but could not find an answer: > > I would like to be able to update > several rows to different values at the same time > >

Re: [GENERAL] Using Postgres to store high volume streams of sensor readings

2008-11-21 Thread Gerhard Heift
On Fri, Nov 21, 2008 at 02:50:45PM +0200, Ciprian Dorin Craciun wrote: > Hello all! > > I would like to ask some advice about the following problem > (related to the Dehems project: http://www.dehems.eu/ ): > * there are some clients; (the clients are in fact house holds;) > * each

Re: [GENERAL] Using database to find file doublettes in my computer

2008-11-18 Thread Gerhard Heift
On Tue, Nov 18, 2008 at 12:36:42PM +, Sam Mason wrote: > On Mon, Nov 17, 2008 at 11:22:47AM -0800, Lothar Behrens wrote: > > I have a problem to find as fast as possible files that are double or > > in other words, identical. > > Also identifying those files that are not identical. > > I'd pro

[GENERAL] avoid replace of column with variable in pgsql function

2008-11-16 Thread Gerhard Heift
Hello, I have a function with an out variable in which I have an INSERT statement with the same name as column. Is it possible to avoid the replacement? Its something like this: CREATE FUNCTION insert_foo(IN bar integer, OUT id integer) AS $BODY$ BEGIN INSERT INTO t1 (id, value) VALUES (bar, b

Re: [GENERAL] Get interval in months

2008-11-10 Thread Gerhard Heift
On Sat, Nov 08, 2008 at 07:44:45AM -0500, David Spadea wrote: > Gerhard, > > Check out: > > http://www.postgresql.org/docs/8.3/interactive/functions-datetime.html > > In particular, look at 'age()' or 'justify_days()', but I think age() is the > one you want. > > > SELECT age('2008-02-01'::ti

[GENERAL] Logging in function with exception

2008-11-10 Thread Gerhard Heift
Hello, I write funktions in pl/pgsql and want to abort it. For this I use raise exception, to undo all changes for this transaction. Now I want to log these exceptions somewhere. DECLARE a integer; log_id integer; BEGIN SELECT a INTO b FROM c WHERE d = 10; IF NOT FOUND THEN INSERT INT

[GENERAL] Get interval in months

2008-11-08 Thread Gerhard Heift
Hello, I want to get an interval in months from two dates: SELECT '2008-02-01'::timestamp - '2008-01-01'::timestamp AS '1 month' Here I want '1 month' and not '31 days' as answer. How can I do this? Regards, Gerhard signature.asc Description: Digital signature

Re: [GENERAL] UPDATE tuples with a sub-select

2008-11-07 Thread Gerhard Heift
On Fri, Nov 07, 2008 at 11:15:07AM +0100, Thomas Kellerer wrote: > Hi, > > are there any plans to support updating a tuple using a sub-select in one of > the future versions. > > e.g, something like: > > UPDATE report_table > SET (order_count,order_value) = (SELECT count(*), sum(amount) >

Re: [GENERAL] UPDATE tuples with a sub-select

2008-11-07 Thread Gerhard Heift
On Fri, Nov 07, 2008 at 02:31:42PM +0100, Thomas Kellerer wrote: > Gerhard Heift, 07.11.2008 13:35: >>> are there any plans to support updating a tuple using a sub-select in one >>> of the future versions. >>> >>> e.g, something like: >>> >>&g

Re: [GENERAL] UPDATE tuples with a sub-select

2008-11-07 Thread Gerhard Heift
On Fri, Nov 07, 2008 at 11:15:07AM +0100, Thomas Kellerer wrote: > Hi, > > are there any plans to support updating a tuple using a sub-select in one of > the future versions. > > e.g, something like: > > UPDATE report_table > SET (order_count,order_value) = (SELECT count(*), sum(amount) >

[GENERAL] restruct cash table

2008-11-07 Thread Gerhard Heift
Hello, I have a small problem with my table: I have a table for my cash and i do several actions in it. I receive money in different forms, I expend money in different forms etc. And do each action I have various foreign keys. But they are not all in use in every column. I don't know how I can str