Oracle 存储过程中的“AS”和“IS”有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/230348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between "AS" and "IS" in an Oracle stored procedure?
提问by Ishmaeel
I see Oracle procedures sometimes written with "AS", and sometimes with "IS" keyword.
我看到 Oracle 程序有时用“AS”编写,有时用“IS”关键字编写。
CREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **AS**
...
vs.
对比
CREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **IS**
...
Is there any difference between the two?
两者之间有什么区别吗?
编辑:显然,两者之间没有功能差异,但有些人遵循约定,当 SP 是包的一部分时使用“AS”,而当它不是时使用“IS”。或者反过来。嗯。
采纳答案by Tony Andrews
None whatsover. They are synonyms supplied to make your code more readable:
没有什么。它们是为使您的代码更具可读性而提供的同义词:
FUNCTION f IS ...
功能 f 是 ...
CREATE VIEW v AS SELECT ...
创建视图 v 作为选择 ...
回答by Nick Pierpoint
One minor difference...
一个细微的区别...
They are synonyms for packages and procedures, but not for cursors:
它们是包和过程的同义词,但不是游标的同义词:
This works...
这工作...
cursor test_cursor
is
select * from emp;
... but this doesn't:
……但这不是:
cursor test_cursor
as
select * from emp;
回答by Dileep Krishnamurthy
"IS" and "AS" act as a synonym while creating procedures and packages but not for a cursor, table or view.
“IS”和“AS”在创建过程和包时充当同义词,但不是游标、表或视图的同义词。
回答by StuartLC
Here's another difference (in 10g, at any rate)
这是另一个区别(无论如何都是 10 克)
Given a loose object type:
给定一个松散的对象类型:
CREATE TYPE someRecordType AS OBJECT
(
SomeCol VARCHAR2(12 BYTE)
);
You can create a loose
Table type of this object type with either AS
or IS
您可以loose
使用AS
或创建此对象类型的表类型IS
CREATE OR REPLACE TYPE someTableType
IS {or AS} TABLE OF someRecordType;
However, if you create this same table type within a package, you must use IS
:
但是,如果您在包中创建相同的表类型,则必须使用IS
:
CREATE OR REPLACE PACKAGE SomePackage IS
TYPE packageTableType IS TABLE OF someRecordType;
END SomePackage;
Use of AS
in the package yields the following error:
使用AS
在包装产生以下错误:
Error(2,30): PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: object opaque
错误(2,30):PLS-00103:在预期以下情况之一时遇到符号“TABLE”:对象不透明
回答by Dániel Sándor
According to TutorialsPoint
The AS keyword is used instead of the IS keyword for creating a standalone procedure.
使用 AS 关键字代替 IS 关键字来创建独立过程。
and considering previous answers,
并考虑以前的答案,
I guess
我猜
AS
is for stand alone (outside of any block, subprogram, package) entities
AS
用于独立(在任何块、子程序、包之外)实体
and
和
IS
is for embedded (within a block, subprogram or package) entities.
IS
用于嵌入(在块、子程序或包内)实体。
.
.
回答by Pankaj Shivalkar
The ASkeyword is used instead of the ISkeyword for creating a standalone function.
使用AS关键字代替IS关键字来创建独立函数。
[ A standalonestored function is a function (a subprogram that returns a single value) that is stored in the database. Note: A standalone stored function that you create with the CREATE FUNCTION statement is differentfrom a function that you declare and define in a PL/SQL block or package. ]
[独立存储函数是存储在数据库中的函数(返回单个值的子程序)。注意:您使用 CREATE FUNCTION 语句创建的独立存储函数与您在 PL/SQL 块或包中声明和定义的函数不同。]
For more explanation, read this...
有关更多解释,请阅读此...