Re: Question on Package Variables
Date: Thu, 24 Jan 2008 05:46:15 -0800 (PST)
On Jan 24, 2:37 pm, Galen Boyer <galen_bo..._at_yahoo.com> wrote:
> CREATE OR REPLACE PACKAGE p_tst
> v_var int := 1;
> SQLPLUS> select p_tst.v_var from dual;
> The above fails with an error of p_tst not a function (or something to
> that affect).
> Is this based on the variable only being available in the PLSQL engine
> and not available in SQL or something else?
> Galen Boyer
First of all : You can't call procedures in a select.
Functions are thingies that return something, until Bill Gates misused
the procedure concept in T-SQL to return a cursor as if it where a
Procedures don't return anything except for OUT parameters. Programming Fundamentals 101, lesson 1.
You can't access PL/sql variables outside pl/sql even if they are in a package spec. You'll need a (guess what) *function* to return them. So the proper method to use PL/sql flags (or anything similar) is create or replace package util is
procedure set_flag(i in number);
function get_flag returns number;
create or replace package body util is
procedure set_flag(i in number) is
flag := i;
function get_flag returns number is
Would that be in any Steven Feuerstein book. I bet it is!!!
-- Sybrand Bakker Senior Oracle DBAReceived on Thu Jan 24 2008 - 07:46:15 CST