Skip to content

Instantly share code, notes, and snippets.

@rektide
Last active December 11, 2015 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rektide/4513985 to your computer and use it in GitHub Desktop.
Save rektide/4513985 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION SPROC_UA_MSG(_forChan INTEGER, _usr INTEGER, _t TIMESTAMP, _msg TEXT)
RETURNS void AS
$$
DECLARE
tmprow msg%ROWTYPE;
BEGIN
-- [error: relation "tmprow" does not exist]
INSERT INTO msg (forChan,usr,t,msg)
VALUES(_forChan,_usr,_t,_msg)
RETURNING *
INTO tmprow;
PERFORM pg_notify("msg", row_to_json(rec.*)::TEXT) FROM tmprow AS rec;
--PERFORM pg_notify("msg", row_to_json(rec.*)::TEXT) FROM (
-- SELECT _forChan as forChan, _usr as usr, _t as t, _msg as msg
--) AS rec;
END;
$$
LANGUAGE plpgsql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment