Error while trying to create index

Asked

Viewed 37 times

0

I’m trying to create an index by command:

declare
  cont integer;
  tabela varchar2(100) := 'DECLARACAO_IMPORTACAO';
  coluna varchar2(100) := 'DESPACHANTE_FK';
  indice varchar2(100) := 'DECLARACAO_IMPORTACAODESPCHT1';
begin
   select distinct count(index_name) into cont from user_ind_columns
   where table_name = tabela and column_name = coluna;
   if cont = 0 then
       execute immediate 'create index '||indice||' on '||tabela||' ( '||coluna|| ')';
       commit;
   end if;
end;
/

But always returns me the error:

[2021-04-02 16:00:49] [42000][904]
[2021-04-02 16:00:49]   ORA-00904: "DESPACHANTE_FK": invalid identifier
[2021-04-02 16:00:49]   ORA-06512: at line 10
[2021-04-02 16:00:49] Position: 0

It seems to be a syntax problem but I don’t know how to fix it.. Someone please give a help?

  • Does the column exist in the table ? Does a dbms_output of the command.

  • There is, blz. I’ll see

No answers

Browser other questions tagged

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