RE: [sqlite] Rewriting SQLite APIs to Delphi

2003-11-07 Thread Bronislav Klučka
I know where the mistake is:
this
>   int *pN, /* OUT: Number of columns in result */

is not  AColumnCount:PInteger; but var AColumnCount:Integer;

Klucka

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[sqlite] Rewriting SQLite APIs to Delphi

2003-11-07 Thread Bronislav Klučka
Hi there are 3 functions as described in SQLite homepage help


int sqlite_compile(
  sqlite *db,  /* The open database */
  const char *zSql,/* SQL statement to be compiled */
  const char **pzTail, /* OUT: uncompiled tail of zSql */
  sqlite_vm **ppVm,/* OUT: the virtual machine to execute zSql */
  char **pzErrmsg  /* OUT: Error message. */
);

int sqlite_step(
  sqlite_vm *pVm,  /* The virtual machine to execute */
  int *pN, /* OUT: Number of columns in result */
  const char ***pazValue,  /* OUT: Column data */
  const char ***pazColName /* OUT: Column names and datatypes */
);

int sqlite_finalize(
  sqlite_vm *pVm,  /* The virtual machine to be finalized */
  char **pzErrMsg  /* OUT: Error message */
);


I've rewrote it this way:



type
PSQLite=type pointer;

var
SQLite:PSQLite;

sqlite_compile:function(ASQLite:PSQLite; ASql:pChar; var ASqlTail:Pointer;
var ASqlVM:PSQLite; var AErrMsg: pChar):integer; cdecl;
sqlite_step:function(ASqlVM:PSQLite; AColumnCount:PInteger; var
AColumnValues: Pointer; var AColumnNames: Pointer):integer; cdecl;
sqlite_finalize:function(ASqlVM:PSQLite; var AErrMsg: pChar):integer; cdecl;


I'm using it this way:


procedure TForm1.Button4Click(Sender: TObject);
var tail:Pointer;
SqlVM:PSQLite;
res:integer;
cc:PInteger;
cv,cn:pointer;
begin
  res:=sqlite_compile(SQLite,pChar('select * from aa;'),tail,SqlVM,ErrMsg);
  if sqlite_step(SqlVM,cc,cv,cn)=SQLITE_ROW then
  begin
  end;
  if sqlite_step(SqlVM,cc,cv,cn)=SQLITE_ROW then
  begin
  end;
  if sqlite_step(SqlVM,cc,cv,cn)=SQLITE_ROW then
  begin
  end;
  sqlite_finalize(SqlVM,ErrMsg);
end;


when I call sqlite_step onetime, everything works OK, byt when I call it
multipletime times (as above) then error occures: "acces violation at
address 673E8B76 in module 'sqlite.dll'. Write of address 0043D4Fs". I have
version 2.8.6 for Windows.

Bronislav Klucka


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [sqlite] database table is locked

2003-11-07 Thread Mrs. Brisby
On Sat, 2003-11-08 at 07:20, Thiago Mello wrote:
> Hi Ben Carlyle, 
> 
> First of all, thanks for your help!
> 
> I can't brig these two operation togethe causa I need the result of the
> SELECT in a if condition.

You cannot do the UPDATE inside of a SELECT callback. You do not need
the results of a SELECT for an UPDATE. Not for this one.

I think you mean:

UPDATE TABLE1 SET number=number+1 WHERE id="JOHN";

Or maybe you meant:

UPDATE TABLE1 SET number=number+1 WHERE name="JOHN";

Either way, it seems an awful like you have a "bigger goal" that you're
trying to solve that you're not explaining here for whatever reason--
instead you assumed you needed to UPDATE inside the SELECT. You can't
and if you show us what you're really trying to do, I'll bet that you
don't either...


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]