What is the difference between "AS" and "IS" in an Oracle stored procedure?

OracleStored ProceduresKeyword

Oracle Problem Overview


I see Oracle procedures sometimes written with "AS", and sometimes with "IS" keyword.

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?


Edit: Apparently, there is no functional difference between the two, but some people follow a convention to use "AS" when the SP is part of a package and "IS" when it is not. Or the other way 'round. Meh.

Oracle Solutions


Solution 1 - Oracle

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

FUNCTION f IS ...

CREATE VIEW v AS SELECT ...

Solution 2 - Oracle

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;

Solution 3 - Oracle

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

Solution 4 - Oracle

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

Solution 5 - Oracle

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.

.

Solution 6 - Oracle

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...

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIshmaeelView Question on Stackoverflow
Solution 1 - OracleTony AndrewsView Answer on Stackoverflow
Solution 2 - OracleNick PierpointView Answer on Stackoverflow
Solution 3 - OracleDileep KrishnamurthyView Answer on Stackoverflow
Solution 4 - OracleStuartLCView Answer on Stackoverflow
Solution 5 - OracleDániel SándorView Answer on Stackoverflow
Solution 6 - OraclePankaj ShivalkarView Answer on Stackoverflow