Search Postgresql Archives

SPI_ERROR_CONNECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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';
---------------------------------------------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
      message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux