Estou tentando fazer uma validação para que não sejam inseridos registros iguais e no pre-insert fiz o código abaixo, porém quando vou inserir um registro já existente, ao invés de dar a mensagem do código, ocorre o erro, de cursor inváido.
ORA-01001 invalid cursor
Cause Either a host language program call specified an invalid cursor or the values of the AREASIZE and MAXOPENCURSORS options in the precompiler command were too small. All cursors must be opened using the OOPEN call before being referenced in any of the following calls: SQL, DESCRIBE, NAME, DEFINE, BIND, EXEC, FETCH, and CLOSE. The Logon Data Area (LDA) must be defined by using OLON or OLOGON. If the LDA is not defined, this message is issued for the following calls: OPEN, COM, CON, ROL, and LOGOFF.
Action Check the erroneous call statement. Specify a correct LDA area or open the cursor as required. If there is no problem with the cursor, it may be necessary to increase the AREASIZE and MAXOPENCURSORS options before precompiling.
Código:
Declare
Cursor cInserir is (Select cd_bd
,desc_bd
From create_banco_de_dados);
rInserir cInserir%rowtype;
Begin
Open cInserir;
Loop
Fetch cInserir into rInserir;
Exit when cInserir%notfound;
If (:create_banco_de_dados.cd_bd = rInserir.cd_bd)
and (:create_banco_de_dados.desc_bd = rInserir.desc_bd) Then
message ('Atenção: Banco de dados, já cadastrado.');
raise form_trigger_failure;
End If;
Close cInserir;
End Loop;
End;