执行立即更新不会赋予PL SQL值

时间:2018-07-17 12:18:20

标签: oracle plsql

我正在尝试更新PL SQL中的值。问题是我的dbms_output.put_line运行正常,一切都写好,但是立即执行不起作用。有趣的是,它只工作一次(甚至两个),但是现在不工作了。我不知道如何解决这个问题。

我编写的程序正在将一些随机值插入到根据输入值验证的值创建的表中。代码可能很少到很长时间都可以扔到这里,我把代码中最重要的部分放在

for looper in 1..y loop
         execute immediate 'insert into GAME ' || s_string || ' values ' 
         || rowGenerator(v_low=>1, v_high=>6, v_x=>x);
         end loop;

         start_x_point:= round (dbms_random.value( high=>x, low=>1));
         start_y_point:= round (dbms_random.value( high=>y, low=>1));
         dbms_output.put_line(start_x_point || ' ' || start_y_point);
         s_temp:= ' set x' || start_x_point || ' = 0 where ROWNUM = '|| start_y_point; 
         dbms_output.put_line(s_temp);
         execute immediate 'update GAME ' || s_temp;

带有列的s_string约束括号,

rowGenerator将随机值插入表中,

start_x_point和start_y_point是我要放置0值的地方

,问题在于它不起作用。我不知道这样做的其他方式。

这就是我的表格放置随机值后的样子,它是一个包含值的矩阵

    x1  x2  x3  x4  x5  x6  x7  x8
1   2   5   3   2   4   1   1   3
2   2   3   2   5   4   5   3   3
3   4   3   4   2   4   2   6   3
4   2   1   1   4   3   2   4   1
5   1   5   2   5   3   3   5   4
6   1   5   5   1   1   3   5   3
7   5   3   3   4   4   3   1   3
8   5   4   5   6   3   4   3   2

2 个答案:

答案 0 :(得分:4)

您的问题似乎是ROWNUM = ...。它仅在START_Y_POINT = 1时有效,而在非ROWNUM时无效。

该怎么办?不要使用UPDATE;取决于其他内容的ID值(也许是某些next: function(val1,val2) { if (val1.length != 0) { this.input = val1; this.prevMenu.push(val2); } }, prev: function() { let _menu = this.prevMenu.slice(); // this is just to clone the array this.input = _menu[_menu.length - 1]; this.prevMenu.pop(); } 值?)。

答案 1 :(得分:1)

感谢@Littlefoot我得到了答案!

我只需要放这样的东西

select * from (select * from game
where rownum <=start_y_point 
order by rownum desc)
where rownum=1;

然后我得到想要的行!