简体   繁体   中英

WHEN condition postgresql evaluate the result

I dont't understand why the when condition evaluate the result if it is FALSE.

FOR EXAMPLE:

WHERE
    CASE
        WHEN false THEN lower(pmo.id_province) <> lower(dp.id_province)
        WHEN true THEN pmo.id_province <> dp.id_province 
    END;

Here postgresqll's message:

ERROR: function lower(integer) does not exist LINE 8: WHEN false THEN lower(pmo.id_province) <> lower(dp.id_prov... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. SQL state: 42883 Character: 199

I know that lower function accept text arguments, but I inserted the when statements for avoid this issue, but not work. Why WHEN by pass the condition if it is false?

It is not executed, but it failing before execution, when it tries to resolve which functions are being referenced. That happens at parse time, not during execution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM