ERROR ON INSERTING USING A CURSOR IN EDB POSTGRESQL

From: James Kitambara <jameskitambara(at)yahoo(dot)co(dot)uk>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Cc: James Kitambara <jameskitambara(at)yahoo(dot)co(dot)uk>
Subject: ERROR ON INSERTING USING A CURSOR IN EDB POSTGRESQL
Date: 2021-12-09 10:36:34
Message-ID: 820139578.307641.1639046195013@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


ISSUE OF CURSOR ON THE EDB POSTGRESQL

I have the table books2 below with those fields on EDBPostgreSQL.

CREATE TABLE IF NOT EXISTSpublic.books2
(

    id integer NOT NULL DEFAULTnextval('books2_id_seq'::regclass),

    title character(10) COLLATEpg_catalog."default" NOT NULL,

    amount numeric DEFAULT 0,

    CONSTRAINT books2_pkey PRIMARY KEY (id)

);

 
The table is populated with the following data

 

I want to re-insert the records from ID 8 to 11  for the values of TITLE and AMOUNT as the IDis out-increment. To accomplish this I have created the procedure named temp_insert_in_books2() to do this

The procedure does what I wanted BUT IT GIVES ME THIS ERROR MESSAGE:

ERROR:  cursor "book_cur" does not exist

CONTEXT:  edb-spl function temp_insert_in_books2() line15 at CLOSE

SQL state: 34000

HOW CAN I REMOVE THATERROR?. ALSO NOTE THAT I ALWAYS GET THIS ERROR WHEN UPDATING OR INSERTING DATA ONTHE TABLE USING CURSORS.

PLEASE CAN ANYONE ASSIST.

 
Table Data after running the procedure is described below:

Attachment Content-Type Size
image/png 23.8 KB
image/png 31.8 KB

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Sandeep Saxena 2021-12-09 10:55:10 Re: ERROR ON INSERTING USING A CURSOR IN EDB POSTGRESQL
Previous Message Shaozhong SHI 2021-11-30 00:17:54 Re: Fault with initcap