[SQL] PQexec and SPI_exec

2004-08-25 Thread Pedro B.
Hello everyone. I'm experiencing some doubts regarding a procedure i have (.c compiled as .so) running as an 'after insert for each row' trigger. This trigger is supposed to do a simple query, something like SELECT * FROM table order by id where processed=0 limit 1 It's not the perfect way to

Re: [SQL] PQexec and SPI_exec

2004-08-25 Thread Jan Wieck
On 8/25/2004 10:21 AM, Pedro B. wrote: Hello everyone. I'm experiencing some doubts regarding a procedure i have (.c compiled as .so) running as an 'after insert for each row' trigger. This trigger is supposed to do a simple query, something like SELECT * FROM table order by id where processed=0

[SQL] Complicated group by question

2004-08-25 Thread Andrew Perrin
I have a table of people (reviewers), a table of review assignments (assign), and a table of review acceptances (accept). I would like to be able to write a query to return the latest (e.g., max(assign_date)) assignment for each reviewer, plus the acc_id field from accept. I think I should be

Re: [SQL] Complicated group by question

2004-08-25 Thread Josh Berkus
Andrew, I have a table of people (reviewers), a table of review assignments (assign), and a table of review acceptances (accept). I would like to be able to write a query to return the latest (e.g., max(assign_date)) assignment for each reviewer, plus the acc_id field from accept. I think I

Re: [SQL] Complicated group by question

2004-08-25 Thread Jean-Luc Lachance
Andrew, If assing is not a many to many relation, why did you not fold accept_id into assign? Any way, here is the query you need: select assign.reviewer_id, ss.max_assign_date, accept.assign_id, accept.accept_id from ( select reviewer_id, max( assign_date) as max_assign_date from assign

Re: [SQL] Complicated group by question

2004-08-25 Thread Andrew Perrin
Excellent - thanks, Josh! -- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill [EMAIL PROTECTED] * andrew_perrin (at) unc.edu On Wed, 25 Aug 2004, Josh Berkus

[SQL] problem with RULE

2004-08-25 Thread Sreten Milosavljevic
I have two tables. One is test_main, and second is named result. Also I have view which summarizes results from test_main table and groups them by ID column: CREATE TABLE test_main(id varchar(4), value int4); CREATE TABLE result(id varchar(4), value int4); CREATE VIEW

Re: [SQL] olympics ranking query

2004-08-25 Thread Mischa Sandberg
That 'running aggregate' notion comes up quite regularily, and it has a number of nonintuitive holes, to do with what happens when your ordering allows for ties. ASTRID had it, RedBrick SQL had it, the latest MSSQL has it ... not necessarily a recommendation. Tom Lane wrote: David Garamond [EMAIL

[SQL] help with scheme changes to live system.

2004-08-25 Thread Tony Yang
Hi Gurus, Please forgive this naive question: Say, I have a table (containerId, itemId) where for each containerId there are several rows (different itemId value) in that table. Now I want to give those rows (with same containerId) a sequence, so add one colum there to make it become

[SQL] view triggers/procedures

2004-08-25 Thread SVGK, Raju (Raju)
Hi, I have a table where in lot of triggers were included in that as shown below. How to view/access triggers and procedures from postgresql. I am using postgresql 7.4.1 on solaris. regds -raju Process=# \d reviews Table public.reviews Column

[SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Kathrine S
Below is a copy of my sql sentence including the error I am getting. What does the error mean? What have I done wrong? kathrirs=# insert into faglaerer kathrirs-# values ('f-001', '13056802876', 'Petter Lær', lo_import('/home/studenter/it03/kathrirs/img/img01.jpg'), kathrirs(# '2001-12-25', 100,

Re: [SQL] CREATE TYPE VARCHAR2

2004-08-25 Thread Tom Lane
Sascha Ziemann [EMAIL PROTECTED] writes: I would like to define a new type VARCHAR2 which should behave exactly like VARCHAR. You could get about halfway there with CREATE DOMAIN varchar2 AS varchar; But it's only halfway because the domain will not accept length decorations; that is

Re: [SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Tom Lane
Kathrine S [EMAIL PROTECTED] writes: Below is a copy of my sql sentence including the error I am getting. What does the error mean? What have I done wrong? kathrirs=# insert into faglaerer kathrirs-# values ('f-001', '13056802876', 'Petter Lær',

Re: [SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Adrian Klaver
On Wednesday 25 August 2004 07:21 pm, Tom Lane wrote: Kathrine S [EMAIL PROTECTED] writes: Below is a copy of my sql sentence including the error I am getting. What does the error mean? What have I done wrong? kathrirs=# insert into faglaerer kathrirs-# values ('f-001', '13056802876',

Re: [SQL] ERROR: Invalid regular expression: parentheses ( ) not balanced

2004-08-25 Thread Tom Lane
Adrian Klaver [EMAIL PROTECTED] writes: I don't know what to make of it but the problem seems to start at the lines I have marked 1 2 and involves the lo_import function. I have not used lo_import and so do not know how to call it. What I do see is that it is called at 1 and a '(' shows