The register_student and Update student procedures are grouped together in a package
Oracle and Expert Systems Technology
Show Based on my personal DBA experience, I highly recommend that you store all SQL in packages in you have enough shared_pool memory. Storing SQL in packages has several benefits. It ensures that all SQL is uniform and reusable, and it makes the SQL "pin-able". To prevent paging, packages can be marked as nonswappable. Marking a package as nonswappable tells a database that after the package is initially loaded into the shared pool, the package must always remain in memory. This procedure is sometimes called pinning or memory fencing. Oracle provides a procedure called dbms_shared_pool.keep to pin a package, and packages can be unpinned with dbms_shared_pool.unkeep. Only packages can be pinned. Stored procedures cannot be pinned unless they are placed into a package. The choice of whether to pin a package in memory is a function of the size of the object and the frequency of its use. Very large packages that are called frequently might benefit from pinning, but any difference might go unnoticed because the frequent calls to the procedure have kept it loaded into memory anyway. Therefore, because the object never pages out in the first place, pinning has no effect. Also, the way procedures are grouped into packages can have some influence. Some Oracle DBAs identify high-impact procedures and group them into a single package, and then pin this package in the shared pool library cache. In an ideal world, the shared_pool parameter of the init.ora should be large enough to accept every package, stored procedure, and trigger that can be used by the applications. However, reality dictates that the shared pool cannot grow indefinitely, and wise choices must be made in terms of which packages are pinned. Unix users might want to add code to their database startup script ensure that the packages are re-pinned after each database startup, guaranteeing that all packages are re-pinned with each bounce of the box. A script might look like this: ORACLE_SID=mydata EXECUTE dbms_shared_pool.keep('DBMS_ALERT'); exit; The database administrator also needs to remember to run pin.sqlwhenever restarting a database. This is done by reissuing the PIN command from inside SQL*DBA immediately after the database has been restarted. If you have large procedures or large anonymous PL/SQL blocks in your application, you may also want to put these into packages and pin them in the shared pool. You can determine what large stored objects are in the shared pool by selecting from the v$db_object_cache fixed view. This will also tell you which objects have been marked kept. This can be done with the following query: select * from v$db_object_cache where sharable_mem > 10000; If you have plenty of free memory in the shared pool and you wish to mark all packages in the system 'kept', you can execute the following PL/SQL snippet: declare cursor pkgs is select begin open pkgs; end; Now, let's look at how we can identify packages that should be pinned. If you like Oracle tuning, see the book "Oracle Tuning: The Definitive Reference", with 950 pages of tuning tips and scripts. You can buy it direct from the publisher for 30%-off and get instant access to the code depot of Oracle tuning scripts. I am new to creating packages. I have 2 functions and 1 procedure. They all work individually and compile with no errors. When I throw them together in a package I get the error, "Encountered the create symbol" referencing the create used for the package body. Can anybody explain to me what I am doing wrong?
asked May 2, 2015 at 20:06
1 You need to terminate the
If you're running the code from SQLDeveloper, you should choose the "Run as script" option. This thread gives an in-depth explanation about when/why the slash is required.
answered May 2, 2015 at 22:57
Mick MnemonicMick Mnemonic 7,7182 gold badges25 silver badges30 bronze badges What is the difference between procedure and package?A package is a group of related procedures and functions, together with the cursors and variables they use, stored together in the database for continued use as a unit. Similar to standalone procedures and functions, packaged procedures and functions can be called explicitly by applications or users.
What are stored functions procedures and packages?Stored Procedures and Functions
To execute a stored procedure or function, you only need to include its object name. Procedures and functions that are created outside of a package are called stored or standalone subprograms. Procedures and functions defined within a package are known as packaged subprograms.
How can we create procedure inside package in Oracle?Procedure. In the Data Project Explorer, right-click the PL/SQL Packages folder in a project, and click New > PL/SQL Package. ... . Complete the steps of the wizard. ... . In the specification, add the stored procedure name and variables. ... . Click the Body tab and edit the PL/SQL package body, to add the stored procedure.. What is package specification and package body in Oracle?The specification is the interface to the package. It declares the types, variables, constants, exceptions, cursors, and subprograms that can be referenced from outside the package. The body defines the queries for the cursors and the code for the subprograms.
|