A snag I hit in my blog tutorial was text needed to be checked for single quotes before inserting them into an SQL database, and if so the single quotes needed to be escaped SQL-style.
My solution is:
sql_escape_single_quotes(StringIn, StringOut) :- split_string(StringIn, "'", "", List), atomics_to_string(List, "''", StringOut).
It seems to work well, and I’m very proud of it… which probably means there’s some horrible bug lurking in there somewhere.
BTW: I’ve nearly finished Unit 3 which explains how to join a PostgreSQL database to a SWI Prolog web application at https://github.com/roblaing/swipl-webapp-howto