欢迎各位兄弟 发布技术文章
这里的技术是共享的
declare:用于plsql中的声明变量,和begin连用,和存储过程结构相似
declare
v_sal number(7,2):=60000;----声明时同时赋值,声明变量v_sal 类型为number(7,2)前面的7表示总共允许7个字符长,称为宽度。后面2是保留小数点后面两位,称为精度。
v_comm2 number(7,2):=v_sal*0.20;
v_aa number(7,2):=100;
v_message varchar2(255):='eligible for commission';
begin
declare
v_sal number(7,2):=10;
v_comm number(7,2):=0;
v_total_comp number(7,2):=v_sal+v_comm;
begin
v_message:='clerk not'||v_message;
v_comm:=v_sal*0.30;
v_aa:=v_aa*0.30;
DBMS_OUTPUT.PUT_LINE ('2:'||TO_CHAR(v_aa));--dbms_output.put_line 输出数据括号里的||代表字符串的拼接
DBMS_OUTPUT.PUT_LINE ('1:'||TO_CHAR(v_comm2));
end;
v_message:='salesman'||v_message;
DBMS_OUTPUT.PUT_LINE (TO_CHAR(v_comm2));
end;
select employee_ID as employees,first_name||last_name as "employee Name",Department_ID as "departement",salary as "Salary",email as "Email",phone_number as "phone",hire_date as "ehire date",job_id as "job Id" from employees;
select employee_ID employees,first_name||last_name "employee Name",Department_ID "departement",salary "Salary",email "Email",phone_number "phone",hire_date "ehire date",job_id "job Id" from employees;
以上两句都能实现以下效果,plsql中取别名最好不要用as,||符号是拼接字符串
来自 https://blog.csdn.net/pangesange/article/details/76612763