Re: [GENERAL] Stripping apostrophes from data

2007-08-20 Thread Viatcheslav Kalinin
Andrew Edson wrote: Is there some program or procedure for stripping apostrophes (') from data in the db? Most of our data has been shuffled over to Postgres from an older system, and I'm occasionally running into data entered in the old system that has apostrophes in it. (Most recent example

Re: [GENERAL] Polymorphic functions' weird behavior

2007-08-01 Thread Viatcheslav Kalinin
Tom Lane wrote: You'd have to cast the NULL to some specific array type. regards, tom lane Unfortunately I can't do that (well, in fact it would be pretty inconvenient) because the function is called from other plpgsql function and I cannot be sure if it will be called with NULL or not. Anywa

Re: [GENERAL] tables not in list

2007-07-31 Thread Viatcheslav Kalinin
Lee Keel wrote: Is there no way to do this without doing an insert into another table? I usually resolve this as: -- this function lets you select from an array CREATE OR REPLACE FUNCTION "array_to_set" (vaarray anyarray) RETURNS SETOF anyelement AS $body$ BEGIN FOR I IN COALESCE(ARRAY_LOW

[GENERAL] Polymorphic functions' weird behavior

2007-07-31 Thread Viatcheslav Kalinin
Hello We've come across the following issue with Polymorphic functions: CREATE OR REPLACE FUNCTION "array_to_set" (vaarray anyarray) RETURNS SETOF anyelement AS $body$ BEGIN FOR I IN COALESCE(ARRAY_LOWER(VAARRAY, 1), 1) .. COALESCE(ARRAY_UPPER(VAARRAY, 1), 0) LOOP RETURN NEXT VAARRAY

[GENERAL] Pattern matching with index

2007-07-24 Thread Viatcheslav Kalinin
Hello, I can't seem to make a request inside a plpgsql function use an index, basically I have something like this: CREATE TABLE T1 (f VARCHAR(100)); /* db is created with utf8 locale hence 2 indicies */ CREATE INDEX ix_t1_f ON T1 USING btree ((lower("f")::text) text_pattern_ops); CREATE INDE

Re: [GENERAL] Database Insertion commitment

2007-07-09 Thread Viatcheslav Kalinin
Jasbinder Singh Bali wrote: One reason I see that new insert does't see the values of old insert is because as soon as socket connection is established, my trigger returns and 1st insert is complete even though I'm not sure whether the unix tools server has already inserted values in table te

Re: [GENERAL] Database Insertion commitment

2007-07-09 Thread Viatcheslav Kalinin
e of insert 1 and erroneously starts Activity A that it should not actually. Do you think I am missing something vital here? I'm kind of stuck and confused because fundamentally Insert 2 should be able to see the value of Insert 1 as there is no subtransaction involved. Thanks, ~Jas On 7/

Re: [GENERAL] Database Insertion commitment

2007-07-09 Thread Viatcheslav Kalinin
Jasbinder Singh Bali wrote: Hi, If I have a series of Insert statements within a loop in a function on the same table. Would an Insert be able to see the values of previous insert in that table ? I just wanted to know, when would the records be committed, as in, is it after the whole function

Re: [GENERAL] CASE in ORDER BY clause

2007-07-06 Thread Viatcheslav Kalinin
Louis-David Mitterrand wrote: Hi, I am trying the following: critik=# select start_date from show_date order by case when start_date > CURRENT_DATE then start_date desc else start_date asc end; ERROR: syntax error at or near "desc" LINE 1: ...se when start_date > CURRENT_DATE

Re: [GENERAL] CASE in ORDER BY clause

2007-07-06 Thread Viatcheslav Kalinin
Louis-David Mitterrand wrote: Hi, I am trying the following: critik=# select start_date from show_date order by case when start_date > CURRENT_DATE then start_date desc else start_date asc end; ERROR: syntax error at or near "desc" LINE 1: ...se when start_date > CURRENT_DATE

Re: [GENERAL] how to: psql -U user --password password ?

2007-07-03 Thread Viatcheslav Kalinin
http://www.postgresql.org/docs/8.2/interactive/libpq-pgpass.html or you can set PGPASSWORD environment variable (not recommended though) Stefan Zweig wrote: Hi list, i have a problem with connecting to postgresql on a remote server. basically i want to import some sets of data into the databa