0

Estoy teniendo un problema a la hora de dar de alta un procedimiento. Necesitaría ayuda con el pragma excpetion_init. como sería en un caso así:

    create or replace PROCEDURE Cliente_alta(id_cli CLIENTE.CUSTOMER_ID, nombre CLIENTE.NAME, id_vendedor CLIENTE.SALESPERSON_ID, limite_credito CLIENTE.CREDIT_LIMIT)
IS
  EXCEPTION null_credit_limit;
  EXCEPTION null_name;

BEGIN
  IF limite_credito is null THEN
    raise null_credit_limit;
  END IF;
  IF nombre is null THEN
    raise null_name;
  END IF;
  
  IF CHECK_EXISTENCIA_CLIENTE(upper(nombre)) = TRUE THEN
    INSERT INTO CUSTOMER (CUSTOMER_ID, NAME, SALESPERSON_ID, CREDIT_LIMIT)
    VALUES(id_cli, upper(nombre), id_vendedor, limite_credito);
    DBMS_OUTPUT.PUT_LINE('Cliente dado de alta correctamente!');
  ELSE 
    DBMS_OUTPUT.PUT_LINE('Error.');
  END IF;
  
  EXCEPTION
    WHEN null_credit_limit THEN
      DBMS_OUTPUT.PUT_LINE('Error.\nIngrese el limite de credito del cliente!');
    WHEN null_name THEN
      DBMS_OUTPUT.PUT_LINE('Error.\nIngrese el nombre del cliente!');
    WHEN name_in_table THEN
      DBMS_OUTPUT.PUT_LINE('Error.\nEl nombre del cliente ya existe!');
END;

La cuestión es la siguiente, el log me tira el siguiente error:

Error(3,3): PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following: begin function pragma procedure subtype type current cursor delete exists prior external language

2
  • ¿El tipo de dato de los parámetros que ingresaste (CLIENTE.NAME, CLIENTE.SALESPERSON_ID, etc) son correctos? ¿Te referías a %TYPE?
    – padaleiana
    el 5 jun. 2021 a las 11:57
  • Estan mal declaradas las excepciones; las declaraciones son identificador y tipo.
    – Sal
    el 5 jun. 2021 a las 14:19

1 respuesta 1

0

Creo que has mezclado nomenclaturas de diferentes lenguajes.

Cuando haces

   create or replace PROCEDURE Cliente_alta(id_cli CLIENTE.CUSTOMER_ID, nombre CLIENTE.NAME, id_vendedor CLIENTE.SALESPERSON_ID, limite_credito CLIENTE.CREDIT_LIMIT)
IS
  EXCEPTION null_credit_limit;
  EXCEPTION null_name;

Estás intentando generar un tipo excepción propio. Algo así se declararía en lenguajes como Java, pero en PLSQL el tipo se pone DETRÁS del nombre. Prueba lo siguiente:

   create or replace PROCEDURE Cliente_alta(id_cli CLIENTE.CUSTOMER_ID, nombre CLIENTE.NAME, id_vendedor CLIENTE.SALESPERSON_ID, limite_credito CLIENTE.CREDIT_LIMIT)
IS
  null_credit_limit EXCEPTION ;
  null_name EXCEPTION ;

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.