Oracle PL/SQL脚本中的这个斜杠字符是错误吗?

Oracle PL/SQL脚本中的这个斜杠字符是错误吗?,oracle,plsql,Oracle,Plsql,我正在为我的公司整理一系列用Oracle PL/SQL编写的SQL脚本。我偶然发现一个基本脚本,底部有一个奇怪的斜线。它以这种方式检入CVS。这是一个纯粹的语法错误还是有一些我不知道的功能。稍微模糊的脚本: set serveroutput on size 2000; --PL/SQL block to link ISSN in serial base on a company's ISSN text file declare cursor ItemCursor is

我正在为我的公司整理一系列用Oracle PL/SQL编写的SQL脚本。我偶然发现一个基本脚本,底部有一个奇怪的斜线。它以这种方式检入CVS。这是一个纯粹的语法错误还是有一些我不知道的功能。稍微模糊的脚本:

set serveroutput on size 2000;
--PL/SQL block to link ISSN in serial base on a company's ISSN text file

declare
    cursor ItemCursor is
        select issn is2 from web.obfuscated1 where issn is not null
            union
        select eissn is2 from web.obfuscated1 where eissn is not null;

    cursor ItemCursor1(aIS varchar2) is
        select obfuscated1_uid from web.obfuscated1 where group_num is null and issn in (
            select distinct issn from web.obfuscated1 where issn = aIS or eissn = aIS
                union
            select distinct eissn from web.obfuscated1 where issn = aIS or eissn = aIS
        )
            union
        select obfuscated1_uid from web.obfuscated1 where eissn in (
            select distinct issn from web.obfuscated1 where issn = aIS or eissn = aIS
                union
            select distinct eissn from web.obfuscated1 where issn = aIS or eissn = aIS
        );

    cursor ItemCursor2(aIS9 varchar2) is
        select obfuscated1_uid from web.obfuscated1 where issn in (
            select distinct issn from web.obfuscated1 where issn = aIS9 or eissn = aIS9
                union
            select distinct eissn from web.obfuscated1 where issn = aIS9 or eissn = aIS9
        ) and group_num is null;

    agroup      number(8);
    processCount    number(8);

    ------------------------------------------------------
    -- MAIN BLOCK -----------------------------------
    -------------------------------------------------
begin
    processCount := 0;

    agroup := null;
    for itemRec in ItemCursor loop
        agroup := null;
        begin
            select group_num into agroup from web.obfuscated1 where issn in (
                select distinct issn from web.obfuscated1 where issn = itemRec.is2 or eissn = itemRec.is2
                    union
                select distinct eissn from web.obfuscated1 where issn = itemRec.is2 or eissn = itemRec.is2
            ) and group_num is not null and issn is not null and eissn is not null and rownum <= 1;

        exception
            when no_data_found then
                agroup := null;
            when others then
                agroup := null;
        end;

        if agroup is not null then
            for itemRec2 in ItemCursor2(itemRec.is2) loop
                update web.obfuscated1 set group_num = agroup where obfuscated1_uid = itemRec2.obfuscated1_uid;
                commit;
            end loop;
        else
            processCount := processCount + 1;
            for itemRec1 in ItemCursor1(itemRec.is2) loop
                update web.obfuscated1 set group_num = processCount where obfuscated1_uid = itemRec1.obfuscated1_uid;
                commit;
            end loop;
            commit;
        end if;
    end loop;

    dbms_output.put_line('Total record read: ' || processCount);
exception
    when others then
        dbms_output.put_line('ORA' || sqlcode);
        dbms_output.put_line(substr(sqlerrm, 1, 255));
        dbms_output.put_line('ORA- Error during processing ' );
    end;
/
exit;

最后的/是告诉解释器执行加载的脚本

基本上,您可以先键入stuff,然后键入/刚键入的内容将执行斜杠:

执行最近执行的 SQL命令或PL/SQL块 存储在SQL缓冲区中。你可以 在命令处输入斜杠/号 提示或在 多行命令。斜杠命令 函数类似于RUN,但确实如此 不列出该命令


这不是一个错误。它执行脚本

当您将各种脚本连接到一个文件中,并希望在执行下一个任务之前先执行每个单独的任务时,这非常有用

ie创建函数 / 创建使用该函数的存储过程


如果没有斜杠,存储过程可能会创建错误,也可能无法创建。

斜杠和出口都让我怀疑您应该从SQLPLUS运行此脚本。如果您试图以其他方式将其提交给Oracle,则可能会出现错误。那样的话,就把这两个都扔掉吧

使用Oracle时,您可以混合使用 三种不同的语法

SQL PL/SQL sqlplus命令行客户端 sqlplus可以执行/处理SQL 和PL/SQL 将语句发送到DB服务器。而sqlplus命令由sqlplus本身解释

分号; 不是SQL的一部分 语法和sqlplus将其识别为SQL的结尾 陈述而对于PL/SQL 它是语法的一部分,必须明确地告诉sqlplus语句在这里结束,并且应该使用斜杠执行

其他sqlplus命令是EXIT、DEFINE和VARIABLE 打印 设置除设置角色之外的其他角色

另一方面,例如Toad识别PL/SQL的结尾 当它看到空行时阻塞