Re: [SQL] C function extending postgres

2005-03-21 Thread Theo Galanakis
Title: RE: [SQL] C function extending postgres Sorted Jonathan, thankyou for your help. -Original Message- From: Jonathan Daugherty [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 22 March 2005 4:32 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] C function extending postgres # I'm

Re: [SQL] C function extending postgres

2005-03-21 Thread Jonathan Daugherty
# I'm actually trying to use a system metrics library from # http://www-usr.inf.ufsm.br/~veiga/liblproc/index-en.html Have you added the path of the lproc library to your /etc/ld.so.conf? -- Jonathan Daugherty http://www.parsed.org ---(end of broadcast)--

Re: [SQL] C function extending postgres

2005-03-21 Thread Theo Galanakis
Title: RE: [SQL] C function extending postgres Thanks for your feedback. I'm actually trying to use a system metrics library from http://www-usr.inf.ufsm.br/~veiga/liblproc/index-en.html I have tried to link the library however I'm still getting the same message. cc -g -I /usr/local/pgsq

Re: [SQL] equivalent of oracle rank() in postgres

2005-03-21 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Jus wanted the equivalent for rank() as in tis example.. > SELECT * > FROM ( > SELECT employee_id, last_name, salary, > RANK() OVER (ORDER BY salary DESC) EMPRANK > FROM employees) > WHERE emprank = 3; There is no direct equivalent to rank(

Re: [SQL] "Flattening" query result into columns

2005-03-21 Thread Scott Marlowe
On Mon, 2005-03-21 at 15:57, Thomas Borg Salling wrote: > I am looking for a way to âflattenâ a query result, so that rows are > âtransposedâ into columns, just as asked here for oracle: > > http://groups.google.dk/groups?hl=da&lr=&client=firefox-a&rls=org.mozilla:en-US:official&selm=aad10be0.0401

Re: [SQL] "Flattening" query result into columns

2005-03-21 Thread PFC
You could use the array_accum aggregate. See examples in the docs. On Mon, 21 Mar 2005 22:57:13 +0100, Thomas Borg Salling <[EMAIL PROTECTED]> wrote: I am looking for a way to "flatten" a query result, so that rows are "transposed" into columns, just as asked here for oracle: http://groups.g

Re: [SQL] "Flattening" query result into columns

2005-03-21 Thread Leif B. Kristensen
On Monday 21 March 2005 22:57, Thomas Borg Salling wrote: > I am looking for a way to "flatten" a query result, so that rows are > "transposed" into columns, just as asked here for oracle: > > Is there any way to do this with pgsql  ? Just to help out the guys, here's a working link:

Re: [SQL] C function extending postgres

2005-03-21 Thread Jonathan Daugherty
# ERROR: could not load library "/usr/lib/pgsql/processinfo.so": # /usr/lib/pgsql/processinfo.so: undefined symbol: proc_cpu_idle My guess that you're not linking against the library that containts 'proc_cpu_idle' when you build your .so. What's the build platform? -- Jonathan Daughert

[SQL] C function extending postgres

2005-03-21 Thread Theo Galanakis
Title: C function extending postgres #include "postgres.h" #include "fmgr.h" #include "proc.h" PG_FUNCTION_INFO_V1(get_process_total); Datum get_process_total(PG_FUNCTION_ARGS) {     float ret;     ret = proc_cpu_user() + proc_cpu_nice() + proc_cpu_system() - proc_cpu_idle();  

Re: [SQL] "Flattening" query result into columns

2005-03-21 Thread Sean Davis
Thomas,   You probably want a crosstab.  There is a contributed module in contrib/crosstab.  If you do a search of the postgres mailing lists, there will be several posts relating to the same issue.   Sean   - Original Message - From: Thomas Borg Salling To: pgsql-sql@p

[SQL] "Flattening" query result into columns

2005-03-21 Thread Thomas Borg Salling
I am looking for a way to ”flatten” a query result, so that rows are ”transposed” into columns, just as asked here for oracle: http://groups.google.dk/groups?hl=da&lr=&client=firefox-a&rls=org.mozilla:en-US:official&selm=aad10be0.0401292322.7b6c320b%40posting.google.com   Is there any wa

Re: [SQL] query

2005-03-21 Thread Bruno Wolff III
On Mon, Mar 21, 2005 at 08:33:43 -0600, "Thomas F.O'Connell" <[EMAIL PROTECTED]> wrote: > You should be able to use the CURRENT_DATE function in place of sysdate. > > You might need to cast the 1 explicitly to an interval. > > As in: > > CURRENT_DATE - '1 day'::interval I don't think you want

Re: [SQL] CASE not working

2005-03-21 Thread Martín Marqués
El Lun 21 Mar 2005 11:29, Alvaro Herrera escribió: > On Mon, Mar 21, 2005 at 11:18:38AM -0300, Martín Marqués wrote: > > Hey Martin, > > > I have this query which has a CASE in the middle to give me special results. > > The problem is that it doesn't interpret my columns as it should. > > > >

Re: [SQL] CASE not working

2005-03-21 Thread Alvaro Herrera
On Mon, Mar 21, 2005 at 11:18:38AM -0300, Martín Marqués wrote: Hey Martin, > I have this query which has a CASE in the middle to give me special results. > The problem is that it doesn't interpret my columns as it should. > > Here is the porblem: > > siprebi=> SELECT getvencimientosancion(190

Re: [SQL] query

2005-03-21 Thread Thomas F . O'Connell
You should be able to use the CURRENT_DATE function in place of sysdate. You might need to cast the 1 explicitly to an interval. As in: CURRENT_DATE - '1 day'::interval -tfo -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC http://www.sitening.com/ 110 30th Avenue North, Suite

[SQL] CASE not working

2005-03-21 Thread Martín Marqués
I have this query which has a CASE in the middle to give me special results. The problem is that it doesn't interpret my columns as it should. Here is the porblem: siprebi=> SELECT getvencimientosancion(190) AS vence, (SELECT codigo FROM sanciones WHERE persona = (SELECT persona FROM usuarios

Re: [SQL] index scan

2005-03-21 Thread Richard Huxton
Please CC the list as well as replying directly to me. I don't read this email address often. Mihail Nasedkin wrote: RH> Why do you want an index scan? Do you have any evidence it will be RH> faster than a sequential scan? No, but I want to be ready for make Index scan queries in future. I make f

Re: [SQL] Your question about date

2005-03-21 Thread Béatrice Yueksel
Dear Christoph, perhaps you could try something like this example. Regards, BÃatrice The table: -- # select * from test; date 2005-02-02 2005-03-05 2005-04-07 2005-05-02 (4 rows) The query -- SELECT (( select test1.date from test test1

Re: [SQL] index scan

2005-03-21 Thread Mihail Nasedkin
Die, Richard. Thank you for answer March, 21 2005 14:15:40: RH> Mihail Nasedkin wrote: >> =# explain select * from sites s join site_screens ss on >> s.oid = ss.id_site;QUERY PLAN >>

Re: [SQL]

2005-03-21 Thread Christoph Haller
Octavio Alvarez wrote: > > Sorry, I tried to make my subject as good as possible. Ahem, what subject? > > I have a table where I store the dates in which I take out of my inventory > (like "installation dates") > > table > --- > row_id SERIAL > date DATE > fk_item INTEGER >

Re: [SQL] index scan

2005-03-21 Thread Richard Huxton
Mihail Nasedkin wrote: =# explain select * from sites s join site_screens ss on s.oid = ss.id_site;QUERY PLAN --- Hash Join (cost=...) Hash Cond:

[SQL] index scan

2005-03-21 Thread Mihail Nasedkin
Hello, pgsql-sql. I have customize simple query with join two tables: =# \d sites Таблица "public.sites" Колонка | Тип | Модификаторы -+--

Re: [SQL] date subtraction

2005-03-21 Thread Richard Huxton
Ashok Agrawal wrote: I need to do date calculation similar to oracle in postgres. like sysdate - creation_date of the record which returns no of days in oracle which you can convert to hours or second by multiplying by 60 or 3600. How do i achieve this in postgres. Umm, SELECT CURRENT_DATE - crea

Re: [SQL] Trigger with parameters

2005-03-21 Thread Richard Huxton
[EMAIL PROTECTED] wrote: CREATE TRIGGER products_codes_checkfieldvalue BEFORE INSERT OR UPDATE ON main.products_codes FOR EACH ROW EXECUTE PROCEDURE trigger_system_checkfieldvalue('main','products_codes'); --- ERROR: function trigger_system_checkfieldvalue() does not exist But the functio