So from a tutorial, I successfully created a stored procedure, stored it, and
made code to use it. I think.
If I run my code, it seems to work fine, regardless of whether or not I have
entered that stored procedure into the database.
Is my code suppose to work regardless? Is storing a procedure just meant to
make my code, which repeats quite often, more efficient? Or are stored
procedures created for different reasons? Are they there to let me run my
java code from an sql query? I'm at my wits end trying to understand the
significance of a stored procedure. I've posted my code, if it helps.
public static void callSortTwo(Connection conn, CallList cl) {
try {
Timestamp ts = new Timestamp(System.currentTimeMillis() );
System.out.println("Executed at: " + ts);
String insert_query = "INSERT INTO SWEATY_BALLSAK.CALLS (" +
"beat," +
"call_descr," +
"priority," +
"date," +
"time," +
"call_num," +
"location," +
"status," +
"entry_id) " +
"VALUES(?,?,?,?,?,?,?,?,?)";
PreparedStatement pstmt = conn.prepareStatement(insert_query);
for (int counter = 0; counter < cl.getSize(); counter++) {
String current_event[] = cl.getElementArray(counter);
pstmt.setString(1,current_event[0]);
pstmt.setString(2,current_event[1]);
pstmt.setString(3,current_event[2]);
pstmt.setString(4,current_event[3]);
pstmt.setString(5,current_event[4]);
pstmt.setString(6,current_event[5]);
pstmt.setString(7,current_event[6]);
pstmt.setString(8,current_event[7]);
pstmt.setTimestamp(9, ts);
pstmt.executeUpdate();
}
}
catch(SQLException sqle_callSort) {
System.out.println("SQL Exception" + sqle_callSort.getMessage()
);
}
--
View this message in context:
http://www.nabble.com/Stored-Procedures-%28what-is-it-really-used-for-%29-tp16485873p16485873.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.