oracle - PLSQL UPDATE OF with Join -


i'm trying create plsql statement updates money in inventory of characters money creatures they've fought

the following code i've been trying:

   declare         inv_money character.money%type;         cursor updmoney             select *             character             id in (select character_id inst_creature)         update of money;     begin         v_character in updmoney loop            select inst_creature.money           inv_money           inst_creature,character           inst_creature.character_id = character.id;            update character           set money = money+inv_money           current of updmoney;         end loop;         commit;     end; 

there character_id in inst_creature table used define character fought creature.

i'm getting error ora-01422: exact fetch returns more requested number of rows.

i've been trying fix using google solution nothing has been working far. thoughts?

what happens when character has killed more 1 monster? ora-01422, that's what. select ... syntax populates scalar value, 1 row. when query returns more 1 row pl/sql hurls ora-01422.

" there solution work?"

the easiest way fix query returns 1 row. you're adding money character's trove, can use aggregate:

      select sum(inst_creature.money)       inv_money       inst_creature,character       inst_creature.character_id = character.id; 

so 1 row per character, , 1 update per character.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -