ERROR: syntax error at end of input LINE 1: ...= 'H' OR r.ricodtri = 'DAM') AND CAST(r.ricodstr AS INT) = ^