3
I’m doing some Sqls in my Delphi program and I came up with this question, what is the cost to the bank engine when a UPDATE
does not find the record according to the parameters of WHERE
?
My question arose by the need to make some IFs
in the program to check before if a certain number satisfies the UPDATE, I will give an example:
if (param_pedido > 0){
update tabela set campo = valor where pedido = param_pedido
update ...
update ...
update ...
update ...
}
If we evaluate the IF
doesn’t make much sense unless the UPDATE
is very costly for the database when it does not find the record in question.
Don’t get me wrong, it’s not lazy to type, I have a certain neurosis in letting the code as dry and clean as possible and depending I would have to do a IF
for each update.
What colleagues have to say about this?
Thanks for the reply Renan, my question is very simple even, I do not need to make use of the data after the update is only an update to remove a request number of a renegotiation, I know that there is a cost to the UPDATE as you put, the issue is to leave this cost to the bank or to the application, as it is a simple select and these results will not transit on the network because it is an UPDATE, I believe that the IF in this case is expendable, but I may be wrong so I raised the issue.
– Marcelo