<< Click to Display Table of Contents >>
CreateStatement
쿼리 실행을 위한 실행문을 가져옵니다.
Prototype
object CreateStatement()
public OZJSStatement CreateStatement(integer reultSetType, integer resultSetConcurrency, [integer resultSetHoldability]) throws OZSQLException
Parameters
resultSetType |
결과셋 타입 OZJSResultSetConst.TYPE_FORWARD_ONLY, OZJSResultSetConst.TYPE_SCROLL_INSENSITIVE, OZJSResultSetConst.TYPE_SCROLL_SENSITIVE 중 하나의 값으로 설정 |
resultSetConcurrency |
결과셋 Concurrency OZJSResultSetConst.CONCUR_READ_ONLY,OZJSResultSetConst.CONCUR_UPDATABLE 중 하나의 값으로 설정 |
resultSetHoldability |
결과셋 Holdability OZJSResultSetConst.HOLD_CURSORS_OVER_COMMIT, OZJSResultSetConst.CLOSE_CURSORS_AT_COMMIT 중 하나의 값으로 설정 |
Reference
그룹 관리자 정보를 가져온 경우 true가 리턴되고, 실패한 경우 false가 리턴됩니다.
Example 1
function DataBaseConnectionSample(){
var con = OZCreator.GetBuiltInObject(OZBuiltInObject.DBCONNECTION);
con.SetVendor("mssql");
con.AddItemValue("serverAddress","127.0.0.1");
con.AddItemValue("portNo","1433");
con.AddItemValue("dbName", "oz");
con.AddItemValue("user", "sa");
con.AddItemValue("password", "forcs");
var isOK = con.Connect(false);
_DEBUG("isOK="+isOK);
con.SetAutoCommit(false);
var stmt;
try {
stmt = con.CreateStatement();
var query = "insert into table1 (field1) values("value1")";
stmt.ExecuteUpdate(query);
con.Commit();
} catch(e) {
con.Rollback();
_ERROR("error="+e);
} finally {
stmt.Close();
con.Close();
}
_DEBUG("OK");
}
Example 2
function prepareStatementSample(){
var con = OZCreator.GetBuiltInObject(OZBuiltInObject.DBCONNECTION);
con.SetVendor("mssql2008");
con.AddItemValue("serverAddress","192.168.100.172");
con.AddItemValue("portNo","1433");
con.AddItemValue("dbName", "pubs");
con.AddItemValue("user", "sa");
con.AddItemValue("password", "1234");
var isOK = con.Connect(false);
_DEBUG("isOK="+isOK);
con.SetAutoCommit(false);
var stmt;
try {
var query = "select * from sales";
stmt = con.PrepareStatement(query, OZJSResultSetConst.TYPE_SCROLL_SENSITIVE, OZJSResultSetConst.CONCUR_UPDATABLE, OZJSResultSetConst.CLOSE_CURSORS_AT_COMMIT);
var rs = stmt.ExecuteQuery();
var meta = rs.GetMetaData();
for(var i=0; i<meta.GetColumnCount(); i++) {
_DEBUG(i+'= column Name='+meta.GetColumnName(i+1)+' type='+meta.GetColumnType(i+1));
}
while(rs.Next()) {
var a = "";
for(var i=0; i<meta.GetColumnCount(); i++) {
a = a + rs.GetObject(meta.GetColumnName(i+1)) + ", ";
}
_DEBUG(a);
}
rs.BeforeFirst();
while(rs.Next()) {
var a = "";
for(var i=0; i<meta.GetColumnCount(); i++) {
a = a + rs.GetObject(meta.GetColumnName(i+1)) + ", ";
}
_DEBUG(a);
}
rs.Close();
} catch(e) {
_ERROR("error="+e);
} finally {
//stmt.Close();
//con.Close();
}
_DEBUG("OK");
}
See Also