File: hk_sqliteactionquery.cpp

package info (click to toggle)
hk-classes 0.7.3-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,976 kB
  • ctags: 8,014
  • sloc: cpp: 84,248; sh: 8,328; python: 3,255; makefile: 257
file content (105 lines) | stat: -rw-r--r-- 3,066 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// ****************************************************************************
// copyright (c) 2000-2005 Horst Knorr <hk_classes@knoda.org>  
// This file is part of the hk_sqliteclasses library.
// This file may be distributed and/or modified under the terms of the
// GNU Library Public License version 2 as published by the Free Software
// Foundation and appearing in the file COPYING included in the
// packaging of this file.
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
// ****************************************************************************
#include "hk_sqliteactionquery.h"
#include "hk_sqlitedatabase.h"
#include "hk_sqliteconnection.h"
#include <sqlite.h>

hk_sqliteactionquery::hk_sqliteactionquery(hk_sqlitedatabase* db) :hk_actionquery(db)
{
    sqlitedb=db;
   // p_identifierdelimiter="`";
}


bool hk_sqliteactionquery::driver_specific_execute(void)
{
#ifdef HK_DEBUG
    hkdebug("hk_sqliteactionquery::driver_specific_execute");
#endif

        if  (!sqlitedb||!sqlitedb->dbhandler()) 
	 {
	  cerr <<"error p_sqlitedatabase==NULL||p_sqlitedatabase->dbhandler()"<<endl;
	  cerr <<"db="<<sqlitedb<<" handler="<<sqlitedb->dbhandler()<<endl;
	  return false;
	 } 
        sqlite_vm* vm=0;
	char* errormsg=0;
	int result= sqlite_compile(sqlitedb->dbhandler() ,p_sql,0,&vm,&errormsg );
	//cerr <<"SQL="<<p_sql<<endl;
	if (result!=SQLITE_OK)
	{
          sqlitedb->sqliteconnection()->servermessage(errormsg);
	  cerr <<errormsg<<" ";
	  sqlite_freemem(errormsg);
	  errormsg=0;
	  cerr<< "compile problem"<<endl;
	  return false;
	}
            
	//cerr <<"sqlite_compile result="<<result<<endl;
	int colnums=0;
	const char** data=0;
	const char** colnames=0;
	if (vm)
	{
	result=sqlite_step(vm,&colnums,&data,&colnames);
	//cerr <<"sqlite_step result="<<result<<endl;
	}
	sqlite_finalize(vm,&errormsg);
	vm=0;
	if (result==SQLITE_ERROR) 
        {
	  sqlitedb->sqliteconnection()->servermessage(errormsg);
	  sqlite_freemem(errormsg);
	  errormsg=0;
         return false;
	}  
	
	    
   
   return true;	    

/*    if (!sqlitedb->connection()->dbhandler()) return false;


    int i=sqlite_real_query(sqlitedb->connection()->dbhandler(),p_sql,p_length);


#ifdef HK_DEBUG
    hkdebug("hk_sqliteactionquery::driver_specific_execute after query");
#endif
    if (i==0)  return true;
    else
    {
        hk_string error;
        switch (i)
        {
            case CR_COMMANDS_OUT_OF_SYNC : error="CR_COMMANDS_OUT_OF_SYNC";break;
            case CR_SERVER_GONE_ERROR : error="CR_SERVER_GONE_ERROR";break;
            case CR_SERVER_LOST : error="CR_SERVER_LOST";break;
            case CR_UNKNOWN_ERROR : error="CR_UNKNOWN_ERROR";break;
            default : error="misc. Mysql error message!";
        }
        cerr <<"MYSQL Error: "<<error<<endl;
        sqlitedb->connection()->servermessage();
        return false;
    }
*/
return false;
}


bool hk_sqliteactionquery::driver_specific_sql(const char* )
{
    return true;
}