Skip to content
Advertisement

PLS00215: String length constraints must be in range (1..32767)

I am new to pl/sql. I want to create a procedure that has three parameters called ‘startMonth’, ‘endMonth’, ‘thirdMonth’. In the procedure, I am executing a sql query which is in ‘run_sql’ column in table_query. Values for ‘startMonth’, ‘endMonth’, ‘thirdMonth’ are needed to this query. This is how I wrote the procedure. My plan is to put all the sql queries in a separate table and execute in the for loop in the procedure. There I am creating a table called table1 and in the next month I want to drop it and create the table again. This is how I have written the procedure.

This is the query in the run_sql column in table_query.

But when I try to compile the procedure it gives me the error ‘PLS00215: String length constraints must be in range (1..32767). Though I searched for the error I could not find the exact reason. It seems to be a problem in variable assigning. But I could not resolve it.

–Update

As it is given in the answer I converted the strings to dates.

But when executing the query it gives the error message that ORA-00904: “END_DATE”: invalid identifier. But it does not show any error message for the start_date and what would be the reason for this error message?

Advertisement

Answer

The error is pointing you to where the problem is. String declarations (char, varchar, varchar2 – but you should only be using varchar2, not varchar) need a length; so for example:

Notice the procedure arguments do not specify a length; only the local variable declarations.

If those represent dates then they, and passed-in arguments, should probably be dates, not strings. It depends what your dynamic SQL is expecting though – if that is converting the strings to dates and specifying the format mask then I guess it’s OK; otherwise you should be passed dates, or convert the strings to dates. The example you showed doesn’t seem to have any bind variables to populate, though.

Dropping and recreating tables is generally not something you want to be doing though. You could delete/truncate and repopulate a table; or use partitioning if you want to keep more than one month; or use a view (or materialized view).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement