Pretty new to this; What is the equivalent of the ...
# sql
m
Pretty new to this; What is the equivalent of the .valid? method in Ruby for Postgres? My goal is to utilize the .rpc method to evaluate if a record exists and return a boolean
s
Copy code
sql
CREATE FUNCTION row_exists()
  RETURNS BOOLEAN
AS $$
RETURN EXISTS (
  SELECT *
  FROM some_table
  WHERE
    some_condition = some_expected_value
)
END
$$ LANGUAGE plpgsql;
https://stackoverflow.com/a/41026588
m
👍