cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

fetch on cursor

abou_doumbia
Product and Topic Expert
Product and Topic Expert
0 Likes
510

Hi,

I'm writing a cursor for retrieve a name from a table.

And take this name to do logic work.

My code is :

DECLARE v_nomtable VARCHAR(70);

DECLARE v_trigramme CHAR(3);

DECLARE v_expresst1 varchar(200);

DECLARE v_expresst2 varchar(200);

DECLARE CURSOR cursor_reset_repli FOR

select NomTable from TABLE_REPLICATE;

select Trigramme into v_trigramme from TABLE_TRIGRAMME;

OPEN cursor_reset_repli;

FETCH cursor_reset_repli into v_nomtable;

WHILE NOT cursor_reset_repli::NOTFOUND

DO

v_expresst1 = CONCAT ('VT_',:v_trigramme) || CONCAT ('_', :v_nomtable);

v_expresst2 = CONCAT ('TG_',:v_trigramme) || CONCAT ('_', :v_nomtable);

... some exec

FETCH cursor_reset_repli into v_nomtable;

END WHILE;

CLOSE cursor_reset_repli;

END

---

When I've exec the cursor, I've got this error:

Error: (dberror) [1300]: fetch returns more than requested number of rows:

I can't understand why my cursor doesn't.

Can you help me?

Really thanks

View Entire Topic
Kai_Mueller
Advisor
Advisor
0 Likes

Hello Abou,

it could be related to this line
"select Trigramme into v_trigramme from TABLE_TRIGRAMME;"
If TABLE_TRIGRAMME contains more than one row the statement will fail. Please check this.

Best regards, Kai