在dblink Postgres上传递日期参数

问题描述 投票:0回答:1

我如何在postgres上将日期参数传递给dblink?

SELECT * FROM dblink
    (
       'my connection'
       ,
     'SELECT s.dtcreated  FROM realvida.tbstudente s  ' ||
     ' WHERE s.dtcreated' = $1 -- my parameter pass '02-01-2017'

    ) as result2( dtcreated date )

这样它就给我一个错误:

运算符不存在:date = integer

postgresql function
1个回答
1
投票

改变'SELECT s.dtcreated FROM realvida.tbstudente s ' || ' WHERE s.dtcreated' = $1

format('SELECT s.dtcreated FROM realvida.tbstudente s WHERE s.dtcreated = %L',$1)

© www.soinside.com 2019 - 2024. All rights reserved.