本文介绍了仅在键入:= E时才需要询问价格代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在这里有个小问题,我想要一部分代码lv_price_num:='& lv_price_num';如果TYPE:='E'则要初始化,但是当我运行代码时,无论类型如何,它都会提示输入价格,其余的都可以正常工作.
I have small problem here, I want portion of the code lv_price_num := '&lv_price_num'; to be initiated if TYPE := 'E', however when I run the code it will prompt to enter the price regardless of the type, rest is working fine.
DECLARE
lv_type_txt CHAR(1);
lv_price_num NUMBER(4,2);
lv_disc_num NUMBER(3,2);
BEGIN
lv_type_txt := '&lv_type_txt';
IF lv_type_txt = 'E' THEN
lv_price_num := '&lv_price_num';
IF lv_price_num > 85 THEN
lv_disc_num := .20;
ELSIF lv_price_num > 45 THEN
lv_disc_num := .15;
ELSE lv_disc_num := .10;
END IF;
ELSIF lv_type_txt = 'C' THEN
lv_disc_num := .05;
ELSE lv_disc_num := 0;
END IF;
DBMS_OUTPUT.PUT_LINE(lv_disc_num);
END;
推荐答案
每当您使用&"号调用变量时,相关语句都会将其视为参数.您可以将其称为抑制此类响应的过程或函数:
whenever you call a variable with an ampersand, related statement perceives it as a parameter. You may call it as a procedure or function to suppress such a response :
SQL> set serveroutput on;
SQL> CREATE OR REPLACE PROCEDURE MY_PROC( lv_price_num NUMBER, lv_type_txt VARCHAR2 ) IS
lv_disc_num NUMBER(3,2);
BEGIN
IF lv_type_txt = 'E' THEN
IF lv_price_num > 85 THEN
lv_disc_num := .20;
ELSIF lv_price_num > 45 THEN
lv_disc_num := .15;
ELSE lv_disc_num := .10;
END IF;
ELSIF lv_type_txt = 'C' THEN
lv_disc_num := .05;
ELSE lv_disc_num := 0;
END IF;
DBMS_OUTPUT.PUT_LINE(lv_disc_num);
END;
这篇关于仅在键入:= E时才需要询问价格代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!