SQL,DB's, and LiveCode

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tjm167us
Posts: 50
Joined: Sat Dec 03, 2011 8:27 pm

SQL,DB's, and LiveCode

Post by tjm167us » Wed Nov 13, 2013 10:23 pm

Hello everyone,
I know there is a "Database" forum, but I have come to know people in this forum and don't like making new friends ;). I just started using databases with LiveCode have some nagging questions I can't find in the docs.
When setting up an ODBC connection to a database, the liveCode lesson: http://lessons.runrev.com/s/lessons/m/4 ... using-odbc
has you follow a bunch of steps to create an ODBC connection and add a new "Data Source" for the test database. As part of these steps, they require that you point to the database that you want to open.

1. Does this mean that you can only use this ODBC connection for this one database? If I wanted to create another ODBC connection for another database, would I have to do this again?
2. How can you query two databases that belong in different directories? I found that the following simple join query works if the two databases are in the same directory:

Code: Select all

SELECT a.ID,b.ID "&\
        "FROM "&dB_aPath&".Table1 AS a "&\
        "LEFT JOIN "&dB_bPath&".Table1 AS b "&\
        "ON a.ID = b.ID
3. Any general pointers would also be appreciated regarding using LiveCode to interface to databases!

Thanks,
Tom

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: SQL,DB's, and LiveCode

Post by Mark » Thu Nov 14, 2013 1:17 am

Hi Tom,

I understand from the lesson that you need to create connection for each database. I don't use MS Access, so I don't know, but I wonder if there is a way to add multiple databases to one connection.

What are the values in dbA_Path and dbB_Path? If you're using relative paths, try using absolute paths instead.

My book contains a section on databases, but not ODBC. It does tell you how to use LiveCode's database functions and commands.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: SQL,DB's, and LiveCode

Post by snm » Thu Nov 14, 2013 7:42 am

You can Open and use as many databases as you need in the same time, but single SELECT statement can be addressed to only one of them. So you must także data from one db, then from second db, and then do the rest in your code.

Marek

Post Reply