X
X
xjunkiex2015-01-06 15:01:07
SQL
xjunkiex, 2015-01-06 15:01:07

How to pass part of a parameter in a variable?

there is xls with odbc connection to postgres and sql-query execution
Some variables if we replace them with ? will be specified when it is executed in a pop-up window, but for "complex" variables such a trick does not work, in particular, it is necessary to clarify the value of the bold font:

WHERE p.saletime > (now() - '<b>10</b> days'::interval)

If it is replaced by ? , then an error occurs (screenshot).
64f5cd4a8dc143d297026d28fdfade0b.PNGA similar case was with the request:
WHERE un_cg_product.name ilike %?%   AND  erpi_purchase.saletime > (now() - '31 days'::interval)

but such a detour saved there:
un_cg_product.name ilike '%'||?||'%'if done by analogy - (now() - ''||?||' days'::interval)
then
f9b9514f558945db8cad7fac9cd7cfb0.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eyeless_watcher, 2015-01-06
@xjunkiex

There is nothing to try on yourself, but the following approach with interval multiplication usually works:
(now() - ? * '1 days'::interval)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question