Run Instant with Break Lines Getting Invalid Package

Asked

Viewed 1,166 times

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.

  • 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

1 answer

0


I was thinking the problem was the line breaking, so I sought alternatives for 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 Package is no longer Invalid.

Thank you very much.

  • 1

    You do not need to put a "solved" in the questions. When you mark an answer as valid, it is understood that the problem has been solved. :)

  • @Rodrigorigotti Can you tell me why some posts put [Solved] ? (thanks for the tip)

  • 1

    Because other people didn’t know it. : ) I think it’s kind of a habit inherited from the discussion forums.

  • True, I remember that in foruns it was just like that. Thanks @Rodrigorigotti

Browser other questions tagged

You are not signed in. Login or sign up in order to post.