2017-11-21 19 views
0

私は最初の "IF"で満たす必要があるif else文を持っています。しかし、私はそれを動作させることはできませんでした。あなたの誰かが助けてくれると感謝しています。ここでif(複数の条件)... else

は、私はコードを書いた方法です:

Declare 
    is_null Integer := 10; 
    Wrong_record :=2; 

If (is_null > 0 or wrong_record > 0) 
Begin 

Insert INTO table name (column1, column2, .......) 
Values 
    (value1, value2,........); 

ElSE 

    Insert INTO table name (column1, column2, .......) 
    Values 
    (value1, value2,........); 
END IF; 
END 
+1

あなたはBEGINとIFとTHEN条件後 – Thomas

+0

@Thomasのおかげで〜 –

答えて

0
Declare 
    is_null  pls_integer := 10; 
    Wrong_record pls_integer := 2; 
Begin 
If (is_null > 0 or wrong_record > 0) Then 
    Begin -- this "begin .. end " statement is not required but stands for readability 
    Insert Into table_name (column1, column2, .......) 
    Values(value1, value2,........); 
    End; 
Else 
    Begin -- this "begin .. end " statement is not required but stands for readability 
    Insert Into table_name (column1, column2, .......) 
    Values(value1, value2,........); 
    End; 
End if; 
End; 
+0

@StevenHuangは、恐れ入りますが追加する必要があり、私swithced 'table_name'の代わりに' table_name'のままにしておきました。今、私は訂正しました。 –

+0

返事をありがとう。私はそれがうまくいくと確信していますが、試してみると "If(is_null> 0 or wrong_record> 0)"に "invalid number"が返されます。また、コードを実行すると、「匿名ブロックが完了しました」というメッセージが表示され続けます。なぜなのかご存知ですか? –

+0

@StevenHuang \t "anonymous block completed"は、PL/SQLコードが正常に実行されたことを意味します。以前はset serveroutput onを発行したと思いますが、このメッセージが表示されます。問題ない。 –