create or replace procedure GERENCIA_LOCATION(
var_location_id in LOCATIONS.LOCATION_ID%TYPE,
var_street_address in LOCATIONS.STREET_ADDRESS%TYPE,
var_postal_code in LOCATIONS.POSTAL_CODE%TYPE,
var_city in LOCATIONS.CITY%TYPE,
var_state_providence in LOCATIONS.STATE_PROVINCE%TYPE,
var_country_id in LOCATIONS.COUNTRY_ID%TYPE,
var_operacao char)
is
var_exception exception;
v_newrowid rowid;
begin
if (var_operacao ='I')THEN
insert into locations values (var_location_id,var_street_address,var_postal_code,var_city,var_state_providence,var_country_id)
returning rowid into v_newrowid;
dbms_output.put_line('Registros inseridos' || v_newrowid);
commit;
else if (var_operacao ='A')THEN
UPDATE LOCATIONS
SET CITY = var_city
WHERE LOCATION_ID = var_location_id;
dbms_output.put_line('Registros Atualizados');
else if (var_operacao ='D')THEN
DELETE FROM LOCATIONS WHERE LOCATION_ID = var_location_id;
commit;
dbms_output.put_line('Registros DELETADOS');
ELSE
RAISE var_exception;
END IF;
END IF;
END IF;
EXCEPTION
WHEN var_exception then
RAISE_APPLICATION_ERROR(-20999,'Atenção!ESCOLHA:I,D OU A!',FALSE);
when OTHERS THEN
dbms_output.put_line('Atenção codigo'||sqlcode);
dbms_output.put_line('Atenção texto'||SUBSTR(SQLERRM, 1, 200));
end GERENCIA_LOCATION;
Nenhum comentário:
Postar um comentário