Re: procedure & function inside packages

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: Fri, 18 Apr 2008 12:49:44 -0700 (PDT)
Message-ID: <1e7fd88d-a3ea-4be8-b6df-88f72c4b52ca@m44g2000hsc.googlegroups.com>


On Apr 18, 2:08 pm, chris <lazyboy..._at_yahoo.com> wrote:
> Hi All,
>
> I'm a new learner in pl/sql & trying to write a small basic pkg which
> includes both functions & procedures.  could you take a look & tell me
> where I'm doing wrong & how to fix it? Appreciate your helps/
> suggestions.
>
> CREATE OR REPLACE PACKAGE job_pkg IS
>       g_jobid    VARCHAR2(50) := upper('dba');
>       g_jobname  VARCHAR2(50)  := upper('app analyst ');
>       PROCEDURE  add_job (g_jobid VARCHAR2, g_jobname VARCHAR2);
> END job_pkg;
> /
>
> CREATE OR REPLACE PACKAGE BODY job_pkg IS
>       FUNCTION get_job (jobid IN jobs.job_id%TYPE) RETURN boolean IS
>       BEGIN
>             SELECT job_id INTO jobid FROM jobs WHERE job_id = jobid;
>             RETURN jobid;
>       END get_job;
>
>       PROCEDURE add_job
>             (g_jobid   IN jobs.job_id%TYPE,
>              g_jobname IN jobs.job_title%TYPE)
>       IS
>       BEGIN
>             IF get_job(g_jobid) THEN
>                 DBMS_OUTPUT.PUT_LINE ('Job Id: ' || g_jobid || 'already exist in
> DB.');
>             ELSIF get_job(g_jobid) IS NULL THEN
>                 DBMS_OUTPUT.PUT_LINE (' Please re-run program with provided info.');
>             ELSE
>                 INSERT INTO jobs (job_id, job_title)
>                 VALUES (g_jobid, g_jobname);
>             END IF;
>       END add_job;
> END;
>
> TIA,
> -Chris

What errors are you getting when you try to create the package?

HTH -- Mark D Powell -- Received on Fri Apr 18 2008 - 14:49:44 CDT

Original text of this message