printing a value of a variable in postgresql
SqlPostgresqlSql Problem Overview
I have a postgresql function
CREATE OR REPLACE FUNCTION fixMissingFiles() RETURNS VOID AS $$
DECLARE
deletedContactId integer;
BEGIN
SELECT INTO deletedContactId contact_id FROM myContacts WHERE id=206351;
-- print the value of deletedContactId variable to the console
END;
$$ LANGUAGE plpgsql;
How can I print the value of the deletedContactId to the console?
Sql Solutions
Solution 1 - Sql
Solution 2 - Sql
Also, the SELECT INTO you're using looks like PostgreSQL for copying rows into a table. See, for example, the SELECT INTO doc page which state: "SELECT INTO -- define a new table from the results of a query"
In pgplSQL I'm used to seeing it in this order: SELECT
SELECT contact_id INTO deletedContactId FROM myContacts WHERE id=206351;
As described in Executing a Query with a Single-Row Result.