[SQL] Job control in sql

2012-05-25 Thread Svenne Krap
Hi. I am building a system, where we have jobs that run at different times (and takes widely different lengths of time). Basically I have a jobs table: create table jobs( id serial, ready boolean, job_begun timestamptz, job_done timestamptz, primary key (id) ); This should

[SQL] Select row cells as new columns

2012-05-25 Thread danycxxx
Hello. I hope you can help me with this or at least guide me into the right direction: I have 2 tables: CREATE TABLE infos ( id integer NOT NULL DEFAULT nextval('info_id_seq'::regclass), name text NOT NULL, id_member integer NOT NULL, title text, min_length integer NOT NULL DEFAULT 0,

Re: [SQL] Select row cells as new columns

2012-05-25 Thread Jan Lentfer
On Fri, 25 May 2012 02:03:41 -0700 (PDT), danycxxx wrote: [...] The question: How can I achive this output? nume, prenume, cnp, nume anterior, stare civila, ... (as columns - built from unique rows from infos) a , a, ... b , b, ... (as rows) Did you look at crosstab functio

Re: [SQL] Job control in sql

2012-05-25 Thread Jan Lentfer
On Fri, 25 May 2012 10:28:03 +0200, Svenne Krap wrote: [...] The problem is that a later run of run_jobs() will not see the job_begun has been set by a prior run (that is unfinished - as all queries from the plpgsql-function runs in a single, huge transaction). My intitial idea was to set t

Re: [SQL] Select row cells as new columns

2012-05-25 Thread danycxxx
Yes, I've looked at it, but id doesn't create the desired output. After more research I've found that I my design is similar to Entity, Attribute and Value(EAV) design and I think I have to redesign. Any suggestion regarding EAV? Is there any other approach? -- View this message in context: http:

Re: [SQL] Inherited table identification possible

2012-05-25 Thread George Woodring
Thanks for all of the help, this was exactly what I was looking for. George On Thu, May 24, 2012 at 2:11 PM, Stephen Belcher wrote: > Yes, the system column "tableoid" identifies the actual table in which the > row is stored. If you cast this to "regclass" you'll get the name of the > table that

Re: [SQL] Flatten table using timestamp and source

2012-05-25 Thread Raj Mathur (राज माथुर)
On Friday 25 May 2012, Raj Mathur (राज माथुर) wrote: > On Thursday 24 May 2012, Elrich Marx wrote: > > If source changes, in this case from 1 to 2, then etime would be > > the last value of stime for source =1; So for source 1 it starts > > at stime 13:00 and continues till 13:02 (etime). > > > >

Re: [SQL] Flatten table using timestamp and source

2012-05-25 Thread Raj Mathur (राज माथुर)
On Saturday 26 May 2012, Raj Mathur (राज माथुर) wrote: > On Friday 25 May 2012, Raj Mathur (राज माथुर) wrote: > > On Thursday 24 May 2012, Elrich Marx wrote: > > > If source changes, in this case from 1 to 2, then etime would be > > > the last value of stime for source =1; So for source 1 it starts