Standard

posted on 11 Aug 2005 20:16 by kaze  in Technology
ช่วงนี้วุ่นๆกับงาน ต้องมาคอยทำให้ซอฟต์แวร์ของบริษัท
ใช้ได้ทั้ง Sybase และ Oracle แล้วก็พบหลายๆอย่างที่ทำให้หงุดหงิด

Sybase และ MS SQL server ใช้ SQL มาตรฐานเดียวกัน
ขณะที่ Oracle แตกต่างออกไป

เท่าที่ลองใช้ดู SQL plus ที่เป็น Database client ของ Oracle
นับเป็น DB client ตัวหนึ่งที่ใช้แล้วรู้สึกไม่ชอบเลย
ใช้ isql รู้สึกดีกว่าเยอะ (ใช้ command line บน unix)

ส่วน SQL ก็แตกต่างกันมากมาย มองแล้วเหมือนคนละขั้ว
Sybase ยืดหยุ่นเกินไป ส่วน Oracle stick เกินไป
Sybase สามารถใช้ = Null, <> Null, != Null ได้
Oracle ต้องใช้ is Null, is not Null เท่านั้น

และที่ทำให้กลุ้มคือ insert statement
Sybase สามารถใช้ SQL แบบนี้ได้

insert into securities select "TRUE", "True corp."
where not exist (select * from securities where secID = "TRUE")

แต่ oracle ไม่ยอมต้องมี from table ด้วยเป็น

insert into securities select "TRUE", "True corp." from dual
where not exist (select * from securities where secID = "TRUE")

ง่ะแล้วจะทำไงให้ SQL เดียวใช้ได้กับทั้งสองอันเนี่ย T_T
จะทำเป็น Transaction ก็ไม่ได้อีก (เป็นข้อจำกัดของ requirement)

หรือ update statement อีก
Sybase ยอมให้ทำแบบนี้ได้

update securities set secType = 1 from securities, securities_type
where
securities.secType = securities_type.typeID
and
securities_type.desc = 'EQUITY'

แต่ Oracle ไม่ยอม แต่ไม่เป็นไรปัญหานี้แก้ง่ายมาก
แต่ไอ้ insert statement เนี่ยจะทำไงเนี่ย -_-"
กลับไปนอนคิดดีกว่า



Comment



smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

เรื่อง sql server นี่เป็นปัญหาจริง ๆ เปลี่ยนยี่ห้อที สับสนที

#1 By T!D on 2005-08-12 21:32

นี่แหล่ะ ถึงไม่ชอบงาน DB

#2 By PaePae on 2005-08-13 12:38

อืม.. แต่ Sybase, MS SQL server มาตรฐานเดียวกันนะ

#3 By kaze on 2005-08-15 09:51