Changeset View
Changeset View
Standalone View
Standalone View
src/drivers/sybase/SybaseConnection.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | 88 | { | |||
---|---|---|---|---|---|
90 | // todo: verify. | 90 | // todo: verify. | ||
91 | return queryStringList(KDbEscapedString("SELECT name FROM master..sysdatabases"), list) ; | 91 | return queryStringList(KDbEscapedString("SELECT name FROM master..sysdatabases"), list) ; | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | bool SybaseConnection::drv_createDatabase(const QString &dbName) | 94 | bool SybaseConnection::drv_createDatabase(const QString &dbName) | ||
95 | { | 95 | { | ||
96 | //sybaseDebug() << dbName; | 96 | //sybaseDebug() << dbName; | ||
97 | // mysql_create_db deprecated, use SQL here. | 97 | // mysql_create_db deprecated, use SQL here. | ||
98 | if (drv_executeVoidSQL(KDbEscapedString("CREATE DATABASE ") + dbName)) { | 98 | if (drv_executeSql(KDbEscapedString("CREATE DATABASE ") + dbName)) { | ||
99 | // set allow_nulls_by_default option to true | 99 | // set allow_nulls_by_default option to true | ||
100 | KDbEscapedString allowNullsQuery = KDbEscapedString("sp_dboption %1, allow_nulls_by_default, true").arg(dbName); | 100 | KDbEscapedString allowNullsQuery = KDbEscapedString("sp_dboption %1, allow_nulls_by_default, true").arg(dbName); | ||
101 | if (drv_executeVoidSQL(allowNullsQuery.data())) | 101 | if (drv_executeSql(allowNullsQuery.data())) | ||
102 | return true; | 102 | return true; | ||
103 | } | 103 | } | ||
104 | d->storeResult(); | 104 | d->storeResult(); | ||
105 | return false; | 105 | return false; | ||
106 | } | 106 | } | ||
107 | 107 | | |||
108 | bool SybaseConnection::drv_useDatabase(const QString &dbName, bool *cancelled, KDbMessageHandler* msgHandler) | 108 | bool SybaseConnection::drv_useDatabase(const QString &dbName, bool *cancelled, KDbMessageHandler* msgHandler) | ||
109 | { | 109 | { | ||
110 | Q_UNUSED(cancelled); | 110 | Q_UNUSED(cancelled); | ||
111 | Q_UNUSED(msgHandler); | 111 | Q_UNUSED(msgHandler); | ||
112 | 112 | | |||
113 | //! @todo is here escaping needed? | 113 | //! @todo is here escaping needed? | ||
114 | return d->useDatabase(dbName) ; | 114 | return d->useDatabase(dbName) ; | ||
115 | } | 115 | } | ||
116 | 116 | | |||
117 | bool SybaseConnection::drv_closeDatabase() | 117 | bool SybaseConnection::drv_closeDatabase() | ||
118 | { | 118 | { | ||
119 | // here we disconenct the connection | 119 | // here we disconenct the connection | ||
120 | return true; | 120 | return true; | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | bool SybaseConnection::drv_dropDatabase(const QString &dbName) | 123 | bool SybaseConnection::drv_dropDatabase(const QString &dbName) | ||
124 | { | 124 | { | ||
125 | 125 | | |||
126 | return drv_executeVoidSQL(KDbEscapedString("DROP DATABASE ") + escapeString(dbName)); | 126 | return drv_executeSql(KDbEscapedString("DROP DATABASE ") + escapeString(dbName)); | ||
127 | } | 127 | } | ||
128 | 128 | | |||
129 | bool SybaseConnection::drv_executeSQL(const KDbEscapedString& sql) | 129 | bool SybaseConnection::drv_executeSql(const KDbEscapedString& sql) | ||
130 | { | 130 | { | ||
131 | return d->executeSQL(sql); | 131 | return d->executeSql(sql); | ||
132 | } | 132 | } | ||
133 | 133 | | |||
134 | quint64 SybaseConnection::drv_lastInsertRecordId() | 134 | quint64 SybaseConnection::drv_lastInsertRecordId() | ||
135 | { | 135 | { | ||
136 | int rowId = 0; | 136 | int rowId = 0; | ||
137 | querySingleNumber(KDbEscapedString("Select @@IDENTITY"), &rowId); | 137 | querySingleNumber(KDbEscapedString("Select @@IDENTITY"), &rowId); | ||
138 | return (qint64)rowId; | 138 | return (qint64)rowId; | ||
139 | } | 139 | } | ||
Show All 34 Lines | |||||
174 | 174 | | |||
175 | bool KDbSybaseConnection::drv_beforeInsert(const QString& table, KDbFieldList* fields) | 175 | bool KDbSybaseConnection::drv_beforeInsert(const QString& table, KDbFieldList* fields) | ||
176 | { | 176 | { | ||
177 | 177 | | |||
178 | if (fields.autoIncrementFields()->isEmpty()) | 178 | if (fields.autoIncrementFields()->isEmpty()) | ||
179 | return true; | 179 | return true; | ||
180 | 180 | | |||
181 | // explicit insertion into IDENTITY fields !! | 181 | // explicit insertion into IDENTITY fields !! | ||
182 | return drv_executeVoidSQL(KDbEscapedString("SET IDENTITY_INSERT %1 ON").arg(escapeIdentifier(table))); | 182 | return drv_executeSql(KDbEscapedString("SET IDENTITY_INSERT %1 ON").arg(escapeIdentifier(table))); | ||
183 | 183 | | |||
184 | } | 184 | } | ||
185 | 185 | | |||
186 | bool KDbSybaseConnection::drv_afterInsert(const QString& table, KDbFieldList* fields) | 186 | bool KDbSybaseConnection::drv_afterInsert(const QString& table, KDbFieldList* fields) | ||
187 | { | 187 | { | ||
188 | // should we instead just set a flag when an identity_insert has taken place and only check for that | 188 | // should we instead just set a flag when an identity_insert has taken place and only check for that | ||
189 | // flag here ? | 189 | // flag here ? | ||
190 | 190 | | |||
191 | if (fields.autoIncrementFields()->isEmpty()) | 191 | if (fields.autoIncrementFields()->isEmpty()) | ||
192 | return true; | 192 | return true; | ||
193 | 193 | | |||
194 | // explicit insertion into IDENTITY fields has taken place. Turn off IDENTITY_INSERT | 194 | // explicit insertion into IDENTITY fields has taken place. Turn off IDENTITY_INSERT | ||
195 | return drv_executeVoidSQL(KDbEscapedString("SET IDENTITY_INSERT %1 OFF").arg(escapeIdentifier(table))); | 195 | return drv_executeSql(KDbEscapedString("SET IDENTITY_INSERT %1 OFF").arg(escapeIdentifier(table))); | ||
196 | 196 | | |||
197 | } | 197 | } | ||
198 | 198 | | |||
199 | bool KDbSybaseConnection::drv_beforeUpdate(const QString& table, KDbFieldList* fields) | 199 | bool KDbSybaseConnection::drv_beforeUpdate(const QString& table, KDbFieldList* fields) | ||
200 | { | 200 | { | ||
201 | if (fields->autoIncrementFields()->isEmpty()) | 201 | if (fields->autoIncrementFields()->isEmpty()) | ||
202 | return true; | 202 | return true; | ||
203 | 203 | | |||
204 | // explicit update of IDENTITY fields has taken place. | 204 | // explicit update of IDENTITY fields has taken place. | ||
205 | return drv_executeVoidSQL(KDbEscapedString("SET IDENTITY_UPDATE %1 ON").arg(escapeIdentifier(table))); | 205 | return drv_executeSql(KDbEscapedString("SET IDENTITY_UPDATE %1 ON").arg(escapeIdentifier(table))); | ||
206 | } | 206 | } | ||
207 | 207 | | |||
208 | bool KDbSybaseConnection::drv_afterUpdate(const QString& table, KDbFieldList& fields) | 208 | bool KDbSybaseConnection::drv_afterUpdate(const QString& table, KDbFieldList& fields) | ||
209 | { | 209 | { | ||
210 | // should we instead just set a flag when an identity_update has taken place and only check for that | 210 | // should we instead just set a flag when an identity_update has taken place and only check for that | ||
211 | // flag here ? | 211 | // flag here ? | ||
212 | 212 | | |||
213 | if (fields.autoIncrementFields()->isEmpty()) | 213 | if (fields.autoIncrementFields()->isEmpty()) | ||
214 | return true; | 214 | return true; | ||
215 | 215 | | |||
216 | // explicit insertion into IDENTITY fields has taken place. Turn off IDENTITY_INSERT | 216 | // explicit insertion into IDENTITY fields has taken place. Turn off IDENTITY_INSERT | ||
217 | return drv_executeVoidSQL(KDbEscapedString("SET IDENTITY_UPDATE %1 OFF").arg(escapeIdentifier(table))); | 217 | return drv_executeSql(KDbEscapedString("SET IDENTITY_UPDATE %1 OFF").arg(escapeIdentifier(table))); | ||
218 | } | 218 | } |