SQL access to TPS databases without ODBC driver

Here is standard SCHOOL application demonstrating a possibility to SQL access to TPS databases. Just run school.exe, there are 2 items under “SQL” menu: “Browse Teachers with SQL filter” and “Arbitrary SQL Queries”.

First item opens Teachers browse and allows to filter like

t.LastName LIKE(‘C%’) AND m.Description IN(‘Law’, ‘Sociology’)

where t and m are aliases for Teachers and Majors tables, respectively.

Second item allows to execute any arbitrary SELECT statement against entire database, for example:

– sample sql script:
SELECT s.lastname || ’ ’ || s.firstname AS “full name”, s.Number AS number,
s.GradYear AS “grad year”, m.description AS major,
s.city AS city, s.telephone AS phone
FROM students s
JOIN majors m ON m.number=s.major
ORDER BY s.lastname

and immediately see the result set in listbox.

I hope this is interesting to someone.

3 Likes

Hi Mike,

Well that is interesting :slight_smile:
How are you doing it?
I suppose the presence of the SQLite DLL must be a clue.

Are you somehow creating a DNSless TPS connection and querying it via SQLite or …?

Graham

we magicians do not reveal our secrets :slight_smile:

sqlite can use in memory databases https://www.sqlite.org/inmemorydb.html so we may think that Mike is using that facility :slightly_smiling_face:

sqlite is a hat which the audience sees, sql filter to real TPS data is a rabbit :slight_smile:

Hi MIkee!
How do it…?

It’s very interesting.

it’s relatively easy to replicate that functionality creating a in memory db by using the sqlite driver or by connecting directly to the database.

Oh! excellent !! Please !! Tell me how to do it with an example.
Thank you !!

You have an example using the sqlite driver in the school application that came with clarion.
It can be modified to use in memory database inserting as owner “:memory”.
Also check the example SQLScriptor (executes sql code as a series de sql commands).
If you want to access the sqlite database without using the sqlite driver, you can use the excelent class made by John Taylor.
Also, remember to use SQL as understood by sqlite. There are some differences.but check the sqlite documentation that is very good.
Eventually, if you still have problems put the specific question here.

If your time is worth more than it would take to re-invent a wheel with fewer features, another option is to buy Mike’s SQLite-x addon, which has facilities in it like the demo. GitHub - mikeduglas/sqlite-x: Native SQLite access for Clarion