0

为什么这不起作用?:

Declare
type tablica is table of varchar2(30)
index by binary_integer;
tab tablica;
i integer :=0;
n integer :=0;
inp integer:='&inp';
one varchar(20);

Begin
While n<3 Loop

n:=n+1;
tab(n):='&one';

End Loop;

(....)

它应该从键盘读取 3 次输入并将其放入 char 表中 - 它只读取 1 次:/

4

1 回答 1

0

为什么要在 PL/SQL 中使用 &?替换用于 SQL。这将起作用:

Declare
  type tablica is table of varchar2(30) index by binary_integer;
  tab tablica;
  i integer :=0;
  n integer :=0;
 --inp integer:='&inp';
 one varchar(20);
Begin
 While n<3 Loop
  n:=n+1;

  If n = 1 Then
     tab(n):='one';
  elsif
    n = 2 Then
     tab(n):='two';
  Else
     tab(n):='three';
  End if;

   dbms_output.put_line(n||chr(9)||tab(n));
 End Loop;
End;
/

这是您可能想要的一些很好的例子: http ://www.dba-oracle.com/concepts/pl_sql_while_loop.htm

于 2013-02-27T13:21:57.387 回答