• Welcome to SQLitening Support Forum.
 

News:

Welcome to the SQLitening support forums!

Main Menu

Accessing a point in DB

Started by kepler, July 19, 2014, 11:17:07 AM

Previous topic - Next topic

kepler

Hi,

I've already put a VB6 program to read a SQLite file :) But I have to read ALL the records...

Is there a way of getting a specific registry imediatly? Say, record/entry number 77?

Kind regards,

Kepler

cj

#1
drop table if exists mytable;
create table if not exists mytable(RecNum integer primary key autoincrement,comment);
insert into mytable values(null,'one');
insert into mytable values(null,'two');
insert into mytable values(77,'seventy-seven');
insert into mytable values(null,'seventy-eight');

select * from mytable;
select * from mytable where rowid  = 77;
select * from mytable where recnum = 77;

results:
--------------------------------------------------
1  one 
2  two 
77  seventy-seven 
78  seventy-eight 
--------------------------------------------------
77  seventy-seven 
--------------------------------------------------
77  seventy-seven 
--------------------------------------------------


#INCLUDE "sqlitening.inc"
-----------------------------------------------------------------------------------
FUNCTION PBMAIN () AS LONG
  LOCAL s AS STRING

  slOpen "sample.db3","C"

  s=  "drop table if exists mytable;"
  s+= "create table if not exists mytable(RecNum integer primary key autoincrement,comment);"
  s+= "insert into mytable values(null,'one');"
  s+= "insert into mytable values(null,'two');"
  s+= "insert into mytable values(77,'seventy-seven');"
  s+= "insert into mytable values(null,'seventy-eight');"
  slexe s

  s = GetSet("select recnum,comment from mytable where rowid  = 77;") + $CR
  s+= GetSet("select recnum,comment from mytable where recnum = 77;") + $CR
  MSGBOX s + GetSet("select * from mytable where recnum = 77;"),,"Results"

END FUNCTION
-----------------------------------------------------------------------------------
FUNCTION GetSet(SqlStatement AS STRING) AS STRING
  LOCAL s() AS STRING
  slSelAry(SqlStatement,s(),"Q9c")
  FUNCTION = JOIN$(s(),$CRLF)
END FUNCTION
-----------------------------------------------------------------------------------
Results:
77   seventy-seven
77   seventy-seven
77   seventy-seven