Execute Immediate with line breaks getting Invalid Package

0

I'm creating a package dynamically ie:

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;

If I want to add a new CONSTANT, I just add it, for example, to OwnC, and I guarantee that I will not lose the data that already exists in PACKAGE.

However when I run this script the package letters are getting invalid, and editing via PLSQL and executing is valid.

    
asked by anonymous 21.10.2014 / 22:51

1 answer

0

I was thinking that the problem was in breaking lines, then I looked for alternatives to this, instead of using CHR (13) I used CHR (10)

Chr(13) = Avanço de linha = Line Feed
Chr(10) = Retorno de Carro = Carriage Return

so the Package is no longer Invalid.

Thank you.

    
22.10.2014 / 11:50