寫Web一直以來是我的罩門,但同事會信的沒多少,認為這對我應該不難,其實下意識覺得我是救世"僕"。想拿回借出去的書參考,結果它們全被擺在家裡睡覺。

  Web搞不定,就記錄我在PostgreSQL的新發現:

  • JDBC承接serial型態都會出錯,用Long接說不能Cast成Integer、用Integer接說不能Cast成BigDecimal、用BigDecimal接卻又說不能Cast成Integer、用String接也說不能Cast成Integer。那怎麼辦咧?在SQL語法強轉型:select cast(serial_id as int) from table。cast不但可以將serial轉成int,也能將character varying轉成int。
  • PostgreSQL似乎沒有判斷NULL的function,NULLIF(var1, var2)是指當var1 = var2回傳Null,所以只好這麼改:select case when serial_id is null then –1 else serial_id end from table。典型的MSSQL語法。
  • 有個欄位放系統時間長整數,卻是字串格式,所以要format成顯示格式如下:select to_char(to_timestamp(to_number(origtime, '99999999999')), 'YYYY-MM-DD') from table。先to_number再to_timestamp後to_char,夠落落長吧!

  沒有餘額再開新的分類,就放在Oracle了。

arrow
arrow
    全站熱搜

    Jemmy 發表在 痞客邦 留言(0) 人氣()