Solved

DBX TSQLQuery results missing fields that are defined to always return null

Posted on 2013-05-10
6
537 Views
Last Modified: 2013-07-22
I have defined a query to return 15 columns.  This is one of several where I have designed the queries to return like data from different tables.  In some tables there is a field for full name.  In others there are fields for First Name, Middle Initial, and Last Name.  I have the routine that uses these fields set to see if the name parts are defined.  If they are not then it reads the Full Name field and breaks out the name.

All of this has been working well.  As I added a new query to the list I found I did not have all of the fields defined.  I added the new fields to the query as:
null FirstName,
null MiddleInitial,
null LastName,

Now when I run the query, all of the fields that will always return null are missing (not in the fields list)!

I am looking for a way to make this TSQLQuery.Open statement return all of the fields.
0
Comment
Question by:developmentguru
  • 4
6 Comments
 
LVL 40

Expert Comment

by:Sharath
ID: 39156642
Post your original and the modifed queries.
0
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 39157013
Agree, post it here. My guess goes to this - force type cast for fields like:

cast(null as varchar(100)) as FirstName,
cast(null as varchar(100)) as MiddleInitial,
...
0
 
LVL 21

Author Comment

by:developmentguru
ID: 39163427
The queries are working.  I have one row of data in my result set.  I set an index by name (using the IndexName property) and the one record I have now shows as 0 records.

The data is in a TClientDataset.  You can get data into those without a query, which I am doing here.  I create my dataset independently of several queries, then I add the query results to the client dataset.

using the client dataset I am running into issues.  I have 5 indexes setup from the time I create the dataset (before I add the data).  At one point in the program I run a command like

fCDS.IndexName := 'idxPersonalEmail';

And watch.  Before running that line I have 1 record.  After running it I have 0 records.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 21

Author Comment

by:developmentguru
ID: 39163430
I didn't mention it, but this is being done for a company that is very much against upgrading... it is being done in Delphi 2007.
0
 
LVL 21

Accepted Solution

by:
developmentguru earned 0 total points
ID: 39332939
The routine was using the client dataset within a loop.  I was able to get this working by recreating the client dataset every time I used it.  When the client dataset is recreated each time, before adding the data and setting the index, the setting of the index does not cause the record to disappear.
0
 
LVL 21

Author Closing Comment

by:developmentguru
ID: 39345419
I found a solution to the problem and posted it so others would be able to benefit from it.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to build JSON File in Delphi 6 3 45
Oracle - Query link database loop 8 40
Creation date for a PDB 5 39
firemonkey Android Listview Sort items 7 49
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Via a live example, show how to take different types of Oracle backups using RMAN.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question