A Comparison of Stored Procedure of PL/SQL and Java

เก่ง ศิริจันทร์ 1 และ เยาวดี เต็มธนาภัทร์2
1ภาควิชาวิทยาการคอมพิวเตอร์ มหาวิทยาลัยธรรมศาสตร์
2ภาควิชาวิทยาการคอมพิวเตอร์ สถาบันเทคโนโลยีพระจอมเกล้าพระนครเหนือ


ABSTRACT -- In a client/server environment, a stored procedure is an important technique that has been used by several commercial database management systems (DBMSs) to improve a database application's performance. By grouping several SQL statements, facilitating with some control flow and computational operations, as well as storing them as a procedure inside a DBMS, a stored procedure migrates a client site computation to a server site's and dramatically reduces a network traffic between a client and server. Oracle is one of many DBMSs that adopt this technique by providing an Ada like language called PL/SQL. PL/SQL is completely seamless to SQL, sharing the same data types and is ideal for SQL intensive applications. However, recently Oracle has made use of another popular object-oriented language, Java in its engine. Java is now an alternative way for programming a stored procedure. Then it leaves a developer to a question of which language should be used in which conditions and environments. In this paper, to answer the question, we studied and did some experiment in Oracle 8i to compare them. We looked into several aspects such as language-feature, productivity, reliability, performance, flexibility, portability and security issues. Finally, we have some suggestion on the factors that will help a programmer.
KEYWORDS -- PL/SQL, Stored Procedure, JDBC, SQLJ, Java, Oracle

บทคัดย่อ -- ในการทำงานกับสิ่งแวดล้อมแบบ client/server Stored Procedure เป็นเทคนิคการเข้าถึงข้อมูลที่สำคัญที่ถูกใช้ในระบบจัดการ ฐานข้อมูล (DBMS) ทั่วไปเพื่อปรับปรุงประสิทธิภาพของโปรแกรมประยุกต์ (application) โดยการรวมกลุ่มของ SQL statements พร้อมความสามารถในการควบคุมการไหล (control flow) และการปฏิบัติการทางคอมพิวเตอร์ไว้ภายใน Procedure แล้วจัดเก็บมันไว้ภายใน DBMS การทำงานในลักษณะเช่นนี้ทำให้การประมวลผลหรือเข้าถึงข้อมูลย้ายการทำงานจากฝั่ง client มายังฝั่ง server ช่วยลดเวลาที่ต้องเสียไปในการติดต่อสื่อสารกลับไปมาระหว่าง client และ server Oracle เป็นหนึ่งในหลายๆ DBMS ซึ่งนำเทคนิคของ Stored Procedure มาใช้โดยมีภาษาเฉพาะสำหรับ Oracle เองที่เรียกว่า PL/SQL ลักษณะภาษามีโครงสร้างคล้ายคลึงกับภาษา Ada โดย Oracle ออกแบบให้ PL/SQL นั้นต่อเชื่อมเข้ากับ SQL ได้เป็นอย่างดี, สามารถใช้ data types ร่วมกับ SQL ซึ่งเหมาะสมอย่างยิ่งสำหรับโปรแกรมประยุกต์ที่มีการใช้คำสั่ง SQL ในการทำงานเป็นจำนวนมาก อย่างไรก็ตาม Oracle ได้เพิ่ม ภาษา object-oriented ที่กำลังเป็นที่นิยมคือภาษา Java เข้าไปใน engine ของ Oracle Java เป็นทางเลือกใหม่สำหรับการทำ Stored Procedure สำหรับระบบจัดการฐานข้อมูลอย่าง Oracle ทำให้เกิดคำถามกับนักพัฒนาว่าควรจะเลือกภาษาใดในการพัฒนาเพื่อให้เหมาะสมกับการทำงาน เพื่อตอบคำถามเหล่านี้ผู้ศึกษาได้ทำการศึกษาและทดลองกับ Oracle8i เพื่อเปรียบเทียบภาษา PL/SQL และ Java ผู้ศึกษาได้ทำการศึกษาและเปรียบเทียบต่างๆ อาทิเช่น ลักษณะของภาษา ผลประโยชน์ที่เพิ่มขึ้น ความน่าเชื่อถือ ประสิทธิภาพ ความยืดหยุ่น ความสามารถในการนำไปใช้งานกับระบบอื่น และระบบความปลอดภัย จากข้อเปรียบเทียบต่างๆ เหล่านี้นำไปสู่ข้อเสนอแนะถึงปัจจัยที่จะช่วยในการเลือกภาษาที่จะนำไปใช้งานสำหรับนักพัฒนา
คำสำคัญ -- PL/SQL, Stored Procedure, JDBC, SQLJ, Java, Oracle


National Electronics and Computer Technology Center (NECTEC)
Copyright  © 2001 By Information System Service Section. All right reserved.