27 ms·
Use format() for safely constructing dynamic queries. http://www.postgresql.org/docs/9.4/static/functions-string.html#FUNCTIONS-STRING-FORMAT http://www.postgr
by rpedela 12y ago
Use format() for safely constructing dynamic queries.
http://www.postgresql.org/docs/9.4/static/functions-string.html#FUNCTIONS-STRING-FORMAT http://www.postgresql.org/docs/9.4/static/functions-string.h...
- solidsnack9000 12y agoYou end up doing a lot of string concatenation even with that, though. It's not quite the same thing as having some kind of literal or combinator based setup. select(from('tab'), where(and(like('name','Mo%'),not(is('id',NULL)))
- rpedela 12y agoYou can get a similar syntax with format() by nesting format() calls such as: EXECUTE format('SELECT * FROM tab %s', format('WHERE %I IS NOT NULL', 'id'));