Open topic with navigation

TIBCO BusinessEvents® Enterprise Edition 6.3.1

# Prepared Statements

A prepared statement is an SQL statement whose values are determined at runtime. You can use prepared statements in the `queryUsingPreparedStmt()` and `executePreparedStmt()` functions.

When you use `executePreparedStmt()`, prepare the statement, for example:

    String QueryCON="Insert into HR.COUNTRIES Values (?,?,?)"

Then associate the actual values at execution time, as shown in the following code snippet. It demonstrates use of `executePreparedStmt()` and `queryUsingPreparedStmt()`.

    Database.setCurrentConnection("/JDBC Connection");
    Database.beginTransaction();
    String InsQuery="INSERT into HR.COUNTRIES Values (?,?,?)";
    Object []InsObj={e.rate, e.CID,e.rank};
    int insertCON=Database.executePreparedStmt(InsQuery,InsObj);
    String UpdateQuery="UPDATE HR.COUNTRIES SET COUNTRY_ID=? WHERE COUNTRY_ID=?"
    Object [] update={Use.Updates,Use.UpdateV};
    int updat=Database.executePreparedStmt(UpdateQuery,update);
    String DeleteQuery="DELETE FROM HR.COUNTRIES WHERE COUNTRY_ID=?"
    Object []DelObj={e.CID};
    int deleteCON=Database.executePreparedStmt(DeleteQuery,DelObj);
    String SelectQuery="Select * from HR.COUNTRIES where HR.COUNTRIES.COUNTRY_ID>?"
    Object []SelObj={e.CID};
    Concept []SelectCON=Database.queryUsingPreparedStmt(
            "/Concepts/hr/HR/COUNTRIES",SelectQuery,SelObj,true);
    Database.commit();
    Database.unsetConnection();

Did you find this helpful?

YesNo
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO BusinessEvents® Enterprise Edition

Copyright © 2004-2024. Cloud Software Group, Inc. All Rights Reserved.