Skip to content

Instantly share code, notes, and snippets.

@er2
Last active May 4, 2023 02:49
Show Gist options
  • Save er2/a34f3245229bba9821261bc50def5ef7 to your computer and use it in GitHub Desktop.
Save er2/a34f3245229bba9821261bc50def5ef7 to your computer and use it in GitHub Desktop.
HTML from SQL
create function home() returns XML
language sql as $$
select xmlelement(name table,
xmlelement(name th, 'Column 1'),
xmlelement(name th, 'Column 2'),
xmlagg(
xmlelement(name tr,
xmlforest(column_one as td,
column_two as td))))
from home_page_content;
$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment