Hello,
PostgreSQL has a flexible procedural language system that allows to create database stored procedures in different languages, e.g. here is one using JavaScript:
[code]CREATE TYPE rec AS (i integer, t text);
CREATE FUNCTION set_of_records() RETURNS SETOF rec AS
$$
// plv8.return_next() stores records in an internal tuplestore,
// and return all of them at the end of function.
plv8.return_next( { “i”: 1, “t”: “a” } );
plv8.return_next( { “i”: 2, “t”: “b” } );
// You can also return records with an array of JSON.
return { "i": 3, "t": "c" }, { "i": 4, "t": "d" } ];
$$
LANGUAGE plv8;[/code]
Everything between the $$ is source code in language specified after the LANGUAGE token.
Is there a way to highlight everything outside $$ in PL/SQL syntax and everything between the $$ in the specified language?
Note that there are multiple supported languages: PL/pgSQL, PL/v8, PL/Python, PL/R and so on.
Thanks!
Tobias