field num_med cannot be modified [closed] - delphi

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.

Related

Delphi take values from an SQL query [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 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.

A formula to group timeslots? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a column in my Google Sheet that shows timeslots for appointments in the following format:
07:15-07:45
09:00-09:30
12:45-13:15
16:30-17:00
In a new column, I would like to condense these into groups so that for instance any timeslot between 07:00-10:00 would be "Early Morning" 10:00-13:00 would be "Late Morning/Early Afternoon" etc.
How would I be able to do this with a formula?
Please try the following
=ArrayFormula(IFERROR(IFS(
IFERROR(REGEXEXTRACT(A2:A11,"(.*)-")*1,"")<TIMEVALUE("10:00:00"),"Ear.Mor.",
IFERROR(REGEXEXTRACT(A2:A11,"(.*)-")*1,"")<TIMEVALUE("13:00:00"),"Lt.Mor.",
IFERROR(REGEXEXTRACT(A2:A11,"(.*)-")*1,"")<TIMEVALUE("16:00:00"),"Ear.Aft.",
IFERROR(REGEXEXTRACT(A2:A11,"(.*)-")*1,"")<TIMEVALUE("19:00:00"),"Lt.Aft.")))
OR
=ArrayFormula(IFERROR(IFS(
IFERROR(INDEX(SPLIT(A2:A11,"-"),0,1),"")<TIMEVALUE("10:00:00"),"Ear.Mor",
IFERROR(INDEX(SPLIT(A2:A11,"-"),0,1),"")<TIMEVALUE("13:00:00"),"Lt.Mor",
IFERROR(INDEX(SPLIT(A2:A11,"-"),0,1),"")<TIMEVALUE("16:00:00"),"Ear.Aft",
IFERROR(INDEX(SPLIT(A2:A11,"-"),0,1),"")<TIMEVALUE("19:00:00"),"Lt.Aft")))
(You can adjust ranges to your needs)
Functions used:
ArrayFormula
IFERROR
IFS
INDEX
TIMEVALUE
REGEXEXTRACT
SPLIT
Welcome to StackOverflow. Since I'm also the new member here like you, I would like to give you some advice and answer your question.
While asking a question there are some rules to follow:
you should give the important information about your question before putting your code
don't ask someone for a direct code. Try to handle it by yourself with doing a research about your question. Maybe there is already an answer to your question which can give you better idea than someone's answer in your post.
we all should understand that most of people here are busy with something. So we should respect their time and not ask already answered question or without having a code.
you can find more about how to ask a question here. I hope it'll help you to at least give an idea of what StackOverflow is.
For the answer to your question, I would suggest that to separate beginning time of appointment and end of it to different columns. Then you can write a formula using if statement like this: IF(AND(D2 > TIME(7,0,0), F2 < TIME(10,0,0)),"Early Morning"," another if statement ") Assume that D2 is beginning of appointment and F2 is the end. I might have made a mistake but overall idea is like that. Please refer to those links for more information about if statements and timeslots:
https://exceljet.net/excel-functions/excel-if-function
https://www.excelhow.net/how-to-compare-time-difference-with-certain-time-in-excel.html

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

iOS / Xcode: saving datalist ipad [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
im new to iOS/xcode app and have a question.
If i make a form with "name" "age" "date now" how/where is it saving the info and how do i make new items ?
Have tried to search google for "xcode saving item to list" but its not what im looking for.
Can someone help me with a link to a tutorial or the name function that i need to look at.
So i can read/learn about
- save function
- show the saved items in a list.
- get one or more saved items to another page/view in the app.
First you need to deal with getting notified when the text in each field changes. This is done by using the delegate methods of the text fields (<UITextFieldDelegate>). In particular, textFieldDidEndEditing: will allow you to grab the text when the edit is complete.
Once you have the text, you need to store it somewhere. This could be in a dictionary, or, if you want to display in a list, it could be in an array.
A dictionary is easier if each of the text fields means something different. Then the keys of the dictionary represent the meaning.
An array is easier if it's just a list of arbitrary text. The issue here is how to know that you haven't got duplicates. In this case it can be better to have a submit button which loops over all of the text fields in order and adds the text from each to the array.
Once you have the text in an array or dictionary you can save it to disk (writeToFile:atomically:) or use that as the source data for a table view.

VLOOKUP on continuous form [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
On K250 cell I've this put a formula so that when user submit data via form formula will work.
=VLOOKUP(F250,Available!$C$1:$E$72,3,false))
But problem is when someone submit a form, row K250 is getting down as K251 & submitted form taking palce K250. I've found some other guys are talking about using Array. I've tried this one but didn't work.
=arrayformula(VLOOKUP(F250,Available!$C$1:$E$72,3,false))
Whats the solution?
If i understood your problem correctly then do this:
Instead of giving a fixed range , use name ranges to avoid this problem.
To access name ranges you can use F3 key while typing vlookup.
Following are some screenshots to help you out.
It should work even your cells shift towards down, if the shifting is happening towards right then you might want to select the entire sheet to avoid confusion.
Hope this helps to solve your problem.
When a form submission is made in Google Sheets, a new row is inserted in the sheet receiving the form submissions, and yes, this will "push down" any formulae that were previously in that row.
And yes, one solution is to use an array formula. Something like this could be entered in row 1:
=ArrayFormula(IF(ROW(F:F)=1;"Column Header";IFERROR(VLOOKUP(F:F;Available!$C$1:$E$72;3*SIGN(ROW(F:F));0)))
Multivalue Parallel Lookup Solution
Note: if this answer is in the right ballpark, I will try and edit your question and tags accordingly.

Resources