0
I’m creating a package dynamically:
DECLARE
vpackageletras VARCHAR2(2000);
vvalorpossuia VARCHAR2(10);
vvalorpossuib VARCHAR2(10);
BEGIN
IF letras.possuia THEN
vvalorpossuia := 'TRUE';
ELSE
vvalorpossuia := 'FALSE';
END IF;
IF letras.possuib THEN
vvalorpossuib := 'TRUE';
ELSE
vvalorpossuib := 'FALSE';
END IF;
vpackageletras := 'CREATE OR REPLACE PACKAGE letras AS' || CHR(13) ||
' possuiA CONSTANT BOOLEAN NOT NULL := ' || vvalorpossuia || ';' || CHR(13) ||
' possuiB CONSTANT BOOLEAN NOT NULL := ' || vvalorpossuia || ';' || CHR(13) ||
'END letras;';
EXECUTE IMMEDIATE vpackageletras;
END;
This if I want to add a new CONSTANT I just add it down, for example, the possesC, and I guarantee that I will not lose the data that already exists in the PACKAGE.
However when running this script a package letters is invalid, and editing via PLSQL and running is valid.
Sorry, but constant is constant , number pi , number and etc for variables use variables, to persist values in DBMS use tables, I see no reason to change objects dynamically. But maybe I didn’t understand your problem.
– Motta
You are right, but this routine already exists in the system where I develop, and as the same is in more than 300 client and in each different client, I want it to be possible to add a new constant without losing the values of the current
– David