Search code examples
sqloracle-databaseplsqloracle-apexoracle-apex-5

SELECT command not being recognized for some reason.


For some reason, every time I try to run this, there is any error saying that the SQL statement at line 4, column 3 (SELECT) has been ignored. Also says, "YEAR": Invalid Identifier. Year is another column that exists on the same form. I am trying to make a column that displays the YEAR with a hyphen like for example this: "17-".

 DECLARE
  TERRA_NUMBER VARCHAR2(40);
BEGIN
 SELECT CONCAT(YEAR , '-' )
 INTO TERRA_NUMBER FROM DUAL;
  RETURN TERRA_NUMBER;
END;

Solution

  • This is too long for a comment.

    First, there is no YEAR variable in Oracle. Perhaps you intend TO_CHAR(sysdate, 'YYYY').

    Second, an anonymous programming block does not return a value. So, RETURN is inappropriate.

    If this is part of a function or stored procedure you should show the entire definition.