String size in PL/SQL

Asked

Viewed 239 times

0

 CREATE OR REPLACE FUNCTION TamanhoString(texto char(100))
 RETURN NUMBER IS tamanho NUMBER;
 BEGIN
    tamanho := LENGTH(texto);
    RETURN tamanho;
 END TamanhoString;

I need to create a function that receives a text as a parameter and returns its size. The code is giving the following error:

Error: PLS-00103: Found symbol "(" when one of the following symbols was expected: := ) default Varying large character The symbol ":=" has been replaced by "(" to continue.

  • 1

    You are reinventing the wheel! Just use Length directly in your application

1 answer

1


There were some errors in the writing of its function, correcting remained:

CREATE OR REPLACE FUNCTION TamanhoString (texto IN CHAR)
RETURN NUMBER AS
    tamanho NUMBER;
    BEGIN
        tamanho := LENGTH(texto);
    RETURN tamanho;
END;
  • Just one point worth discussing, I suggest you use INTEGER instead of NUMBER because it makes more sense for that function

Browser other questions tagged

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