`
youwensa
  • 浏览: 1901 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论

mysql存储过程读书笔记2(control and conditional logic)

 
阅读更多

1. If

create procedure example3(stu_id int)
begin
    declare stu_name varchar(30);
 
     select name into stu_name from student where student_id = stu_id;
     If stu_name is not null Then
         select stu_name;
     End If;
End;

 

2. If ... Else....

create procedure example4(stu_id int)
begin
     declare stu_name varchar(30);
 
      select name into stu_name from student where student_id = stu_id;
      If stu_name is not null Then
                select stu_name;
       Else
                 select 'student is not exist';
       End If;
End;

 

3. IF ... ELSEIF ... ELSE ... END;

drop procedure if exists discounted_price;
create procedure discounted_price(normal_price numeric(8,2), OUT discount_price numeric(8,2))
Begin
    IF (normal_price) > 500 Then
        SET discount_price = normal_price * 0.8;
    ElseIF (normal_price > 400) Then
        SET discount_price = normal_price * 0.9;
    Else
         SET discount_price = normal_price;
     End If;
End

 

4. Loop

 

drop procedure if exists simple_loop;
create procedure simple_loop()
begin
 DECLARE counter int;
 SET counter = 0;
 
 my_simple_loop: LOOP
  IF counter = 10 Then
   LEAVE my_simple_loop;
  END IF;
  
  SET counter = counter + 1;
 END LOOP my_simple_loop;
 
 select ' now counter is 10';
END

分享到:
评论

相关推荐

    axurePR7.0教程 第九章 9.1 Axure条件逻辑详解 Conditional Logic.

    交互和条件逻辑 INTERACTIONS AND CONDITIONAL LOGIC 条件逻辑 Conditional Logic 允许你创建条件表达式,在用例编辑器的顶部(第一步.用例说明)右侧,点击新增条件,打开条件生成器对话框。条件生成器允许你创建...

    MySql存储过程编程.chm

    Conditional Control Section 4.3. Iterative Processing with Loops Section 4.4. Conclusion Chapter 5. Using SQL in Stored Programming Section 5.1. Using Non-SELECT SQL in Stored Programs ...

    Marginal and conditional distributions of multivariate.zip

    标题“Marginal and conditional distributions of multivariate.zip”暗示我们将探讨的是多元高斯分布中的边际分布和条件分布。这两个概念在理解变量间的独立性和依赖性方面扮演着重要角色。 **边际分布**: 在...

    Fuzzy Control Systems

    Chapter 2—Towards a Unified Theory of Intelligent Autonomous Control Systems 1 Introduction 2 State of the Art and Future Challenges 2.1 Three views of what are the most important robotic ...

    Log-linear models and conditional random fields

    作者:Elkan, Charles 摘要:Log-linear models are a far-reaching extension of logistic regression, while con- ditional random fields (CRFs) are a special case of log-linear models suitable for so-...

    Java.SE.7.Programming.Essentials

    Using Java Operators and Conditional Logic Chapter 4. Using Java Arrays Chapter 5. Using Loops in Java Code Chapter 6. Encapsulating Data and Exposing Methods in Java Chapter 7. Using Java ...

    FME函数介绍

    - **Conditional Logic**:根据条件执行不同的逻辑分支。 **3. 数据质量检查** - **Validation Checks**:提供数据完整性和一致性的检查功能。 - **Error Handling**:支持错误处理机制,确保转换过程的稳定性和...

    Conditional Branch Logger v1.0 by Blabberer / dELTA / Kayaker

    Conditional Branch Logger is a plugin which gives control and logging capabilities for conditional branch instructions over the full user address space of a process. Useful for execution path analysis...

    The.Language.of.SQL.2nd.Edition.0134658256

    Chapter 8 Conditional Logic Chapter 9 Summarizing Data Chapter 10 Subtotals and Crosstabs Chapter 11 Inner Joins Chapter 12 Outer Joins Chapter 13 Self Joins and Views Chapter 14 Subqueries Chapter 15...

    IPC 读书笔记及测试程序

    2. **FIFO(First-In-First-Out,先进先出)**: FIFO,也称为命名管道,是全双工的通信方式,与无名管道相比,它可以连接两个没有亲缘关系的进程。通过在文件系统中创建一个特殊类型的文件来实现,进程通过打开这...

    Conditional BuildStep Plugin 1.3.3

    Conditional BuildStep Plugin 1.3.3 HPI

    SpringBoot中使用@Conditional示例代码

    在Spring Boot框架中,`@Conditional`注解是条件装配的核心工具,它允许我们基于某些条件来决定是否加载或注册一个Bean。这个功能使得我们能够更精细化地控制应用的配置,仅在满足特定条件时才会激活某个Bean。下面...

    Conditional Random Fields

    标题“Conditional Random Fields”和描述“Conditional-Random-Fields-Probabilistic-Models-for-Segmenting-and-Labeling-Sequence-Data”共同指向的知识点是条件随机场(CRF)模型,这种模型在计算机科学领域中...

    @Conditional注解应用.rar

    在Java Spring框架中,`@Conditional`注解是实现条件化bean注入的关键工具。这个注解允许我们在配置bean时设置一些条件,只有当这些条件满足时,对应的bean才会被Spring容器实例化并注入到应用程序中。这样的设计极...

    spring里@Conditional注解使用示例代码

    在Spring框架中,`@Conditional`注解是一个强大的特性,它允许我们有条件地加载bean,也就是说,只有当特定条件满足时,对应的bean才会被Spring容器实例化并注册。这个注解是Spring Boot的一个核心功能,使得我们...

    Learning SQL.rar_Sql queries_learning sql_objects

    内容如下: 1.The history of the computerized database 2.SQL Data Statements--those used to create, manipulate, and retrieve data stored in your ...7.How conditional logic can be used in Data Statements

    Generalized autoregressive conditional heteroskedasticity.pdf

    \[ \sigma_t^2 = \omega + \alpha_1 \varepsilon_{t-1}^2 + \alpha_2 \varepsilon_{t-2}^2 + ... + \alpha_p \varepsilon_{t-p}^2 \] 其中,\(\sigma_t^2\) 表示t时刻的条件方差,\(\varepsilon_t\) 是随机扰动项,...

    Struts1_Logic标签官方API

    The "struts-logic" tag library contains tags that are useful in managing conditional generation of output text, looping over object collections for repetitive generation of output text, and ...

    js-conditional-compile-loader-1.0.15.tgz

    【js-conditional-compile-loader 1.0.15】是一个专为JavaScript代码条件编译设计的加载器,用于处理项目中的环境特定代码。在软件开发中,有时我们需要根据不同的运行环境(例如开发、测试和生产)来编译不同的代码...

Global site tag (gtag.js) - Google Analytics