2005/5/9

     
 

ACDK SQL Prepared Statements

artefaktur

| Installation | Types | Basic Operations | Prepared Statements | Stored Procedures | Database information |

To improve performance, use prepared statments



Use prepareStament create a Prepared SQL Statement:


    RString sql = "SELECT intcol, realcol, stringcol FROM acdk_PreparedStatement_Test WHERE intcol < ?";
    RPreparedStatement statement = connection->prepareStatement(sql); 
    statement->setInt(1, 2); // 1 = first '?'
    RResultSet rset = statement->executeQuery();
    int count = 0;
    while (rset->next() == true)
    {
      int intcol = rset->getInt(1);
      float floatcol = rset->getFloat("realcol"); 
      RString sval = rset->getString("stringcol");
      ++count;
    }