2
我不喜歡依賴位置參數,是否可以這樣做與HDBC?確實Database.HDBC支持命名參數?
我可以看到通過[(String, SqlValue)]
而不是[SqlValue]
作爲this package各種執行功能的參數。
概括地說,我寧願
select
t.f1
, t.f2
, t.f3
from
schema.table t
where
t.f1 > @param1
and t.f2 < @param2
比
select
t.f1
, t.f2
, t.f3
from
schema.table t
where
t.f1 > ?
and t.f2 < ?
謝謝,這是我沒有設想的方法;我現在這樣做 declare(at)param1 type declare(at)param2 type set(at)param1 =? set(at)param2 =? ...聲明的其餘部分 字符串插值的問題是處理潛在的sql注入,綁定的參數我知道我很安全(只要沒有在引擎蓋下生成動態sql) – smoothdeveloper
要小心使用hdbc placeholderes用於更新/插入。他們有一個討厭的bug。它們在值的末尾添加額外的空間。我修正了github上的bug https://github.com/hdbc/hdbc-odbc/pull/10,但它仍然不被主要的存儲庫所接受 –