All of the following works without a problem on 8i (8.1.7). However, I need it to work in our 8.0.5 database.
Function Prototype in package header:
FUNCTION Return_Factor
( Date_One DATE,
Date_Two DATE,
Date_Compare DATE,
Compare_type VARCHAR2 )
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES ( Return_Factor, WNDS );
Function Definition in package body:
CREATE OR REPLACE FUNCTION Return_Factor
( Date_One IN DATE,
Date_Two IN DATE,
Date_Compare IN DATE,
Compare_type IN VARCHAR2 )
RETURN NUMBER
AS
gl_Between VARCHAR(20) := 'BETWEEN';
gl_Less VARCHAR(20) := '<';
gl_Equal VARCHAR(20) := '=';
gl_Greater VARCHAR(20) := '>';
gl_LessEqual VARCHAR(20) := '<=';
gl_GreaterEqual VARCHAR(20) := '>=';
BEGIN
IF Compare_type = gl_Between AND Date_Compare BETWEEN Date_one AND Date_two THEN
RETURN 1;
ELSIF Compare_type = gl_Less AND Date_Compare < Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_Equal AND Date_Compare = Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_Greater AND Date_Compare > Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_LessEqual AND Date_Compare <= Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_GreaterEqual AND Date_Compare >= Date_one THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
RETURN 0;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
As you can see there is no updating of the database, it merely examines the variables and returns a 0/1. When I run this code calling the function to update the database it gives the error that it violates its associated pragma.
When I take the function out of the package it compiles and runs but does not do what it is supposed to.
When I run in 8i it works perfectly, even without the pragma. In 8.0.5 it will not compile without the pragma.
You guys are GREAT! I have always found everyone to be a wealth of information. Thanks.
Function Prototype in package header:
FUNCTION Return_Factor
( Date_One DATE,
Date_Two DATE,
Date_Compare DATE,
Compare_type VARCHAR2 )
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES ( Return_Factor, WNDS );
Function Definition in package body:
CREATE OR REPLACE FUNCTION Return_Factor
( Date_One IN DATE,
Date_Two IN DATE,
Date_Compare IN DATE,
Compare_type IN VARCHAR2 )
RETURN NUMBER
AS
gl_Between VARCHAR(20) := 'BETWEEN';
gl_Less VARCHAR(20) := '<';
gl_Equal VARCHAR(20) := '=';
gl_Greater VARCHAR(20) := '>';
gl_LessEqual VARCHAR(20) := '<=';
gl_GreaterEqual VARCHAR(20) := '>=';
BEGIN
IF Compare_type = gl_Between AND Date_Compare BETWEEN Date_one AND Date_two THEN
RETURN 1;
ELSIF Compare_type = gl_Less AND Date_Compare < Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_Equal AND Date_Compare = Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_Greater AND Date_Compare > Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_LessEqual AND Date_Compare <= Date_one THEN
RETURN 1;
ELSIF Compare_type = gl_GreaterEqual AND Date_Compare >= Date_one THEN
RETURN 1;
ELSE
RETURN 0;
END IF;
RETURN 0;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
As you can see there is no updating of the database, it merely examines the variables and returns a 0/1. When I run this code calling the function to update the database it gives the error that it violates its associated pragma.
When I take the function out of the package it compiles and runs but does not do what it is supposed to.
When I run in 8i it works perfectly, even without the pragma. In 8.0.5 it will not compile without the pragma.
You guys are GREAT! I have always found everyone to be a wealth of information. Thanks.