How to limit to not being able to pass 3 units of a book in a PL/SQL ORACLE rental

Asked

Viewed 37 times

0

I’m making a bookstore in APEX and I can’t allow the client to rent more than 3 books. But even putting the code the program does not bar.

declare
W_QUANTIDADE_EMPRESTIMOS number;
W_STATUS     LIVROS.IND_STATUS%TYPE;

begin

SELECT COUNT(EL.COD_EMPRESTIMO), L.IND_STATUS
into W_QUANTIDADE_EMPRESTIMOS, W_STATUS
FROM EMPRESTIMO_LIVRO EL
    ,LIVROS L
WHERE NM_USUARIO_LOC = :P16_NM_USUARIO_LOC;


IF W_QUANTIDADE_EMPRESTIMOS > 3 AND W_STATUS = 'P' THEN
 raise_application_error( -20001, 'Você já possui muitos livros alugados!');
end if;
 
end;
  • Johnny, have you checked what your query is putting in the variables? What else is this W_STATUS?

  • Block runs ? Seems to be missing a "group by" in sql.

No answers

Browser other questions tagged

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