search
HomeDatabaseMysql TutorialOracle的PLS-00231 错误分析

Oracle的PLS-00231 错误分析 ,这个错误一般是函数的访问权限导致的,在包头声明为共有函数则全票通过,在包体声明的话位死于函数

Oracle的PLS-00231 错误分析 ,这个错误一般是函数的访问权限导致的,在包头声明为共有函数则全票通过,在包体声明的话位死于函数会导致错误。
 
create or replace function Two
      return Number
      is
      begin
        return 2;
      end Two;
 create or replace  procedure PrintTwo
      is
        myNum Number;
      begin
      select Two()
      into myNum
      from dual;
      dbms_output.put_line(myNum);
    end PrintTwo;
 以上函数和过程,放在函数和过程中声明,调用正常。注意two函数被printtwo过程以sql语句形式调用。
 
若将此二程序段放入一个package中,函数私有方式,则包体编译时出错,报pls-00231错误,函数不能在sql语句中使用之类。
 
原因为何?
 
pl sql和sql对于oracel而言,是两个不同的引擎,因而对于sql引擎而言,plsql包中私有的two函数,是无法发现的。
 
所以包中使用two函数,方法有两种:
 
1 在包头声明中声明two函数,即将two函数作公有声明,此时可以select two into mynum from dual;形式调用,当然这样将无法隐藏two函数。
 
2 以mynum:=two;方式调用,由于此种方式以pl sql引擎解析,所以可以正常使用以私有方式声明的two函数。
 
可见需以合适的方式将two函数暴露给sql或plsql引擎方可使用。那么若不将two作公有声明,而用包名.two方式调用,不一样可定位到two函数?哦当然不行,你忘了two未作公有声明,在包外无论如何都是不可见的哈哈。
 

那么对于包内一个返回集合类型的函数,,如:FUNCTION strsplit(p_list IN VARCHAR2, p_sep IN VARCHAR2 DEFAULT '|')
    RETURN str_split
    PIPELINED;
 
str_split为一个自定义集合类型:
 
 TYPE "STR_SPLIT" IS TABLE OF VARCHAR2 (4000);
 
此时,无论将type str_split以公有,或私有方式 在包中声明,均无法正常使用sql方式调用,由于返回为集合,也不能用plsql的kkk:=str_split方式调用。此时,只能将str_split定义为oracle的自定义数据类型:
 
create or replace TYPE "STR_SPLIT" IS TABLE OF VARCHAR2 (4000)
 
然后去除包内公有或私有的type str_split定义,即可使用sql方式调用函数。

本文永久更新链接地址:

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL BLOB : are there any limits?MySQL BLOB : are there any limits?May 08, 2025 am 12:22 AM

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

MySQL : What are the best tools to automate users creation?MySQL : What are the best tools to automate users creation?May 08, 2025 am 12:22 AM

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

MySQL: Can I search inside a blob?MySQL: Can I search inside a blob?May 08, 2025 am 12:20 AM

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc

MySQL String Data Types: A Comprehensive GuideMySQL String Data Types: A Comprehensive GuideMay 08, 2025 am 12:14 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,idealforconsistentlengthdatalikecountrycodes;2)VARCHARforvariable-lengthstrings,suitableforfieldslikenames;3)TEXTtypesforlargertext,goodforblogpostsbutcanimpactperformance;4)BINARYandVARB

Mastering MySQL BLOBs: A Step-by-Step TutorialMastering MySQL BLOBs: A Step-by-Step TutorialMay 08, 2025 am 12:01 AM

TomasterMySQLBLOBs,followthesesteps:1)ChoosetheappropriateBLOBtype(TINYBLOB,BLOB,MEDIUMBLOB,LONGBLOB)basedondatasize.2)InsertdatausingLOAD_FILEforefficiency.3)Storefilereferencesinsteadoffilestoimproveperformance.4)UseDUMPFILEtoretrieveandsaveBLOBsco

BLOB Data Type in MySQL: A Detailed Overview for DevelopersBLOB Data Type in MySQL: A Detailed Overview for DevelopersMay 07, 2025 pm 05:41 PM

BlobdatatypesinmysqlareusedforvoringLargebinarydatalikeImagesoraudio.1) Useblobtypes (tinyblobtolongblob) Basedondatasizeneeds. 2) Storeblobsin Perplate Petooptimize Performance.3) ConsidersxterNal Storage Forel Blob Romana DatabasesizerIndimprovebackupupe

How to Add Users to MySQL from the Command LineHow to Add Users to MySQL from the Command LineMay 07, 2025 pm 05:01 PM

ToadduserstoMySQLfromthecommandline,loginasroot,thenuseCREATEUSER'username'@'host'IDENTIFIEDBY'password';tocreateanewuser.GrantpermissionswithGRANTALLPRIVILEGESONdatabase.*TO'username'@'host';anduseFLUSHPRIVILEGES;toapplychanges.Alwaysusestrongpasswo

What Are the Different String Data Types in MySQL? A Detailed OverviewWhat Are the Different String Data Types in MySQL? A Detailed OverviewMay 07, 2025 pm 03:33 PM

MySQLofferseightstringdatatypes:CHAR,VARCHAR,BINARY,VARBINARY,BLOB,TEXT,ENUM,andSET.1)CHARisfixed-length,idealforconsistentdatalikecountrycodes.2)VARCHARisvariable-length,efficientforvaryingdatalikenames.3)BINARYandVARBINARYstorebinarydata,similartoC

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function