ORACLE1.22 %type %rowtype
select * from tt3
-- 20年后多少歲
?
declare
?? age tt3.age%type;
?? dif tt3.age%type;
begin
?? select age into age from tt3 where id=1;
?? dif := 20; -- 設(shè)置一個(gè)年齡差
?? age:= age + dif;
?? dbms_output.put_line(age);
end;
------------------------------
declare
?? age tt3.age%type;
?? dif tt3.age%type :=20; -- 設(shè)置一個(gè)年齡差
begin
?? select age into age from tt3 where id=1;
?? age:= age + dif;
?? dbms_output.put_line(age);
end;
-------------------
declare
?? age tt3.age%type;
?? dif tt3.age%type :=20; -- 設(shè)置一個(gè)年齡差
begin
?? select age+dif into age from tt3 where id=1;
?? dbms_output.put_line(age);
end;
-------------------
declare
?? age tt3.age%type;
?? dif age%type :=21; -- 設(shè)置一個(gè)年齡差
begin
?? select age+dif into age from tt3 where id=1;
?? dbms_output.put_line(age);
end;
?
?
?
?select * from tt3 where id=1;
?
?
-- 不需要一個(gè)字段一個(gè)字段寫出來(lái)
declare
? my_user tt3%rowtype;
begin
?? select * into my_user from tt3 where id=1;
?? dbms_output.put_line( my_user.user_name );
end;
?
declare
? my_user tt3%rowtype;
? show_message varchar2(200);
begin
?? select * into my_user from tt3 where id=1;
?? show_message:= my_user.user_name || '住在' || my_user.city;
?? dbms_output.put_line( show_message );
end;
----------
declare
? my_user tt3%rowtype;
? show_message varchar2(200);
begin
?? select * into my_user from tt3 where id=1;
?? show_message:= my_user.user_name || '住在' || my_user.city||',年齡:'||my_user.age||'歲';
?? dbms_output.put_line( show_message );
end;
?
---------------
declare
? my_user tt3%rowtype;
? show_message varchar2(200);
? dif number :=20;
begin
?? select * into my_user from tt3 where id=1;
?? show_message:= my_user.user_name || '住在' || my_user.city||',年齡:'||my_user.age||'歲,二十年后'||(my_user.age+dif);
?? dbms_output.put_line( show_message );
end;
轉(zhuǎn)載于:https://www.cnblogs.com/wyj1212/p/8649163.html
總結(jié)
以上是生活随笔為你收集整理的ORACLE1.22 %type %rowtype的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 20165218 2017-2018-1
- 下一篇: 3-3 面向对象 本章总结