plsql包中的规范-为什么需要 [英] Spec in plsql package - why its required

查看:80
本文介绍了plsql包中的规范-为什么需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我,为什么在Oracle PL/SQL中需要打包Spec. 无论如何,程序包主体具有规范中的所有信息.

Can someone tell me, why we package Spec is required in oracle PL/SQL. anyway the package body has all the information as spec.

推荐答案

将程序包规范与程序包主体分离是PL/SQL等语言设计的根本重要组成部分.这是PL/SQL允许您使用封装原理的方式.

The separation of package Specification from the package Body is a fundamentally important part of the design of languages such as PL/SQL. It's the way that PL/SQL allows you to use the principle of Encapsulation.

规范"是您指定程序包公共"部分的方式,即其他程序单元或外部调用者应可访问的功能,过程,类型和常量.

The Specification is the way you specify the Public portion of the package, that is, the functions, procedures, types and constants that should be accessible by other program units or external callers.

Body不仅封装了实现细节,而且还允许您创建私有的函数和过程;也就是说,它们只能由同一程序包中的其他函数和过程使用,而不能由外部调用程序调用.

The Body not only encapsulates the implementation details, but also allows you to create functions and procedures that are Private; that is, they are only allowed to be used by other functions and procedures in the same package, and cannot be called by external callers.

封装带来了许多好处-包括自我说明:如果某个方法是私有的,则可以保证除了在同一个程序包之内之外,不会对其进行任何调用-因此,您可以自由地对其进行更改,并确保知识安全这样您所做的更改至少不会破坏使用该程序包的任何其他系统.

Encapsulation brings a number of benefits - including self-documentation: if a method is Private, you are guaranteed that there will be no calls to it except within the same package - so you are free to change it, secure in the knowledge that your change will at least not break any other system that uses the package.

包可用作API.然后,该规范就成为设计和打算由系统中其他代码调用的功能和过程的文档.

Packages are useful as APIs; the specification then becomes the documentation of which functions and procedures are designed and intended to be called by other code in the system.

这篇关于plsql包中的规范-为什么需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