New topic: 

Get table name of column in a RecordSet

<http://forums.realsoftware.com/viewtopic.php?t=33850>

         Page 1 of 1
   [ 2 posts ]                 Previous topic | Next topic          Author  
Message        basil.bourque          Post subject: Get table name of column in 
a RecordSetPosted: Tue May 18, 2010 10:20 pm                         
Joined: Thu Apr 15, 2010 10:41 pm
Posts: 10
Location: Seattle-area                I cannot find a way to get the table name 
of a column in a RecordSet. 

The only meta-data I have found is to:
(1) Call the RecordSet's "IdxField" command to get a DatabaseField
(2) On that DatabaseField, call "Name" to get the column name.

But I see no way to get the name of the table for that column. For a single 
table query, of course, I know the table. But for a JOIN across tables, I want 
to auto-magically detect the source table for each column.

I see only two solutions:

(A) Insert the "AS my_special_column_name" clause for every column in my SELECT 
statements, to include the table name or some clever naming system I must 
devise.

(B) Use SQLite's PRAGMA settings to have the default name for each column in a 
result set include both the table and column name:
Customer.FirstName | Customer.LastName
rather than 
FirstName | LastName

To do that, my experimenting in REAL Server Admin app's Console and my reading 
of the SQLite doc suggests I should set these two pragmas in every database 
session:
Code:PRAGMA full_column_names = 1;
PRAGMA short_column_names = 0;

To get the current pragma value, drop the last part:
Code:PRAGMA full_column_names;
PRAGMA short_column_names;

Is (B) the route to take? Some other way?

--Basil Bourque

(Using REAL Server 2009r1.2 with REAL Studio 2010 release 2 on Mac OS X 10.6.2 
& .3)   
                             Top                 timhare          Post subject: 
Re: Get table name of column in a RecordSetPosted: Wed May 19, 2010 12:02 am    
                     
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 7779
Location: Portland, OR  USA                When I care, or when there is a 
conflict, I use A.   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 2 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to