On Sunday, January 19, 2020 at 8:56:04 PM UTC-8, BeeRich33 wrote:
>
> This is how I've been using it, now currently replaced with "30 days"
> manually. I'd like to shove a variable in there.
>
> tm = PG::TypeMapByColumn.new([
> PG::TextEncoder::String.new
> ])
> d = d.to_s
>
> res = $conn.exec_params( %Q{ SELECT search_phrase, count(search_phrase)
> FROM searches
> WHERE creation_date::timestamp::date > (CURRENT_DATE - interval '$1
> days')::date
> AND search_phrase != 'about'
> GROUP BY search_phrase
> ORDER BY count(search_phrase) DESC }, [ d ], 0, tm ).to_a
>
>
>
I'm trying something similar and I can't get it to work ($conn is a
PG::Connection instance):
$conn.exec_params("SELECT CURRENT_DATE - interval '$1 days' as b",
['30'], 0, tm)
PG::IndeterminateDatatype (ERROR: could not determine data type of
parameter $1)
It's not difficult to work around though:
$conn.exec_params("SELECT CURRENT_DATE - ($1 || ' days')::interval as b",
['30']).to_a
[{"b"=>"2019-12-21 00:00:00"}]
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/6f9ed0f7-5231-4238-8b29-b94409231b49%40googlegroups.com.