zoukankan      html  css  js  c++  java
  • Oracle %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; -- 设置一个年龄差
       age:= age + dif;
       dbms_output.put_line(age);
    end;
    ------------------------------
    declare
       age tt3.age%type;
       dif tt3.age%type :=20; -- 设置一个年龄差
    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; -- 设置一个年龄差
    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; -- 设置一个年龄差
    begin
       select age+dif into age from tt3 where id=1;
       dbms_output.put_line(age);
    end;
    
    
    
     select * from tt3 where id=1;
     
     
    -- 不需要一个字段一个字段写出来 
    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;
  • 相关阅读:
    【摘】DB2程序性能
    动态html标签textarea的readOnly属性(JavaScript)
    Html和Xml 文件中的特殊字符 需要转义【转】
    ping的通telnet不正常 服务器之间连接不稳定
    AJAX 和 JSP 10.5(转)实现进度条【转】
    RedHat上部署was7.0
    JPPF 在Windows Server 2008R2上的配置
    银联贷记卡账务账务计算说明
    mybatis源码分析
    使用Neo4j的apoc插件,实现数据从MySQL抽取到Neo4j
  • 原文地址:https://www.cnblogs.com/yuchne/p/12920758.html
Copyright © 2011-2022 走看看