• Welcome, Guest. Please login.
 
May 07, 2021, 09:47:56 PM

News:

Welcome to the SQLitening support forums!


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

July 19, 2014, 10:32:24 PM #1 Last Edit: July 19, 2014, 10:56:15 PM by cj
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