I am making a condition to add a field in the database, that is, it will only add if the condition is equal to 0. The problem is that in my execute immediate
statement it says that the word PRIMARY is invalid. This is because it should be in single quotation marks ('') but how can I handle this since the entire query is already quoted? Detail: If it is a number it works since it does not need quotation marks.
declare
col_count integer;
begin
select count(*)
into col_count
from user_tab_columns
where table_name = 'BALANCA'
and column_name = 'TIPO';
if col_count = 0 then
execute immediate 'ALTER TABLE BALANCA ADD TIPO varchar2(255 char) default PRIMARIO not null';
commit;
end if;
end;