在dblink Postgres上传递日期参数

时间:2017-03-20 16:02:21

标签: postgresql function

我如何在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

1 个答案:

答案 0 :(得分: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)