Re: [GENERAL] Please help me regarding the WITH RECURSIVE query

2013-08-26 Thread BladeOfLight16
On Mon, Aug 26, 2013 at 3:17 AM, gajendra s v wrote: > Please explain me why it is ? > A good place to start would be removing all the parts here that don't seem to matter. Your problem seems to be with the recursive query (since that is the part you're changing). Cut off everything else and com

[GENERAL] Please help me regarding the WITH RECURSIVE query

2013-08-26 Thread gajendra s v
Hello All, I am migrating oracle queries to postgres queries *Oracle query is below* select * from (select * from KM_COURSE_MAST where ID in (select OBJ_ID from (select OBJ_ID,PERFORMER_TYPE,PERFORMER_ID from KM_REL_OBJ_PER_ACTION where OBJ_TYPE='COURSETYPE') where PERFORMER_TYPE='GROUP'

Re: [GENERAL] Please help me to take a look of the erros in my functions. Thanks.

2012-04-03 Thread Bartosz Dmytrak
2012/4/3 Alban Hertroys > On 2 Apr 2012, at 22:28, Bartosz Dmytrak wrote: > > > That is right, there is no sense to use cursors here... > > I think you're wrong there: The OP is querying a system table for tables > of a certain name, which I expect can contain multiple rows for tables of > the sa

Re: [GENERAL] Please help me to take a look of the erros in my functions. Thanks.

2012-04-02 Thread Alban Hertroys
On 2 Apr 2012, at 22:02, leaf_yxj wrote: > CREATE OR REPLACE FUNCTION truncate_t(tablename IN VARCHAR) RETURNS void AS > $$ > DECLARE > stmt RECORD; > statements CURSOR FOR SELECT tablename FROM pg_catalog.pg_tables; > BEGIN > IF stmt IN statements then > EXECUTE 'TRUNCAT

Re: [GENERAL] Please help me to take a look of the erros in my functions. Thanks.

2012-04-02 Thread Alban Hertroys
On 2 Apr 2012, at 22:28, Bartosz Dmytrak wrote: > That is right, there is no sense to use cursors here... I think you're wrong there: The OP is querying a system table for tables of a certain name, which I expect can contain multiple rows for tables of the same name in different schema's. Of c

Re: [GENERAL] Please help me to take a look of the erros in my functions. Thanks.

2012-04-02 Thread Bartosz Dmytrak
That is right, there is no sense to use cursors here... CREATE OR REPLACE FUNCTION truncate_t (IN tablename text) RETURNS VOID AS $$ BEGIN EXECUTE 'TRUNCATE TABLE ' || quote_ident(tablename) || 'CASCADE;'; EXCEPTION WHEN undefined_table THEN RAISE EXCEPTION 'Table "%" does not exists', tablename

Re: [GENERAL] Please help me to take a look of the erros in my functions. Thanks.

2012-04-02 Thread Pavel Stehule
Hello " IF stmt IN statements then " is nonsense. use trapping exceptions instead BEGIN EXECUTE 'TRUNCATE TABLE ' || quote_ident(_tablename) || ' CASCADE'; EXCEPTION WHEN undefined_table THEN RAISE EXCEPTION 'your own exception, when you like'; END; Regards Pavel 2012/4/2 leaf_yxj : > I

[GENERAL] Please help me to take a look of the erros in my functions. Thanks.

2012-04-02 Thread leaf_yxj
I tried to create function to truncate table 1) when the user call the function just specify the tablename 2) the user can use the function owner privilege to execute the function. But I got the errors as follows. Please help me to take a look. Thanks. Regards. Grace -- function : CREA

Re: [GENERAL] please help me. I can't pg_dumg DB

2010-06-04 Thread Bill Moran
In response to peeratat tungsungnern : > > My HDD has bad sector and i can change new HDD. I have a ploblem can't back > up database and display massage is: > > pg_dump: SQL command failed > pg_dump: Error message from server: ERROR: cache lookup failed for function > 137832813 > pg_dump: The

[GENERAL] please help me. I can't pg_dumg DB

