I'm doing some SQL queries in my Delphi program and I had this doubt, what is the cost to the database engine when a UPDATE
does not find the record according to the parameters of WHERE
?
My question came from the need to make some IFs
in the program to check beforehand if a certain number satisfies the UPDATE, I'll give an example:
if (param_pedido > 0){
update tabela set campo = valor where pedido = param_pedido
update ...
update ...
update ...
update ...
}
If we evaluate IF
it does not make much sense unless UPDATE
is very expensive for the database when it does not find the record in question.
Do not get me wrong, it's not too lazy to type, I have a certain neurosis in leaving the code as clean and clean as possible and depending on I would have to do a IF
for each update.
What do colleagues have to say about this?