60 likes | 217 Views
When is the highest pollution?. Thick Client : Business logic resides at client. Select * From My_Demo_Test ;. Return table data (cursor). DB Server Oracle. Data is processed at client side. Client (Java, JDBC). Int maxPos() { … } Int main() { … EXEC SQL BEGIN DECLARE SECTION;
E N D
Thick Client : Business logic resides at client Select * From My_Demo_Test ; Return table data (cursor) DB Server Oracle Data is processed at client side Client (Java, JDBC)
Int maxPos() { … } Int main() { … EXEC SQL BEGIN DECLARE SECTION; char szServerDatabase[(SQLID_MAX * 2)+2] = “dbname"; char szLoginPassword[(SQLID_MAX * 2)+2] = “uname.password"; int t0, t1, t2, t3, t4 ; EXEC SQL END DECLARE SECTION; … EXEC SQL CONNECT TO:szServerDatabaseUSER:szLoginPassword; … EXEC SQL DECLAREC1CURSOR FORSELECT * FROM my_demo_test; EXEC SQL OPENC1 ; … EXEC SQL FETCH C1 INTO :t0, :t1, :t2, :t3, :t4 ; while (SQLCODE == 0) { Pos = maxPos(t0, t1, t2, t3, t4); PosCount[Pos] = PosCount[Pos] + 1; EXEC SQL FETCH C1 INTO :t0, :t1, :t2, :t3, :t4 ; } <-- Print out results --> }
Executing sp… Thin Client : Business logic resides at server Package isk_demo { MaxPos() ; PosCount() ; } Package isk_demo { MaxPos() ; PosCount() ; } Call isk_demo.PosCount() ; Results DB Server Oracle Client (Sql*plus)
Create Or Replace Package isk_demo As FunctionMaxPos(t1 Float, t2 Float, t3 Float, t4 Float, t5 Float) Return Integer ; ProcedurePosCount ; End isk_demo ; Create Or Replace Package Body isk_demo As <-- Body of package goes here --> End isk_demo ;
Create Or Replace Package Body isk_demo As FunctionMaxPos(…) Return Integer <-- Body of function goes here --> End MaxPos ; ProcedurePosCount As Cursor rSet Is Select * From My_Demo_Test ; … Begin For rSetRow In rSet Loop I := MaxPos(rSetRow.t0, rSetRow.t1, rSetRow.t2, rSetRow.t3, rSetRow.t4) ; PosCountArray(I) := PosCountArray(I) + 1 ; End Loop ; <-- Return the result --> End PosCount ; End isk_demo ;