SPI_ERROR_CONNECT - Mailing list pgsql-general

From Willem Buitendyk
Subject SPI_ERROR_CONNECT
Date
Msg-id 47B0C50C.9020706@pcfish.ca
Whole thread Raw
Responses Re: SPI_ERROR_CONNECT
List 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';
---------------------------------------------------------------------------------------------------

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: tsearch2 text::TSVECTOR cast not working for me on Pg 8.1.6
Next
From: Tom Lane
Date:
Subject: Re: SPI_ERROR_CONNECT