ITPub博客

首页 > 数据库 > Oracle > pl/sql中的注释

pl/sql中的注释

Oracle 作者:stotf 时间:2018-10-16 23:58:15 0 删除 编辑

一、注释分为单行注释和多行注释两种。

    1.单行注释使用“--”。

        DECLARE

        howmany NUMBER;

        num_tables NUMBER;

        BEGIN

        -- Begin processing

        SELECT COUNT(*) INTO howmany

        FROM USER_OBJECTS

        WHERE OBJECT_TYPE = 'TABLE';     -- Check number of tables

        num_tables := howmany; -- Compute another value

        END;

    2.多行注释以“/*”开始,“*/”结尾。

        DECLARE

        some_condition BOOLEAN;

        pi NUMBER := 3.1415926;

        radius NUMBER := 15;

        area NUMBER;

        BEGIN

        /* Perform some simple tests and assignments */

        IF 2 + 2 = 4 THEN

        some_condition := TRUE;

        /* We expect this THEN to always be performed */

        END IF;

        /* This line computes the area of a circle using pi,

        which is the ratio between the circumference and diameter.

        After the area is computed, the result is displayed. */

        area := pi * radius**2;

        DBMS_OUTPUT.PUT_LINE('The area is: ' || TO_CHAR(area));

        END;

二、使用注释需要注意点

    1.多行注释不能进行嵌套,如下面是错误的:

         /*

        IF 2 + 2 = 4 THEN

        some_condition := TRUE;

        /* We expect this THEN to always be performed */

        END IF;

        */

    2.多行注释里面可以嵌套单行注释:

        /*

        IF 2 + 2 = 4 THEN

        some_condition := TRUE;

        -- We expect this THEN to always be performed

        END IF;

        */


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31557103/viewspace-2216639/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2018-10-05

  • 博文量
    8
  • 访问量
    18252