473,414 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,414 developers and data experts.

PL/SQL-PACKAGE - 3

debasisdas
8,127 Expert 4TB
USE OF REF-CURSOR IN THE PACKAGE
================================
PACKAGE
-----------------
Expand|Select|Wrap|Line Numbers
  1. create or replace package pack1
  2. as
  3. type mycur is ref cursor;
  4. end;
Note :--since the package does not contain any procedure or functions it not required to create the package body.
----------------------------
USING THE (GLOBAL) REFCURSOR IN A PROCEDURE
---------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. create or replace procedure testproc
  2. (
  3. no emp.deptno%type,
  4. rec out pack1.mycur
  5. )
  6. is
  7. begin
  8. open rec for select * from emp where deptno=no;
  9. end ;
--------------------------------
CALLING THE PROCEDURE FROM ANNONYMOUS BLOCK
==============================================
Expand|Select|Wrap|Line Numbers
  1. declare
  2. mm pack1.mycur;
  3. ll emp%rowtype;
  4. begin
  5. testproc(10,mm);
  6. loop
  7. fetch mm into ll ;
  8. exit when mm%notfound;
  9. DBMS_OUTPUT.PUT_LINE(ll.empno||' ' ||ll.ename);
  10. end loop;
  11. end;
FUNCTION OVERLOADING IN PACKAGE.
=================================
package
----------------
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE PKG_OVRLD
  2. AS
  3. FUNCTION TRANS_DATE(DT IN DATE)RETURN  NUMBER;
  4. FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE;
  5. END PKG_OVRLD;
package body
------------------------
Expand|Select|Wrap|Line Numbers
  1. CREATE OR REPLACE PACKAGE BODY PKG_OVRLD AS
  2.  
  3. FUNCTION TRANS_DATE(DT IN DATE)RETURN  NUMBER IS
  4. BEGIN
  5. RETURN ROUND((DT-TO_DATE('01011970','MMDDYYYY'))*86400);
  6. END TRANS_DATE;
  7.  
  8. FUNCTION TRANS_DATE(DT IN NUMBER)RETURN DATE IS
  9. BEGIN
  10. RETURN (TO_DATE('01011970','MMDDYYYY') +(DT/(86400)));
  11. END TRANS_DATE;
  12.  
  13. END PKG_OVRLD;
  14.  

Also check PACKAGE - 4
Jun 8 '07 #1
0 3164

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: cooldv | last post by:
i am running a website on Windows 2000 server with ASP 3 webpages and Access 2000 database. (with a hosting company) traffic is slow at this time but expect to grow. lately i have been reading...
2
by: Peter | last post by:
I run most of my SQL scripts via kornshell on AIX. I use the "here-document" to run some of the smaller ones. Example: #!/bin/ksh # Analyze the table. sqlplus...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
10
by: Dagwood | last post by:
Good morning: At least it's morning where I am. :) I have a rather newbie question I'm afraid. I have VisualStudio.NET, and have installed it along with SQL server. However I can't seem to...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
6
by: Fuzzydave | last post by:
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are...
14
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can...
5
by: dbrother | last post by:
Access 2003 Win XP Pro SP3 Using SQL /ADO Recordsets in a Do Loop Hello, I'm using a random number generator based on an integer input from a user from a form that will get X number of random...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.