13#if __DCL_HAVE_ALLOC_DEBUG
14#undef __DCL_ALLOC_LEVEL
15#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
21#if __DCL_HAVE_THIS_FILE__
62 __count = hQuery->fieldCount();
67 for(
size_t i = 0; i < hQuery->fieldCount(); i++) {
68 _field = &(__fields[i]);
70 if (!hQuery->getField(i, &(_field->
__handle))) {
86 if (__fieldMap.isEmpty()) {
87 __fieldMap.initBuckets(__count);
88 for(
size_t i = 0; i < __count; i++)
89 __fieldMap[__fields[i].name()] = &__fields[i];
91 _field = (
SQLField*)(__fieldMap[_name]);
94 for(
size_t i = 0; i < __count; i++) {
96 if (String::compare(__fields[i].name(), _name) == 0) {
97 _field = &__fields[i];
103 if (_field ==
NULL) {
142 __count = hQuery->paramCount();
146 for(
size_t i = 0; i < hQuery->paramCount(); i++) {
166 if (__paramMap.isEmpty()) {
167 __paramMap.initBuckets(__count);
168 for (
size_t i = 0; i < __count; i++) {
170 __paramMap[p->name()] = p;
176 for(
size_t i = 0; i < __count; i++) {
177 if (String::compare(__params[i].name(), _name) == 0) {
191static void __sql_transform__(
192 const String& _sql,
wchar_t _placeholder,
193 String& _newsql, StringArray& _names
196 StringBuilder newsql(_sql.length());
197 const wchar_t* s = _sql.data();
198 const wchar_t* e = s + _sql.length();
199 const wchar_t* p = s;
203 if ((*p == L
':' && !wcschr(L
":=", *(p + 1)))
204 || *p == L
'?' || *p == L
'$') {
206 if (_placeholder == L
'?')
211 newsql.format(L
"%lc%zd", _placeholder, _names.size() + 1);
217 if (wcschr(L
",);:", *p) || iswspace(*p)) {
223 _names.add(String(s, p));
227 else if (*p == L
'\'') {
244 _newsql = newsql.toString();
258 if (!_conn->handle()->createQueryInstance(&hQuery)) {
264 __connection = _conn;
293 __sql_transform__(_sql,
__handle->placeholder(), sql, names);
298 mbs = UTF8Encoder::encode(sql);
304 if (!
__handle->prepare(mbs, mbs.length(), names.size())) {
320 throw new SQLException(this, __sql);
322 throw new SQLException(this, NULL);
339 throw new SQLException(this, NULL);
345 bool _moreResults =
false;
346 if (!
__handle->moreResults(&_moreResults)) {
347 throw new SQLException(this, NULL);
352 __fields.initialize(this);
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
void initialize(SQLQuery *_query)
_CONST SQLField & byName(const wchar_t *_name) _CONST __DCL_THROWS1(InvalidIndexException *)
void initialize(SQLQuery *_query, const StringArray _names)
SQLParam & byName(const wchar_t *_name) _CONST __DCL_THROWS1(InvalidIndexException *)
void prepare(const String &_sql) __DCL_THROWS1(SQLException *)
SQLQuery(SQLConnection *_conn) __DCL_THROWS1(SQLException *)
void execute() __DCL_THROWS1(SQLException *)
void fetch() __DCL_THROWS1(SQLException *)
SQL::Query * handle() const
bool moreResults() __DCL_THROWS1(SQLException *)
SQLConnection * __connection