Delphi take values from an SQL query [closed] - delphi

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to retrieve text values from this query
FdTmp2.SQL.Text := 'SELECT PATH_FILE FROM STORAGE_DATA';
FdTmp2 is a TFDQuery.
I've tried to do FdTmp2.FieldByName('PATH_FILE').AsString := TEST;
But it tells me Delphi exception EDatabaseError at $8DACF859

It sounds like you might need to review some basic SQL language use, please don't take this the wrong way.
If you are only trying to retrieve the text of the PATH_FILE column, your attempt of
FdTmp2.FieldByName('PATH_FILE').AsString := TEST; is not retrieving anything at all, in fact it is trying to assign the value of TEST to the specific record PATH_FILE in the table you have open. To retrieve the record's value, use TEST := FdTmp2.FieldByName('PATH_FILE').AsString; instead.
EDatabase errors can be kind of generic, maybe the table isn't connected, table isn't open, isn't editable, lots of weird things I've seen. How does a command like
FdTmp2.SQL.Text := 'SELECT * FROM STORAGE_DATA'; work out?
'SELECT PATH_FILE FROM STORAGE_DATA'; This command, once executed, will give you a list of all PATH_FILE values from the table STORAGE_DATA. If your PATH_FILE table has 100 records, you will have 100 records of PATH_FILE to work with. Loop through them if you want, or change your SQL statement to give you smaller, more concise, results.

Related

Exclude unmatched postal codes in Tableau [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have two tables First is called "All postal codes" and 2nd is called the "Office_Location_Postal_Codes". How do I use these tables to get Postal Codes from First Table which are not in 2nd table?
I tried to leave join, but I think it won't get the correct result. What should I do to get the unmatched postal codes from "All postal codes" Table.
Note : My first table is in SQL server and 2nd one is in Excel File
I have resolved the issue by taking Right join with office postalcodes and filter out offices = Null
Step 1 Right Join
You can also use left join depending on the Master Table. My Master table is in right thats why i take right join
Step 2 Filter Where Office = Null
Put office field (or the field where postal code is located) on filter shelf and select 'NULL' only

How to consolidate data in google sheet using query function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Hell,
I encountered one problem while combining different sheets(tabs) into one master sheet, e.g I have three sheets named Cola, Pepsi & Thumbsup, I consolidated their results all in my Master sheet using Query formula with null. Whenever anyone entered data in Cola, Pepsi & Thumbsup sheet it comes to my master sheet somewhere in Between the rows. I need it to comes queue wise, is it possible?
The problem I faced is, I am writing a remark on my master sheet on each entry so whenever someone added new data in Cola, Pepsi & Thumbsup it inserted in between the data and break the sequence of my remarks.
The remark I wrote for e.g Cola 103 it shift to cola 102 when someone enters new data in cola sheet.
About the query, it just displays the values. It's kind of impossible to control as your mention. I recommend to use app-script (macro), function append or getValue setValue or getRange copyto as text paste not just display
If your data have timestamp each row. It might work, sort by depending on date and time added. Need to use just one column sorted. In function query ...order by A asc
Anyways, I still recommend to use app-script (macro)

field num_med cannot be modified [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I've put this code in a speedbutonclick but when I'was trying to execute it I got the message that said field num_med cannot be modified
the code is
procedure TAddEdiMedForm.SpeedButton1Click(Sender: TObject);
begin
DM.MedicamentTable.InsertRecord([ Edit1.Text, Edit2.Text, Edit3.text,
Edit4.Text, Edit5.Text, Edit6.Text,
Edit7.Text]);
CloseModal;
end;
The problem is trying to insert a value for an AutoInc field, which you are trying to do with your InsertRecord statement. You need to retrieve the AutoInc value (from the server) after the new row is inserted, not try and force a value from the client side!
Since you can't specify a value for the AutoInc field when you add a new row, you need to avoid using InsertRecord. Instead, call Insert on tthe dataset, populate the other (non-AutoInc) fields by individual assignment statements, then call Post. How best to retrieve the AutoInc value depends on the back-end server, though FireDAC usually does a pretty good job of doing this for you - look up how to get the value from the Online Help or google it.
You should have mentioned that the Num_med field is an AutoInc in your q, not blithely say that it is an Int field in a comment in reply to a query for info you should have supplied in the first place. In future, please exercise a bit of consideration for readers here by including all relevant info in your initial q.

Comparing 2 items of an listbox and 2 lines of a Memo [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
How to compare 2 items of an listbox and 2 lines of a Memo?
How do I give an item of an Listbox a variabele? How do I give a line of a Memo a variabele?
ListBox items
The contents of a ListBox is stored in TListBox.Items which is of type TStrings. This is a zero-based list/array of strings, thus in order to get the second item in the ListBox call one of the following:
ListBox1.Items.Strings[1], or
ListBox1.Items[1], because Strings[] is the default property.
Memo lines
The contents of a Memo is stored in TMemo.Lines which also is of type TStrings, thus to get the first line of the Memo, call:
Memo1.Lines.Strings[0], or
Memo1.Lines[0].
Comparison/relational operators
= equality
<> inequality
< smaller
etc...
All together
Thus to compare the first line of the Memo with the second item of the ListBox, do:
if Memo1.Lines[0] <operator> ListBox1.Items[1] then
For example: when you want to check whether both are equal:
if Memo1.Lines[0] = ListBox1.Items[1] then
Going advanced
Maybe a simple comparison operator does not give enough information about the difference between the two strings. Then use a function instead of an operator to compare the two strings, see the units SysUtils and StrUtils. For example, when you want to compare both strings for having the same text, regardless case:
if SameText(Memo1.Lines[0], ListBox1.Items[1]) then
Comparing 4 items simultaneously
Concatenate two comparisons with a boolean/logic operator:
if (Memo1.Lines[0] = ListBox1.Items[0]) and (Memo1.Lines[1] = ListBox1.Items[1]) then

How can you map IDs even when duplicates are eliminated? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I currently have a large set of objects in SAS (>100000) each with about 60 columns of data, including an ID number. There are many duplicate ID numbers in this set of data. My goal is to convert the ID numbers that I currently have into another form of ID number using a piece of software that I have. The problem is that when I input the ID numbers into the software, the converted output comes back without the duplicates, which I need. Is there any way to use the output ID numbers to somehow create a list of output IDs except with the duplicates that the original set of data had. Any language or piece of software would be fine.
Here is a illustration of what I described above.
Original IDs: 086516 677240 449370 677240 941053 449370
Output: 147244 147947 147957 148021
Preferred Output: 147244 147947 147957 147947 148021 147957
You can merge on the ID using a MERGE statement, and it will append the value to each of the records with the same ID value.
data want;
merge have(in=a) newIDs(in=b);
by id;
if a and b;
run;

Resources