Delphi - Quick Report(Dynamic report preview) - delphi

I am creating run time report(Quick report).
1. Create QRSubdetails band.
Assign parent, master and dataset.
2. Create one RQ label
assign parent
3. Create QRDbText
assign dataset and datafield and parent field
4 Write Select statement and open query.(select name from Member)
assign to column name to TQRDBText .datafield:='name';
Problem - In report first row is printing 'Name' instead of actual data from table. Rest of record is print properly except first row data. Could anybody help me what are property I am missing ?

Related

How to select cases with same value in one variable but at least one value in two other variables in SPSS?

I have a dataset in SPSS as follows:
Key variables:
k_hidp is the household identifier
pidp_parent is the personal
identifier of the parent
pidp_child is the personal identifier of
the child
I would like to extract all data from households with at least one valid value in pidp_parent and one valid value in pidp_child.
For example in the above data excerpt: On line 6-7, we have household #68639220. I would like to extract data from both line 6 & 7, how could I do so in SPSS?
Thank you.
The following aggregate function will identify the maximum child ID and maximum parent ID for each household. Households where all parent IDs are missing will show missing in maximum parent ID and we will know to deselect them - same for child.
aggregate out=* mode=addvariables/break=k_hidp
/mxParent mxChild=max(pidp_parent pidp_child).
compute forAnalysis=not missing(mxParent) and not missing(mxChild).
The new variable forAnalysis has value 1 for households that have at least one valid parent ID and one valid child ID. You can use if to select or filter or otherwise identify the lines relevant for analysis.

Delphi, Master-Detail with DetailFields in the where condition (not in select-part)

I am using master-detail connection to show a list of assigned columns of a detail-table. In addition i want to show a second grid with not assigned detail columns
Example
Master-Table t_human: idHU, nameHU (like John, Oscar, ...)
Detail-Table t_property: idPO, namePO (like male, female, blond hair, beard, blue eyes ...)
Join-Table t_hu_po: idHU, idPO
-> John - male, blond hair
-> Oscar - male, blue eyes, beard
When i select a master table row i want to show the assigned porperties and also the not assigned ones. The master-detail for the assigned properties works fine.
But for the not-assigned properties doesn't work.
Detail-SQL:
select p.idPO, p.namePO
from t_property p
where not exists (select * from t_hu_po hp where hp.idHU = :idHU and hp.idPO = p.idPO)
Master-SQL:
select idHU, nameHU from human
When i try to select the detailfield in the delphi component (Devart, SDAC, TMSQuery) it only shows me the fields for p.idPO and p.namePO. The :idHU parameter in the statement is configured as parameter for the query in the component. When i manually type the idHU in the DetailFields property of the Dataset (TMSQuery) i get an Invalid column name 'idHU'.. from delphi when activating the query.
Does someone knows a better solution than doing it with events for datachange and manually setting the detail-parameter and refreshing the detail-query.
My thought was, that master-detail would do the same thing but only in background, so that i don't have do code it.
Thanks
Stephan
Instead of using the where not exists try where p.idPO not in (Select idPO from t_hu_po where idHU=:idHu)
By makinge the subquery simply return all the idPOs that exist for the selected idHu, your query now looks for the properties that are not in that list.

How to change format / treat missing values in SPSS

