Presentation is loading. Please wait.

Presentation is loading. Please wait.

My_Demo_Test : Air –Pollution measured at certain time points in a day t0t1t2t3t4 4548556560 4352576361 4042575556 3536474641 3637495048 65 63 57 47 50.

Similar presentations


Presentation on theme: "My_Demo_Test : Air –Pollution measured at certain time points in a day t0t1t2t3t4 4548556560 4352576361 4042575556 3536474641 3637495048 65 63 57 47 50."— Presentation transcript:

1 My_Demo_Test : Air –Pollution measured at certain time points in a day t0t1t2t3t Results t0t1t2t3t When is the highest pollution?

2 Client (Java, JDBC) DB Server Oracle Table : My_Demo_Tes t... Return table data (cursor) Select * From My_Demo_Test ; Data is processed at client side Thick Client : Business logic resides at client

3 Int maxPos() { … } Int main() { … EXEC SQL BEGIN DECLARE SECTION; charszServerDatabase[(SQLID_MAX * 2)+2] = “dbname"; charszLoginPassword[(SQLID_MAX * 2)+2] = “uname.password"; intt0, t1, t2, t3, t4 ; EXEC SQL END DECLARE SECTION; … EXEC SQL CONNECT TO :szServerDatabase USER :szLoginPassword; … EXEC SQL DECLARE C1 CURSOR FOR SELECT * FROM my_demo_test; EXEC SQL OPEN C1 ; … 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 ; } }

4 Client (Sql*plus) DB Server Oracle Package isk_demo { MaxPos() ; PosCount() ; } Table : My_Demo_Tes t... Result s Executing sp… Call isk_demo.PosCount() ; Package isk_demo { MaxPos() ; PosCount() ; } Thin Client : Business logic resides at server

5 Sql*Plus Oracle Server ResultQuery, Procedure Call

6 Create Or Replace Package isk_demo As Function MaxPos(t1 Float, t2 Float, t3 Float, t4 Float, t5 Float) Return Integer ; Procedure PosCount ; End isk_demo ; Create Or Replace Package Body isk_demo As End isk_demo ;

7 Create Or Replace Package Body isk_demo As Function MaxPos(…) Return Integer End MaxPos ; Procedure PosCount 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 ; End PosCount ; End isk_demo ;

8 class Luft {// stands for "Luftverschmutzungsstatistik“ int MaxPos(float t0, float t1, float t2, float t3, float t4) { } void main () { // Load the Oracle JDBC driver DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // Connect to the database : : Connection conn = DriverManager.getConnection "iskXX", "*****"); // Select the complete table ResultSet rset = stmt.executeQuery ("SELECT * FROM My_Demo_Test");... while (rset.next ()) { Pos = MaxPos(); PosCount[Pos] = PosCount[Pos] + 1; } }


Download ppt "My_Demo_Test : Air –Pollution measured at certain time points in a day t0t1t2t3t4 4548556560 4352576361 4042575556 3536474641 3637495048 65 63 57 47 50."

Similar presentations


Ads by Google