Oracle 存储过程中的“ AS”和“ IS”有什么区别?

我看到 Oracle 过程有时使用“ AS”编写,有时使用“ IS”关键字编写。

CREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **AS**
...

对。

CREATE OR REPLACE Procedure TESTUSER.KILLINSTANCE (INSTANCEID integer) **IS**
...

这两者之间有什么区别吗?


编辑: 显然,两者之间没有功能上的区别,但是有些人遵循一个惯例,当 SP 是包的一部分时使用“ AS”,而当它不是包的一部分时使用“ IS”。或者反过来。切。

72023 次浏览

None whatsover. They are synonyms supplied to make your code more readable:

FUNCTION f IS ...

CREATE VIEW v AS SELECT ...

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;

Here's another difference (in 10g, at any rate)

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

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:

CREATE OR REPLACE PACKAGE SomePackage IS
TYPE packageTableType IS TABLE OF someRecordType;
END SomePackage;

Use of AS in the package yields the following error:

Error(2,30): PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: object opaque

"IS" and "AS" act as a synonym while creating procedures and packages but not for a cursor, table or view.

According to TutorialsPoint

The AS keyword is used instead of the IS keyword for creating a standalone procedure.

and considering previous answers,

I guess

AS is for stand alone (outside of any block, subprogram, package) entities

and

IS is for embedded (within a block, subprogram or package) entities.

.

The AS keyword is used instead of the IS keyword for creating a standalone function.

[ A standalone stored 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 different from a function that you declare and define in a PL/SQL block or package. ]

For more explanation, read this...