2017-03-20 66 views
0

如何在postgrees上將日期參數傳遞給dblink?在dblink上傳遞日期參數Postgres

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) 

這樣,它返回我一個錯誤:運營商不存在:日期=整數 感謝。

回答

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)

+1

謝謝。你非常幫助我。 – joelton