zoukankan      html  css  js  c++  java
  • Oracle PLSQL入门

    -- 有了SQL 为什么还需要PL/SQL

    -- SQL功能很强大,但如果是单1sql语句,没有流程控制

    -- PL/SQL 是什么?

    --不仅仅实现流程控制,同时保留SQL本身所有的功能

    --还提供变量、常量等支持

    --提供更多数据类型的支持

    --第一,学习PL/SQL块(有开头,有结尾,还有块之外)

    <script language=javascript>

      ...

    </script>

    int a = 3;

    int a = a+3;

          :=

    PL/SQL块的定义

    --声明

    declare 

    begin

      

      exception

        

    end;

    --------

    String userName = "小明";

    System.out.println();

    dbms   output  put_line

    变量的定义

    变量的赋值1

    变量的赋值2(通过查询把,结果赋值给变量,注意,必须是单条记录)

    create table t1(

       id number primary key,

       user_name varchar2(20)

    );

    insert into t1 values(1,'小军');

    commit

    select user_name from t1 where id=1

    常量的使用

    -- 会话session级别的变量

    -- 宿主变量

    create table tt3(

       id number primary key,

       user_name varchar2(20),

       city varchar2(20),

       is_java number,

       is_boy number,

       age number

    );

    insert into tt3 values(1,'小明','珠海',1,1,19);

    commit;

    ---

    declare

      show_name varchar2(100);

    begin

      select user_name||' '||city into show_name from tt3 where id=1;

      dbms_output.put_line(show_name);

    end;

    ---

    declare

      is_java number;

      age number;

      is_java_stu boolean;

      more_than_age boolean;

      xxx varchar2(100);

    begin

      select is_java,age into is_java,age from tt3 where id=1;

      is_java_stu:=  (is_java=1);

      more_than_age:= (age>18);

      if (is_java_stu and more_than_age ) then 

         select '是一个java程序员' into xxx from dual;

      else

         select '不招' into xxx from dual;    

      end if;

      dbms_output.put_line(xxx);  

    end;

  • 相关阅读:
    Firemonkey绑定对象列表
    Firemonkey 自定义Button的Style
    Delphi中使用GDI+进行绘图(2)
    Delphi中使用GDI+进行绘图(1)
    很好用的一个类:TJvAppXMLFileStorage
    我的Win32开发抉择,Delphi老将复出
    实现动态的XML文件读写操作
    一个简单的统计图像主颜色的算法(C#源代码)
    开始使用THREE.JS
    C++应用程序在Windows下的编译、链接(一)概述
  • 原文地址:https://www.cnblogs.com/sheying/p/8629196.html
Copyright © 2011-2022 走看看