From: | Willem Buitendyk <willem(at)pcfish(dot)ca> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | SPI_ERROR_CONNECT |
Date: | 2008-02-11 21:58:36 |
Message-ID: | 47B0C50C.9020706@pcfish.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am receiving a SPI_ERROR_CONNECT error. From what I'm reading I could
fix this in C using SPI_push(). How does one fix this with PL/PGSql?
Return error:
---------------------------------------------------------------------------------------------------
NOTICE: current day = 1
ERROR: SPI_connect failed: SPI_ERROR_CONNECT
CONTEXT: PL/pgSQL function "pop_tag_day_over" line 17 at FOR over
SELECT rows
********** Error **********
ERROR: SPI_connect failed: SPI_ERROR_CONNECT
SQL state: XX000
Context: PL/pgSQL function "pop_tag_day_over" line 17 at FOR over SELECT
rows
---------------------------------------------------------------------------------------------------
Here is my function:
---------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION pop_tag_day_over()
RETURNS void AS
$BODY$
DECLARE
current_row RECORD;
trans_day integer;
BEGIN
trans_day := 0;
truncate table day_over;
FOR i IN 1..(extract('day'
from(last_day(process_month())))-1)::integer LOOP
execute 'CREATE OR REPLACE VIEW temp_tags_18 AS SELECT datetime,
tagnum, tagtype, vrn
FROM tag
WHERE datetime <= process_month()
AND datetime > (process_month() - 18 + ' || trans_day || ')
ORDER BY vrn, tagnum, datetime';
FOR current_row IN SELECT * from temp_tags_18_counted
LOOP
IF current_row.day_count = 1 THEN
insert into day_over (vrn,process_day) values
(current_row.vrn,(1 + trans_day) );
END IF;
END LOOP;
raise notice 'current day = %',trans_day+1;
trans_day := i;
END LOOP;
END;
$BODY$
LANGUAGE 'plpgsql';
---------------------------------------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-02-11 22:14:19 | Re: SPI_ERROR_CONNECT |
Previous Message | Tom Lane | 2008-02-11 21:45:42 | Re: tsearch2 text::TSVECTOR cast not working for me on Pg 8.1.6 |