I'm using SPSS modeler and I have a variable that the software recognizes as numeric. So the missing values are $null$. I want that the missing values of the variable are selectionable with '', as character.
So I would: or trasform the format of the variable from numeric to character or change only the missing values from $null$ to ''.
How can I fix?
thanks in advance
The best way to select null values in a numeric field is to use the #NULL() function from the Blanks and Null section of the Expression Builder.
For example, if you wanted to keep only the null values so that you could inspect them, you might use a Select node. Leave the radio button set as Include. Press the Expression Builder (calculator) button. Change the filter in the drop menu on the left side from General Functions to show Blanks and Null (press B 2 or 3 times). Double-click on #NULL(ITEM). Go to the right side and double-click on your numeric field name. Put a Table node at the end and run it.
Using Select #NULL in IBM SPSS Modeler
Another way to view just the null rows is to enter the #NULL(varname) function into the "Highlight records where" section of the Table dialog box.
"Highlight records where" dialog
When you run the table, any row that is true for this condition will be shown in red.
If you really need the variable to be a string, then use a Compute node to create a copy of this field under a new name and use the to_string() function in the Conversion section of the Expression Builder to change the type of the variable. Now you will be able to use the the Select node to grab "" as the missing value. Or you could use the Filler node to replace the column, but then you would not be able to compare before and after.
The dialog examples shown in this answer use this sample stream that is installed with your IBM SPSS Modeler software:
C:\Program Files\IBM\SPSS\Modeler\18.0\Demos\streams\featureselection.str
The easiest way to do it it's using the Fill node with the configurations:
A) FIELD
B) Condition = #NULL(#FIELD)
C) Replace by = ' '
This node will replace all $null$ for ' ' at the same variable chosen in option a.
I don't think you can customize how you visualize $nulls. (I know it's possible in SQL db though)
So I'd suggest that you work with the numbers and when you want to visualize or export the results, then turn the field to a string one then replace nulls:
Filled node > to_string(#FIELD)
Filler node > blank and nulls > #FIELD = ''

Recognize the type of the parameters of a user defined sql to be used in a Delphi TQuery at runtime

I'm writing a delphi(7 ver) application and in some place I want to execute parameterized queries (for BDE and Paradox) which will be loaded at runtime into a TQuery by the user. These queries will be stored in text files (one text file for one query). The application then, will construct for any parameter of the query, one input control (Tedit) in order to be able to accept values by the user. Also there will be a button for the execution of query. My question is how can I recognize the datatype of the query's parameter? Is there a way to get this type without of cause to be included in some way in the text file containing the query?
Create a second query from the first, but modify its where clause to ensure no rows.
SELECT * FROM MYTABLE WHERE PKFIELD IS NULL
Name your parameters so that you can establish their datatypes from the fieldtypes of this second query.
I realise this only works for relatively simple cases, but it should get you some of the way.
the advantage of using a parameter is that you don't need to know its data type.
Use the string value from the tedit
"select * from mytable where myfield = :param1"
"parambyname('param1').asstring := edit1.text"
I've made this with MySQL database. you must define some parameters, Exemple:
SELECT * FROM MyTable WHERE MyField=[ANNEE];
in this case, i have an other table, called balise, that look like this
"ID" "BALISE" "CAPTION" "DEFAULT_VALUE" "CNDT" "COMPOSANT"
"1" "ANNEE" "Année" "2014" "Properties.MaxValue=2014||Properties.MinValue=2007" 1;
in runtime, this mean that:
Make in my Panel, a TLablel that have caption Année
Make in the same line an other component type 1 (That mean in my case TcxSpinEdit), this component have défault value 2014, have Two properties Max Value=2014 and Min Value=2007, (I use RTTI to modifie this value of parameters, in Delphi ver7, use TypeInfo).
An Other Button with function called Actualise, this function have Original query, must browse an array of TBalise that i have created, take the value (In my case, take TcxSpinEdit(MyObject).Value), and replace it in the copy of my query (AnsiReplaceStr(Requete, '[ANNEE]', MyValue)), so i have the final query to execute it.
I have module in complete projet, worked with this methode, and it workk fine.

TSQLQuery not returning right amount of records

I have a table called Artist which currently contains four records and a TSQLQuery that contains the following statement:
SELECT name
FROM Artist
The table Artist also contains the following records:
id name
1 Artist 1
2 Artist 2
3 Artist 3
4 Artist 4
Current method of record retrieval:
Query1.Open;
for i := 0 to qArtist.FieldCount -1 do
with cbArtist.ListBox.ListItems[i] do
Text := qArtist.Fields[i].AsString;
Previous method of record retrieval:
Data bind Query1 to ComboBox1.
With the "previous" method, ComboBox1 would display all the expected records from the Artist table. However, when I try to use "current" method Query1 is only selecting the very first record from the Artist table despite there being three other existing values. I have tried the "current" method across other queries and they also returned only the first value of the table.
The reason I am going for this new approach is because I feel that I am very limited in what I can do if I continue to the "previous" / data bind method, but that is besides the point.
So how can I fix this problem? i.e. the problem of the query only selecting the very first record from the table.
You must use the Eof and Next methods to iterate over the records.
Query1.Open;
while not Query1.eof do
begin
cbArtist.Items.Add(Query1.FieldByName('Artist').AsString);
Query1.Next;
end;
You code show an interaction over fields, if you need iterate all record then you must use a code like:
Query1.Open;
Query1.first;
while not Query1.eof do
begin
with cbArtist.ListBox.ListItems[i] do
Text := qArtist.Fields[1].AsString; //put here field you want to bind on ListBox.
Query1.next;
end;
I don't think you are navigating your query's dataset correctly. The FieldCount and Fields[i] access the field metadata (columns going across), not the rows. I beleive in Delphi you use While not Eof begin... end.
Navigating Datasets
I would consider altering the data binding fields to suit your needs. Delphi's Databinding is very powerful. Manually iterating the dataset just to populate a control will just be extra code where bugs can hide. Utilize the built-in capabilities of the tools and it will be easier to understand and maintain.

Resources