[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

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

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
developmentguru
Asked:
developmentguru
  • 4
1 Solution
 
SharathData EngineerCommented:
Post your original and the modifed queries.
0
 
Sinisa VukCommented:
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
 
developmentguruAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
developmentguruAuthor Commented:
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
 
developmentguruAuthor Commented:
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
 
developmentguruAuthor Commented:
I found a solution to the problem and posted it so others would be able to benefit from it.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now