Esempio n. 1
0
func (stmt *Statement) Execute(params ...interface{}) *ODBCError {
	if params != nil {
		var cParams C.SQLSMALLINT
		ret := C.SQLNumParams(C.SQLHSTMT(stmt.handle), &cParams)
		if !Success(ret) {
			err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
			return err
		}
		for i := 0; i < int(cParams); i++ {
			stmt.BindParam(i+1, params[i])
		}
	}
	ret := C.SQLExecute(C.SQLHSTMT(stmt.handle))
	if ret == C.SQL_NEED_DATA {
		// TODO
		//		send_data(stmt)
	} else if ret == C.SQL_NO_DATA {
		// Execute NO DATA
	} else if !Success(ret) {
		err := FormatError(C.SQL_HANDLE_STMT, stmt.handle)
		return err
	}
	stmt.executed = true
	return nil
}
Esempio n. 2
0
func (stmt *Statement) NumParams() int {
	var cParams C.SQLSMALLINT
	ret := C.SQLNumParams(C.SQLHSTMT(stmt.handle), &cParams)
	if !Success(ret) {
		return -1
	}
	return int(cParams)
}
Esempio n. 3
0
func SQLNumParams(statementHandle SQLHSTMT, parameterCountPtr *SQLSMALLINT) (ret SQLRETURN) {
	r := C.SQLNumParams(C.SQLHSTMT(statementHandle), (*C.SQLSMALLINT)(parameterCountPtr))
	return SQLRETURN(r)
}