34 #include <nsServiceManagerUtils.h>
35 #include <nsComponentManagerUtils.h>
36 #include <nsStringGlue.h>
37 #include <nsIConsoleService.h>
38 #include <nsIScriptError.h>
49 : mStatement(nsnull), mSql(sql)
67 NS_IMETHODIMP CDatabasePreparedStatement::GetQueryString(nsAString &_retval)
69 if (
mSql.Length() > 0) {
74 _retval = NS_ConvertUTF8toUTF16(sql);
77 _retval = EmptyString();
85 NS_WARNING(
"GetStatement called without a database pointer.");
92 NS_WARNING(
"GetStatement() called with a different DB than the one originally used compile it!.");
101 if (
mSql.Length() == 0) {
102 NS_WARNING(
"GetStatement() called on a PreparedStatement with no SQL.");
106 const char *pzTail = nsnull;
107 nsCString sqlStr = NS_ConvertUTF16toUTF8(
mSql);
108 int retDB = sqlite3_prepare_v2(db, sqlStr.get(), sqlStr.Length(),
110 if (retDB != SQLITE_OK) {
111 const char *szErr = sqlite3_errmsg(db);
114 log.AppendLiteral(
"SQLite compile step: \n");
116 log.AppendLiteral(
"\ncaused the error\n");
117 log.Append(NS_ConvertUTF8toUTF16(szErr));
118 log.AppendLiteral(
"\n");
121 nsCOMPtr<nsIConsoleService> consoleService = do_GetService(
"@mozilla.org/consoleservice;1", &rv);
123 nsCOMPtr<nsIScriptError> scriptError = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
125 nsresult rv = scriptError->Init(log.get(),
131 "DBEngine:StatementCompilation");
132 if (NS_SUCCEEDED(rv)) {
133 rv = consoleService->LogMessage(scriptError);
140 mSql = EmptyString();
sqlite3_stmt * mStatement
NS_IMPL_THREADSAFE_ISUPPORTS1(sbDeviceCapsCompatibility, sbIDeviceCapsCompatibility) sbDeviceCapsCompatibility
Songbird Database Prepared Query.
sqlite3_stmt * GetStatement(sqlite3 *db)
virtual ~CDatabasePreparedStatement()
A prepared database statement.
Songbird Database Object Definition.