I haven't used SQL to load records into objects but the command Selection
to JSON
<http://doc.4d.com/4Dv16R6/4D/16-R6/Selection-to-JSON.301-3547940.en.html>
does allow you to load multiple fields, as well as fields from different
tables.

Refer to the section entitled "Example 2" which is new in the docs for V16
but the code works in V15 and perhaps as far back as V14, the version in
which it was introduced.

As far as I know, you will have to assign the field pointers individually,
which is a drag, but you *will* get JSON from the selection.

Seeing that SQL doesn't change the current selection, you can restore the
selection by using the named selection commands or by using a set.



--
Douglas von Roeder
949-336-2902

On Thu, Mar 22, 2018 at 10:28 AM, Kelderic via 4D_Tech <4d_tech@lists.4d.com
> wrote:

> I have a database with tables that are linked together via IDs. Simplified
> example:
>
> CallLogs Table
> UniqueID, Date, Type, Log, CustomerID
>
> Customers Table
> UniqueID, FirstName, LastName, City, State
>
> A CallLogs record will be linked to a Customers record by:
>
> [CallLogs]CustomerID = [Customers]UniqueID
>
> ----------------
>
> All of that is working. I have been using Selection to JSON to send data
> from the DB out to a web app. However, the list of CallLogs doesn't have
> the
> name of the linked Customer, because Selection to JSON only works with one
> table.
>
> I want to be able to return a joined set of data.
>
> With SQL, I can do a JOIN request into an array of objects, and then
> convert
> that array to JSON to send out. However, I can't figure out how to get a
> joined set of data out of 4D. I can't even get multiple fields in ONE
> table,
> into an object array.
>
> Here is what I have tried:
>
> ----------------
>
> ARRAY OBJECT(aoRecords;0)
>
> Begin SQL
> SELECT *
> FROM CallLogs
> INTO :aoRecords
> End SQL
>
> ----------------
>
> Is there a way to accomplish this besides querying and then looping through
> and building the arrays myself? Thanks!
>
>
>
>
> --
> Sent from: http://4d.1045681.n5.nabble.com/4D-Tech-f1376241.html
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to