2010-06-04 Thread peeratat tungsungnern
My HDD has bad sector and i can change new HDD. I have a ploblem can't back up database and display massage is: pg_dump: SQL command failed pg_dump: Error message from server: ERROR: cache lookup failed for function 137832813 pg_dump: The command was: SELECT tableoid, oid, adnum, pg_cat

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Tim Landscheidt
Nikolas Everett wrote: > Sorry. Here is the setup: > CREATE TABLE test (id BIGSERIAL PRIMARY KEY, state1 INT NOT NULL, state2 INT > NOT NULL, timestamp TIMESTAMP); > INSERT INTO test (state1, state2, timestamp) VALUES (1, 1, now() - interval > '12 hours'); > INSERT INTO test (state1, state2, tim

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Nikolas Everett
Got it: SELECT state1, timestamp FROM (SELECT state1, timestamp, lag(state1) OVER (ORDER BY timestamp) FROM test) as foo WHERE state1 != lag OR lag IS NULL ORDER BY timestamp; state1 | timestamp + 1 | now() - interval '12 hours'

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Nikolas Everett
The 10 and 11 hour interval are being skipped because I'm only interested in the transitions of state 1. State 1 only transitioned three times at now - 12, now - 9 and now - 8. The table has both transitions in it because I frequently care about them both together. I just don't in this case. On

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Justin Graf
On 5/27/2010 9:45 AM, Nikolas Everett wrote: > Sorry. Here is the setup: > CREATE TABLE test (id BIGSERIAL PRIMARY KEY, state1 INT NOT NULL, > state2 INT NOT NULL, timestamp TIMESTAMP); > INSERT INTO test (state1, state2, timestamp) VALUES (1, 1, now() - > interval '12 hours'); > INSERT INTO tes

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Justin Graf
On 5/27/2010 9:04 AM, Nikolas Everett wrote: > Say I have a table that stores state transitions over time like so: > id, transitionable_id, state1, state2, timestamp > > I'm trying to write a query that coalesces changes in state2 away to > produce just a list of transitions of state1. I guess it

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Nikolas Everett
Sorry. Here is the setup: CREATE TABLE test (id BIGSERIAL PRIMARY KEY, state1 INT NOT NULL, state2 INT NOT NULL, timestamp TIMESTAMP); INSERT INTO test (state1, state2, timestamp) VALUES (1, 1, now() - interval '12 hours'); INSERT INTO test (state1, state2, timestamp) VALUES (1, 2, now() - interva

Re: [GENERAL] Please help me write a query

2010-05-27 Thread Ozz Nixon
Lost me a bit, do you mean DISTINCT? select distinct state1, first(timestamp) from table On May 27, 2010, at 10:04 AM, Nikolas Everett wrote: > Say I have a table that stores state transitions over time like so: > id, transitionable_id, state1, state2, timestamp > > I'm trying to write a qu

[GENERAL] Please help me write a query

2010-05-27 Thread Nikolas Everett
Say I have a table that stores state transitions over time like so: id, transitionable_id, state1, state2, timestamp I'm trying to write a query that coalesces changes in state2 away to produce just a list of transitions of state1. I guess it would look something like SELECT state1, FIRST(timest

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-09 Thread pgsql
Tom Lane wrote: pgsql writes: Tom Lane wrote: Um, that's not too helpful, we want to see the string it's pointing at. Sorry about that. All statements are calling one of two pl/pgsql functions. While that information already helps me a lot, it'll take me a while to step through the code. T

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-06 Thread Tom Lane
pgsql writes: > Tom Lane wrote: >> Um, that's not too helpful, we want to see the string it's pointing at. > Sorry about that. All statements are calling one of two pl/pgsql > functions. While that information already helps me a lot, it'll take me > a while to step through the code. Those funct

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-05 Thread pgsql
Tom Lane wrote: pgsql writes: Tom Lane wrote: Looking at debug_query_string in the core dumps would at least show what SQL command is calling the function(s) --- and I wouldn't be surprised if there's exactly one function involved here. Content of debug_query_string: core.21207 $1 = 6310

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-05 Thread Tom Lane
pgsql writes: > Tom Lane wrote: >> Looking at debug_query_string in the core dumps would >> at least show what SQL command is calling the function(s) --- and I >> wouldn't be surprised if there's exactly one function involved here. > Content of debug_query_string: > core.21207 > $1 = 63106368 U

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-05 Thread pgsql
Tom Lane wrote: pgsql writes: Looking at debug_query_string in the core dumps would at least show what SQL command is calling the function(s) --- and I wouldn't be surprised if there's exactly one function involved here. Content of debug_query_string: core.21207 $1 = 63106368 core.20832 $1 =

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-05 Thread pgsql
Alvaro Herrera wrote: pgsql wrote: Hi, one of our pgsql instances recently started to segfault multiple times a week. I tried a couple of things to pin it down to a certain query or job but failed to find any pattern. All I can offer is some notes and a set of similar looking back traces. Ple

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-04 Thread Craig Ringer
On 5/05/2010 5:27 AM, Alvaro Herrera wrote: pgsql wrote: Hi, one of our pgsql instances recently started to segfault multiple times a week. I tried a couple of things to pin it down to a certain query or job but failed to find any pattern. All I can offer is some notes and a set of similar look

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-04 Thread Tom Lane
pgsql writes: > one of our pgsql instances recently started to segfault multiple times a > week. I tried a couple of things to pin it down to a certain query > or job but failed to find any pattern. All I can offer is some notes > and a set of similar looking back traces. BTW, there is a post-8.3

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-04 Thread Tom Lane
pgsql writes: > one of our pgsql instances recently started to segfault multiple times a > week. I tried a couple of things to pin it down to a certain query > or job but failed to find any pattern. All I can offer is some notes > and a set of similar looking back traces. All of those traces seem

Re: [GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-04 Thread Alvaro Herrera
pgsql wrote: > Hi, > > one of our pgsql instances recently started to segfault multiple times a > week. I tried a couple of things to pin it down to a certain query > or job but failed to find any pattern. All I can offer is some notes > and a set of similar looking back traces. Please install th

[GENERAL] Please help me debug regular segfaults on 8.3.10

2010-05-04 Thread pgsql
Hi, one of our pgsql instances recently started to segfault multiple times a week. I tried a couple of things to pin it down to a certain query or job but failed to find any pattern. All I can offer is some notes and a set of similar looking back traces. Thanks in advance. Machine details ---

Re: [GENERAL] PLEASE HELP ME

2005-04-21 Thread John DeSoi
On Apr 21, 2005, at 1:22 AM, amit kumar awasthi wrote: # Using sockets credentials for improved security. Not available everywhere, # but works on Linux, *BSD (and probably some others) local  all    all            ident  sameuser #local  all    all            127.0.0.1  sameuser only this en

[GENERAL] PLEASE HELP ME

2005-04-21 Thread amit kumar awasthi
  Hello sir actually i am working with Qt using postgresql i have to get connection {(database("trainee"),user("trainee"))} from the network (database remote accessing) so i have configured postgresql.conf and pg_hba.conf upto some extents the fields that i  have configured r as follows even t

Re: [GENERAL] please help me with arrays

2000-10-22 Thread Peter Eisentraut
Bo Berkhaut writes: > CREATE TABLE example (name text, slots text[]); > > I want to be able to select, for example, all rows such that an element > of example.slots exists equal to example.name. There are some operators for this in contrib/array. However, I'd say that if you're trying to do thi

[GENERAL] please help me with arrays

2000-10-22 Thread Bo Berkhaut
Hi! Would you please explain me how can I express in PostgreSQL the notion of "any element of the array". Having a table like: CREATE TABLE example (name text, slots text[]); I want to be able to select, for example, all rows such that an element of example.slots exists equal to example.name. So

Re: [GENERAL] please help me recover from duplicate key in unique index

2000-01-04 Thread Adriaan Joubert
> > Please help me recover our database from what I think > > is a duplicate key in unique index problem. > > This may not help, and forgive my asking the obvious, but have > you done a SELECT on the table and actually *seen* duplicate 'id' > values in the SERIAL column? That would surprise me be