While loop lazarus / 16-Databases ---------------------------------------------------------------------- Paulnewyork · 2020-06-09 18:59 Hello I have a Problem with the while loop: the if else condition in the loop works But the program freezes and the CPU for this process is at 30 percent. I think the loop doesnt stop. It should stop at p=1 or variablePrice has reached stringPrice (it can be the same value). But i have to Check every Price when StringPrice is higher than Variable Price. And i Tested also a higher Price and changed  in the the of else cobdition in the loop To StringPrice >= variablePrice But than nothing happens, but the string price I choose is higher. IF  no if elese matches and ervery price is checked with every if elses than p:=1 but i don`t know where to write tis. because inside the loop is actually wrong I have three more if else, but they are not in the code already, because I just wanted to try with this first. ---------------------------------------------------------------------- Blaazen · 2020-06-09 19:49 At first, do proper indentation and place missing semicolons. Also, put your code to tag < code >. Even the beginning of your code is wrong and wouldn't compile (begin end else): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i IF ( stringPrice < variablePrice)THENP:= '1';BEGINEND   ELSE ---------------------------------------------------------------------- Paulnewyork · 2020-06-09 20:21 The beginning was something I added later just here. But I changed that now. ---------------------------------------------------------------------- TRon · 2020-06-09 21:00 As Blaazen already wrote: please USE CODE TAGS (click on me to learn all about them) ---------------------------------------------------------------------- Paulnewyork · 2020-06-10 05:32 Sorry, I am new to that. Here is the code.....looks totally better to read. Thank you for support! Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   stringPrice:= Form2.SQLQuery1.FieldByName('price').AsString;stringPruefpunkt Form2.SQLQuery1.FieldByName('p').AsString;stringName:= Form2.SQLQuery1.FieldByName('name').AsString;stringNachname:= Form2.SQ LQuery1.FieldByName('nachname').AsString;   Form2.connectDB;Form2.SQLQ uery3.SQL.Text := 'SELECT price FROM tabelle2 WHERE price= (SELECT min(price)FROM tabelle2)';Form2.SQLQuery3.Open; variablePrice := Form2.SQLQuery3.FieldByName('price').AsString; IF ( stringPrice < variablePrice)    THEN    BEGIN    P:= '1';END   ELSE     While ((variablePrice <= stringPrice) OR (p < '1'))     DO     BEGIN     Form2.SQLQuery1.SQL.Text := 'SELECT * from sold WHERE price ='''+variablePrice+''';';     Form2.SQLQuery1.Open;       // IF variablePrice = null      // THEN      // BEGIN      // variablePreis := variablePrice + '2';      // end      // ELSE     //Begin        variablePrice := Form2.SQLQuery1.FieldByName('price').AsString;       variableName := Form2.SQLQuery1.FieldByName('name').AsString;       variableNachname:= Form2.SQLQuery1.FieldByName('nachname').AsString; // First condition....everything has to fit    but i stringprice >= variable nothing happens// stringPrice = variablePrice  than the program IF ELSE makes the insert into....       IF ((stringPrice = variablePrice) AND (p = '0') AND (stringNachname = variableNachname)        AND (stringName= variableName))       THEN       BEGIN       Form2.SQLQuery1.SQL.Text := 'INSERT INTO tabelle3 (....) values (...)';       p := '1';       Form2.closeDB;       END // here are two more IF ELSE Conditions which i am going to add later and they are the same like above but the differen is//    stringNachname > variableNachname   and stringNachname < variableNachname     // this is something that should happend after the loop when every price in the db was checked, but i dont no where to put this     ELSE     p := '1';     END       variablePrice := variablePrice + '2';END END;END; ---------------------------------------------------------------------- TRon · 2020-06-10 06:21 Thank you Paulnewyork, Perhaps not the most elegant answer (i apologise in advance for that), but in order to help you improve: For starters: 1 Formatting (see below) 2 This code does not compile 3 Even if it is a snippet (which does not necessarily have to compile), it should be at least valid code (f.e. see Line 3, but also sloppy 57, 58 ) 4 SQL Insert can not be done with method Open but should be done with method ExecSQL 5 variablePrice is a string. if i read your code "variablePrice := variablePrice + '2'" and "(p < '1')" then i have a suspicion that you expect a numeric returned answer ? It is nearly impossible to help you because of a) the above and b) we have no idea what you are trying to accomplish (although you did made an attempt in your first post, sorry it was unclear for me) and c) you are guessing what is happening ("i think ..") Those are all bad ingredients for retrieving help. It would be helpful for yourself if you could improve that situation. For example by describing step by step what exactly you expect your code to accomplish. For example on a personal note, i do not speak SQL, so your code makes even less sense for me personally  Somewhat better formatted code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i begin  stringPrice:= Form2.SQLQuery1.FieldByName('price').AsString;  stringPruefpunkt Form2.SQLQuery1.FieldByName('p').AsString;  stringName:= Form2.SQLQuery1.FieldByName('name').AsString;  stringNachname:= Form2.SQLQuery1.FieldByName('nachname').AsString;    Form2.connectDB;  Form2.SQLQuery3.SQL.Text := 'SELECT price FROM tabelle2 WHERE price= (SELECT min(price)FROM tabelle2)';  Form2.SQLQuery3.Open;   variablePrice := Form2.SQLQuery3.FieldByName('price').AsString;   if ( stringPrice < variablePrice) then  begin    P:= '1';  end    else    while ((variablePrice <= stringPrice) or (p < '1')) do    begin      Form2.SQLQuery1.SQL.Text := 'SELECT * from sold WHERE price ='''+variablePrice+''';';      Form2.SQLQuery1.Open;       // IF variablePrice = null      // THEN      // BEGIN      // variablePreis := variablePrice + '2';      // end       // ELSE      //Begin       variablePrice := Form2.SQLQuery1.FieldByName('price').AsString;      variableName := Form2.SQLQuery1.FieldByName('name').AsString;      variableNachname:= Form2.SQLQuery1.FieldByName('nachname').AsString;       // First condition....everything has to fit    but i stringprice >= variable nothing happens      // stringPrice = variablePrice  than the program IF ELSE makes the insert into....      if ((stringPrice = variablePrice) and (p = '0') and (stringNachname = variableNachname) and (stringName= variableName)) then      begin        Form2.SQLQuery1.SQL.Text := 'INSERT INTO tabelle3 (....) values (...)';        p := '1';        Form2.closeDB;      end       // here are two more IF ELSE Conditions which i am going to add later and they are the same like above but the differen is      //    stringNachname > variableNachname   and stringNachname < variableNachname       // this is something that should happend after the loop when every price in the db was checked, but i dont no where to put this      else       p := '1';    end;  // while   variablePrice := variablePrice + '2';end; END;END;  Please do not let my post discourage you. ---------------------------------------------------------------------- Paulnewyork · 2020-06-10 09:55 Sorry for all this mistakes :/ I am going to answer the questions: 4. After the insert  I oben a procedure:        Form2.closeDB; In this procedure there is the Exec command. 5. In this strings are prices, which are varchar in mysql. Thats maybe the reason why this is not working: variablePrice := variablePrice + '2' stringPrice is a price which was entered whith some other information. VariablePrice is the price in the database. stringprice is for a buying price and variablePrice is for sell. If the buy price is smaller than sell price, no trade is done. than the variable p is true/1 p is something like "check done". just for better understanding. If not the While starts at the lowest variablePrice. First i select all information at this lowest price. and then i check if my IF ELSE the strings with the variables, i select from the database. If one IF ELSE fits than i assign P:=1 if no IF ELSE fits, than the variablePrice is +2 Than i select every information which belongs to the new variablePrice. Than I check my if else conditions again. If nothing fits I add to the variablePrice 2 again. and select the information which belongs to this new variablePrice again and so own the while should stop when the variablePrice is the same like stringPrice or it should stop when p=1; When the while is finished I Want to :   P:=1 So this should be done actually pretty easy  after the while and not inside The p is just for comparison. I hope it is now better to understand. It is a little bit difficult to post the complete code. Otherwise i have to change some information inside. But maybe you can help me. I think i have to convert string to int: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i varintVariablePric : int;intstringPrice : int;beginintVariablePrice:= StrToInt(VariablePrice);  intstringPrice:= StrToInt(StringPrice);    intstringPrice := intstringPrice +2;  And After intstringPrice := intstringPrice +2; I have to convert to string again to get all the new information from the database where the new variable price is?? Is this understandable? ---------------------------------------------------------------------- TRon · 2020-06-10 10:47 Quote from: Paulnewyork on June 10, 2020, 11:55:26 amSorry for all this mistakes :/ There is no need to be sorry, we all have been a rookie once in our lives  Quote5. In this strings are prices, which are varchar in mysql. Thats maybe the reason why this is not working: variablePrice := variablePrice + '2' You are adding two string, which means that the characters in variablePrice are being concatenated with '2'; For example let''s assume the initial 'value' of VariablePrice was literally the text "600". then you add "2" then variablePrice then becomes "6002". The next iteration VariableProce becomes "60022", etc. QuoteBut maybe you can help me. I think i have to convert string to int: Yes, your code example is correct  Now that they are numeric values the comparison will make sense and act like you expected it to act: like a number. PS: do not forget about your "P" value, you are also there comparing either a character or a string (i did not see the declaration of the variable P). QuoteI have to convert to string again to get all the new information from the database where the new variable price is?? Yes. Just as an observation, if i store numbers into a database then it is common to have them stored as a numeric field inside the database. That way you can retrieve and store the numeric field directly into a number (integer) variable (or compare them), without he need to convert them forth and back. QuoteIs this understandable? It is better, at least i am now able to make some sense of what you are trying to accomplish in combination with your code. QuoteIt is a little bit difficult to post the complete code. Otherwise i have to change some information inside. If you really can not share the code then that is ok. It is not always possible to share it, and we all can understand that. What you could do though (it is merely a suggestion, you do not have to take up on it), is to create a small test-project that 'mimics' the situation from your work project. Usually that helps in better understanding your own code as well, and you would not be the first to 'fix' his/her own bugs wile making such a test-project :-) I will address some things in another post, this way you can at least continue and perhaps post a better and improved snippet ? ---------------------------------------------------------------------- Paulnewyork · 2020-06-10 11:18 Thank you. I try this later. Because I have another problem :/ I created a new form, which is doing someting like form1 and form2. But If i start my program and press the button for these three forms i get the message: SQL Statement not set. in form 1 and 2 there is no Data from the db now. I didnt changed anything in FOrm 1 and 2. If i press form 3 i get the same message but i can see the data from db. Does anyone  know where this error is caused by? The internet is not the helpful. If i restore a backup of the whole lazarus file, form 1 and 2 are working. there should be something with form 3? I created form 3 again and get the same problems.... form 3 is below ---------------------------------------------------------------------- TRon · 2020-06-10 12:17 In answer to your reply with regarding your explanations I made this little table Code: [Select]database  |  query    |  field  |  variable ================================================= sold      | SQLQuery1 |  price  |  stringprice    (selling) tabelle2  | SQLQuery3 |  price  |  variablePrice  (buying) Quote4. After the insert  I oben a procedure:        Form2.closeDB; In this procedure there is the Exec command. Ah ok. Then all is ok. But be aware that 'omitting' that kind of information can cause serious confusion :-) In case you can not share that part of the code, then just add some comment to your snippet: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i      // Perform the Exec function for the query so that the data get inserted,      // do this     // do that      // and finally close the database.     Form2.closeDB;  QuoteVariablePrice is the price in the database. stringprice is for a buying price and variablePrice is for sell. Then why not name your variables BuyingPrice and SellingPrice :-) That seems much clearer to me (and for anyone else that is looking at the code) ? QuoteIf the buy price is smaller than sell price, no trade is done. than the variable p is true/1 p is something like "check done". just for better understanding. Ok. But as another suggestion, if that variable can only have two 'states' "0" and "1", why then not make it a boolean ? And would it not be more clear to then name that variable NoTrade, or DoneTrade, or in case you prefer the opposite YesTrade/WillTrade/CanTrade ? Quoteif not .... the While starts at the lowest variablePrice. Ok, then perhaps i misunderstand something. Your code states: Code: [Select]while ((variablePrice <= stringPrice) or (p < '1')) do or in human language: if (BuyingPrice is smaller then or same as SellingPrice) or (Not(DoneTrade)) That is where i am starting to get a little worried as the comparison does not make sense to me (unless you wish to increase the BuyingPrice with the value two, up to the point it will be just at or over the SellingPrice). And should you not be doing that loop for as long trading was not Done ? (both conditions should match ?) QuoteFirst i select all information at this lowest price. I assume you are refering to: Code: [Select]Form2.SQLQuery1.SQL.Text := 'SELECT * from sold WHERE price ='''+variablePrice+''';'; or in human-talk: Select all fields from database sold where the field price matches BuyingPrice Which brings the question does the sold database actually have a SellingPrice that matches BuyingPrice ? Quoteand then i check if my IF ELSE the strings with the variables, i select from the database. If one IF ELSE fits than i assign P:=1 Or with my used variable name: DoneTrade := true; Quoteif no IF ELSE fits, than the variablePrice is +2 Than i select every information which belongs to the new variablePrice. Than I check my if else conditions again. If nothing fits I add to the variablePrice 2 again. and select the information which belongs to this new variablePrice again and so own I can see some conflicting information there with regards to your code. I still assume that variablePrice is the BuyingPrice. Code: [Select]variablePrice := Form2.SQLQuery1.FieldByName('price').AsString; which was taken from the query: Code: [Select]Form2.SQLQuery1.SQL.Text := 'SELECT * from sold WHERE price ='''+variablePrice+''';'; In my understanding you are assigning the field price from the sold database to the BuyingPrice variable ? In case that is the intention of that code then (for better reading) there should be a third variable name to swap  around the numbers (but perhaps that is the reason why you named your variable "variablePrice" ?) Also, if you are doing this by adding 2 to the buying price and loop around, then would it not be more convenient to order the last sqlquery (by price) and take the approach by comparing the other way around ? Perhaps none of what i wrote made any sense. If that is the case then that is ok, as i am also still struggling to fully understand your current code, so it might be i made a wrong assumption somewhere along the line. Please feel free to correct me if that is the case, although i do hope you are able to get something positive out of my response (instead of you having other troubles right now). ---------------------------------------------------------------------- Paulnewyork · 2020-06-10 12:48 Then why not name your variables BuyingPrice and SellingPrice :-) --> yes thats true ...sorry again p is a defined as a boolean (or tinyint(1) thats the same). but i had to use 1 or 0. with "true" or "false" there was nothing in the row. while ((variablePrice <= stringPrice) or (p < '1')) do while     sellingPrice  <=  buyingPrice       p = 0 means not checked and P=1 checked p ist just to get outside the loop if on IF ELSE matches. database  |  query    |  field  |  variable ================================================= sold      | SQLQuery1 |  price  |  variablePrice  (selling) tabelle2  | SQLQuery3 |  price  |  stringPrice   (buying) --> i changed the last row variable, there was a mistake Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Form2.SQLQuery1.SQL.Text := 'SELECT * from sold WHERE price ='''+variablePrice+''';';  --> oh there is a mistake.....Form2.SQLQuery3.SQL.Text should be query 3  omg :/ I have to correct everything when i find a solution for the other problem with the error message: sql state not set Than i can write again my code with clear variables ---------------------------------------------------------------------- TRon · 2020-06-10 13:50 Quote from: Paulnewyork on June 10, 2020, 02:48:14 pmThen why not name your variables BuyingPrice and SellingPrice :-) --> yes thats true ...sorry again Again, there i no need to apologise. That advise is based on years of experience with not naming variables using a logical scheme  I have learned that if you are able to apply a little logic with regards to naming then the code becomes more readable and at the same time makes it easier to spot errors. Quotep is a defined as a boolean (or tinyint(1) thats the same). but i had to use 1 or 0. with "true" or "false" there was nothing in the row. Ok, it is forced upon you. In that case, you still can use a boolean if you want, something like: Code: [Select]SomeBooleanName := p <> '0'; Quotewhile ((variablePrice <= stringPrice) or (p < '1')) do while     sellingPrice  <=  buyingPrice       p = 0 means not checked and P=1 checked p ist just to get outside the loop if on IF ELSE matches. I understand that it is used as an escape to be able to get out of the loop. My concern was that your current while loop keeps looping when one of the two conditions matches (logical or table) Let's say that i am still a bit confused over what p < '1' exactly means in your program As long as this is the correct condition that is required to let your code run properly, then that is ok. Quotedatabase  |  query    |  field  |  variable ================================================= sold      | SQLQuery1 |  price  |  variablePrice  (selling) tabelle2  | SQLQuery3 |  price  |  stringPrice   (buying) --> i changed the last row variable, there was a mistake Thank you for the correction, however as a reminder : line 2: stringPrice:= Form2.SQLQuery1.FieldByName('price').AsString; line 14: variablePrice := Form2.SQLQuery3.FieldByName('price').AsString; Somehow that doesn't exactly add up in my mind  Quote--> oh there is a mistake.....Form2.SQLQuery3.SQL.Text should be query 3  omg :/ Congratulations as you figured that out all by yourself (I am also glad as i then understand the code a little better). Fixing bugs _can_ sometimes be easy  QuoteI have to correct everything when i find a solution for the other problem with the error message: sql state not set No problem, please take your time. Unfortunately i am unable to give any helpful advise for the problem that you now have. It was not my intention to get you into troubles with advising to make a small (stand-alone) test-project. I wish you luck with figuring out what goes wrong there. You are in good company in the other thread. cheers, ---------------------------------------------------------------------- Paulnewyork · 2020-06-11 09:41 So here is the new code. I change int to extended (because of decimal values). I added some comments, I hope it is now understandable. Does the while stop conditions makes sense or does it stop when the prices are the same? It seems like the stop conditions is not workring because the programme freezes. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm3.ButtonStartClick(Sender: TObject);                  var start : TDateTime;stringCheck :string;stringBuyPrice : string;stringBuyVolume :: string;buy_id : string; sold : string; sell_id : string;name : string; SellPrice : string;floatBuyPrice : Extended;floatSellPrice : Extended; //for the calculation of the restvolumefloatBuyVolume : Extended;floatSellVolume: Extended;floatTempVolume : Extended;stringTempVolume : string;  sellVolume : string;  begin   stringCheck := '0';buy_id := EditBuy_ID.Text;stringBuyPrice := Edit2_ID.Text;stringBuyVolume := Edit3_ID.Text;      Form2.SQLQuery3.SQL.Text := 'SELECT price, start FROM sell WHERE price =  (SELECT min(price) FROM sell)';   Form2.SQLQuery3.Open;       SellPrice := Form2.SQLQuery3.FieldByName('price').AsString;        floatSellPrice :=StrToFloat(SellPrice);        floatBuyPrice := StrToFloat(stringBuyPrice);         floatBuyVolume:= StrToFloat(stringBuyVolume);            While ((floatSellPrice <= floatBuyPrice ) OR (stringCheck < '1'))     DO      BEGIN        // I collect the data which belongs to the lowest price, i have to do this every loop again, because the price is getting higher 0.1 after every loop      Form2.SQLQuery1.SQL.Text := 'SELECT * from sell WHERE price ='''+SellPrice+''';';     Form2.SQLQuery1.Open;      SellPrice := Form2.SQLQuery1.FieldByName('price').AsString;     floatSellPrice :=StrToFloat(SellPrice);      sell_id := Form2.SQLQuery1.FieldByName('id').AsString;     name := Form2.SQLQuery1.FieldByName('name').AsString;     sellVolume := Form2.SQLQuery1.FieldByName('volume').AsString;     floatSellVolume:= StrToFloat(sellVolume);      sold := Form2.SQLQuery1.FieldByName('sold').AsString;     ELSE   BEGIN   floatSellPrice := floatSellPrice + 0.1;     SellPrice:=FloatToStr(floatSellPrice)    END         end; Form2.SQLQuery2.SQL.Text := 'Update buy SET check = "1" WHERE buy_id ='''buy_id+''';'; stringCheck:= '1'; Form2.SQLQuery2.ExecSQL; F orm2.SQLTransaction1.Commit; Form2.SQLQuery1.Close;     end end; ---------------------------------------------------------------------- Paulnewyork · 2020-06-11 12:21 I made some tests with different values. if if have the same or higher buy price than the lowest sell price fits. so it gets the tag 1 (in row sold). If i do a higher buy price, and there is a sell price which actually fits, nothing happens. there should be something wrong with the "while  loop" i guess. I found out one big problem: I get the wrong lowest price. Iadded one lower price in mysql and one via my program, bute none of them are the returned with the following command in mysql. I always get a higher price returned. had someone the same experience? SELECT * FROM sell WHERE price=  (SELECT min(price) FROM sell) ---------------------------------------------------------------------- TRon · 2020-06-11 15:16 Quote from: Paulnewyork on June 11, 2020, 11:41:09 amSo here is the new code. Ok, i see we have to start at the basics. Does the following overview matches yours ? Code: [Select]database | fields ======================================================== sell     | start, price, preis, id, name, volume, sold table    | id, price, volume buy      | check, date, buy_id Because that is what your snippet is telling me (give or take a reading error on my part) The i see you use the same query for doing multiple things, which is fine i guess bu i doubt it is doing what yo want it to (i did not looked into that yet because i can't get my tables up to match yours) QuoteI change int to extended (because of decimal values). Please don't use extended, use single or double instead (float if you must) ---------------------------------------------------------------------- Paulnewyork · 2020-06-11 15:40 the correct version: database | fields ======================================================== sell     |  price, price, id, name, volume, sold, date, start table    | id, price, volume buy      | check, date, buy_id,  price, start, volume Why is double better? i changed extended now to double ---------------------------------------------------------------------- TRon · 2020-06-11 15:45 Quote from: Paulnewyork on June 11, 2020, 05:40:49 pmthe correct version: Thank you. Note that in your snippet a query to table is using "table 2" (note the space) QuoteWhy is double better? i changed extended now to double It is not that single, double, float or currency is better, extended is legacy and requires a co-processor (it is deprecated to rely in that) ---------------------------------------------------------------------- Paulnewyork · 2020-06-11 15:51 the space is not in my code, just here in this code, which I posted. I changed the name of the  table.... ---------------------------------------------------------------------- TRon · 2020-06-11 16:04 Quote from: Paulnewyork on June 11, 2020, 05:51:30 pmthe space is not in my code, just here in this code, which I posted. I changed the name of the  table.... hmz, weird. Well, it will take me some time to setup the new tables and i have to do some outside tours, so please don't hold your breath ---------------------------------------------------------------------- Paulnewyork · 2020-06-11 16:20 I changed in MYSQL the data typ for price from varchar to double.... Now i get the correct MIN(price)  in MySQL...my tests go on now i get the message:    " is an invalid float It is crazy ---------------------------------------------------------------------- af0815 · 2020-06-11 16:52 not crazy, its per design. SCNR you are crossposting with the german forum as Daniel_Berlin and here paulnewyork. ---------------------------------------------------------------------- Paulnewyork · 2020-06-11 16:56 Yes i post also in german ---------------------------------------------------------------------- TRon · 2020-06-11 18:42 good to know af0815, thx @paulnewyork That you refrain from providing a compilable example is one thing, but you keep on updating your post that contained code with your original problem. That means that your actual problem keeps changing/shifting Not only that, you do not notify us that you did change your (original) snippet. It is nearly impossible to provide help that way. Your code shows that you are making some basic fundamental and logical errors, and there is no way to address those this way and/or offer any guidance in those matters. instead of guessing what it is you want, i ask: what is it that you want ? A ready to go for your use case working example is not my virtue. You can hire people to do that for you. I'm in no means upset or otherwise, but you clearly have no idea how to ask a question properly and/or provide the information required to be able to help. I did see that from your original post, and that is why i responded as nobody else in his/her right mind would. I like a challenge (once in a while) :-) And to show what i meant, you corrected me: Quote from: Paulnewyork on June 11, 2020, 05:40:49 pmthe correct version: database | fields ======================================================== sell     |  price, price, id, name, volume, sold, date, start table    | id, price, volume buy      | check, date, buy_id,  price, start, volume Which is perfectly ok, you'd better :-) however, in your original posted example you used both price and preis as field inside your sell table.Now i must update my table(s) again to match that. Or in short, you are wasting (my) time. Don't let that hold you back, but please be informative and whatever you do, never change posted snippets unless specifically mentioning with that changed snippet what/why you did it. It is must more preferable to post a new snippet in a new post. If someone reads this thread afterwards, the whole thread doesn't make any sense any more (wasting more of peoples time). Besides that your actions could shed a wrong light on the person attempting to help you. With regards to the latter, i personally don't care, because as i said before: i do not speak sql so this whole thing is a learning exercise for me ---------------------------------------------------------------------- TRon · 2020-06-11 20:27 btw i am unable to create a field with the name check because it being a sql constraint. Is there another way to use a query to create a field with that name or is it better to avoid such (reserved) names at all ? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DBQuery.SQL.Add('CREATE TABLE test ( check BOOLEAN )');DBQuery.ExecSQL;  edit: nevermind. it is expected as a string-literal according to sqlite docs Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DBQuery.SQL.Add('CREATE TABLE test ( "check" BOOLEAN )');DBQuery.ExecSQL; ---------------------------------------------------------------------- TRon · 2020-06-12 07:10 Well, i am sorry but am not going to look at that for now. As said before, your (code) logic is flawed  Besides that, i still think it is much easier to approach this the other way around and instead of using coded criteria, to put those in a SQL statement and iterate through the results. I have implemented your algorithm, and as i suspected: Code: [Select]>> Creating table "sell" >> Filling table "sell" with data >> Creating table "buy" >> Filling table "buy" with data >> Creating table "table" Name of 3 tables: 'buy' 'sell' 'table' LowestSellPrice = 100.00 SafetyCounter = 1 RecordCount = 1 No matched criteria, increasing SellPrice SafetyCounter = 2 RecordCount = 0 Criteria matched, updating records An unhandled exception occurred at $0009B15C: Note the line where it states "RecordCount = 0" Now, this can happen because i do not work with the same data as you do. However, you increase the sellingprice by 0.1 and expect to query to find a match in the query Table. The mentioned line shows what happens if there is no such value inside the table. So the question becomes are we going left, right, or do you decide to go upside-down ?  edit: minor wording correction ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 07:25 so i have to make an if else statement after i check if there is a higher price in the table. if there is no higher price in the table i have to add an IF ELSE  condition for that case to increase the sellingprice again? Like Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i      IF (sellPrice = " ")        THEN        BEGIN        sellingPrice := sellingPrice + 0.1;        sellPrice:=FloatToStr(floatSellPrice);      END   is the condition for empty correct??? sellPrice was the string and a space between the quotation marks? ---------------------------------------------------------------------- TRon · 2020-06-12 07:34 Before the code reaches that location (where you wish to apply the fix), the program has already executed code assuming that the record is present. That includes reading the sellingprice from an empty record (it beats me why the program didn't throw an exception for that, the message "Criteria matched, updating records" is printed after the if statement, thus after reading the empty record). I am not sure about sqlite and it's implementation for Free Pascal, but knowing a little about Free Pascal, if things are empty that means undetermined, behaviour is not consistent, etc. etc. If you wish to follow this path then i have to give it some more thought on what would be the best approach/solution (that is, besides the use of goto's). ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 07:45 Is it possible to put the IF ELSE inside the loop after Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Form2.SQLQuery1.SQL.Text := 'SELECT * from sell WHERE price ='''+SellPrice+''';';Form2.SQLQuery1.Open;SellPrice := Form2.SQLQuery1.FieldByName('price').AsString;// or as alternative// floatSellPrice := Form2.SQLQuery1.FieldByName('price').AsFloat; ---------------------------------------------------------------------- TRon · 2020-06-12 07:59 Quote from: Paulnewyork on June 12, 2020, 09:45:45 amIs it possible to put the IF ELSE inside the loop after Yes, but to fix the problem entirely it would then have to become a while loop. e.g. increase the selling-price until it matches one in the table. Are you already starting to see why i said it would be easier to implement if doing it the other way around ?  Since your actions seem to suggest you are a little impatient, the quickest thing i can think of atm is to just take the next record and fetch it's selling-price (*) edit (*) That was a bit vague, sorry i will elaborate: What i meant by that is having a query that selects the price in an orderly fashion, then iterates through the results from lowest to highest. ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 08:21 Since your actions seem to suggest you are a little impatient, the quickest thing i can think of atm is to just take the next record and fetch it's selling-price (*) --> that sounds pretty good. the second while loop make sense sorry, that i am impatient. I just want to help und suggest some possibilites ---------------------------------------------------------------------- TRon · 2020-06-12 08:53 Quote from: Paulnewyork on June 12, 2020, 10:21:53 amSince your actions seem to suggest you are a little impatient, the quickest thing i can think of atm is to just take the next record and fetch it's selling-price (*) --> that sounds pretty good. Yes, but that is more leaning towards the "doing it the other way around"  As a matter of fact, you would then have to alter things in such a way that it would work as i suggested earlier. Quotethe second while loop make sense It has a drawback. You are never able to tell if there is no match because there simply wasn't a match (yet), or that the selling price that you check for has already reached the top value of selling-prices that are stored inside the database. Of course that can be checked by making another query, where you look for the highest possible selling-price, and bail out the while-loop (or entire routine)  if the price you are checking against is higher then that highest price that is stored inside the table. It sounds a bit too flaky for my taste  Quotesorry, that i am impatient. I just want to help und suggest some possibilites That is no problem, but as i said i do not speak SQL so i need more time to think things through. Every possible solution i have to check/test how that works in practise as i am unfamiliar with any of the used classes, and sql statements. So i am at the same time familiarising myself with the available documentation and explanations as well... i am a slow reader ---------------------------------------------------------------------- TRon · 2020-06-12 09:09 btw this is what i meant with other way around (e.g. let sql do all the hard work), but no idea if something like this statement can be accomplished in a single go Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SELECT price FROM sell ORDER BY price WHERE price <= UserBuyPrice AND userBuyVolume > SellVolume AND SOLD = FALSE Do you see what i mean ? if so then you can already play around with that idea  The idea behind it is that it should produce a list of records that you can iterate, going from price low to price high and select the one that meets your (other, not sql'ed) criteria best. edit: And depending on how you have things setup it can even be that there are no matches at all, in which case you would have to decide what must be done in that situation. ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 14:00 For the last Situation there  is after the while loop an update statement to set one row value. If there are more matches at same price the earliest startdatetime gets matched So there should be a second loop inside the price loop for the start date/time. Maybe we can handle that also with the next value instead of increasing Every second ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 14:17 I have to think about the idea with the Sql statement, if it can work ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 14:25 Your idea sounds good, but I don’t know if nothing matched how to get the higher sell price. I can work tomorrow on that topic again ---------------------------------------------------------------------- Paulnewyork · 2020-06-12 14:38 Also If the volume is higher a lower than the other, i have to check the Rest volume again with the next higher Price or it stays in the dB of nothing fits. But this can maybe done with the function last_inserted_id in the sql statement, and then the check starts again?! Until nothing fits. I thought this would be easier if I store the volume etc direct in variables. But this can be done maybe also when the sql statement gets a match ---------------------------------------------------------------------- TRon · 2020-06-12 15:51 Hi Paulnewyork, First of all thank you for having provided your initial snippet in (semi) translated form and, the fact that you have reduced it to a much smaller portion then your original code  I was already afraid you were going to bring in other (not yet mentioned) secondary requirements  QuoteSo there should be a second loop inside the price loop for the start date/time. Maybe we can handle that also with the next value instead of increasing Every second The moment you start thinking about increasing things with a particular value in the hopes that it matches a value inside your table, then there should be an alarm-bell going off like crazy (one of those that give you a headache for the upcoming five years)  So, yes (indeed) if possible (and in case not we must make it happen so) try to use to embed such a thing into the same query or if not possible then, open up another one that is able to aid/assist. QuoteYour idea sounds good, but I don’t know if nothing matched how to get the higher sell price. You would have to seriously think about that, because if there isn't then there simply isn't such a value. You can't make things up out of thin air, you know  That is unless you are talking about a sale that never happened before so you have nothing to match against (that is if i understood your code correctly). But also then, you would have to come up with a solution on how to handle that situation. I can't make that decision for you. QuoteI can work tomorrow on that topic again No problem. I was kind of working on optimising my sql test-bed environment, to make it more flexible with regards to adapting to new situations. Since i'm new to sql that goes literally with small steps at a time  QuoteAlso If the volume is higher a lower than the other, i have to check the Rest volume again with the next higher Price or it stays in the dB of nothing fits. But this can maybe done with the function last_inserted_id in the sql statement, and then the check starts again?! Until nothing fits. I thought this would be easier if I store the volume etc direct in variables. But this can be done maybe also when the sql statement gets a match ... and another (not mentioned before) secondary requirement  Just take a (good) moment to think about how you wish to approach this, also taking into consideration other influences that you not have thought of earlier. The more you know beforehand, the less likely you'll get stuck when trying to solve the initial problem/issue. As far as I am able to tell, for the snippet you showed, the query as presented works. But it works (only) for that snippet. So the more you come up with other requirements, the more likely it could become that the solution used isn't sustainable in the end. So again, I please urge you to take a good moment and think really hard/clear about things. Also be aware that the more complicated this gets, the less likely I will be able to offer help as I simply miss a) the insight in your whole code-base b) miss required data and c) i will most likely reach the top of what I learned/know about sql, especially since you seem to be stepping things up a notch. And that is if you even considered being as help so far ---------------------------------------------------------------------- Paulnewyork · 2020-06-13 09:56 Hey, the idea with the sql statement works perfect! Also i select all * information from both tables, because i need it for inserts later and i also implemented the earlist time condition. (eg. ORDER BY price ASC) the if else condition seems to work as well. (e.g. buyvolume > sellvolume) so the statement is final. so I just have two things to do: if the buy volume is higher than the sell volume, i need to add the remaining volume to the db and then i have to check again, if another sell entry fits (to the same price but later time, or to a higher price). for that situation there should be a loop inside the IF ELSE condition?! the sql statement remains the same. just one problem with the remaining volume: If the stringRemaining/TempRemaing is 10 the INSERT works! But when the TempRemaining is decimal (e.g. 2.5) the INSERT doesn`t work and i get the error message: ERROR executin query: Data truncated for column  'volume' at row 1.' the data typ of volume is double in the db Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TempRemaining : double;stringRemaining :string; ... TempRemaining:= doubleBuyVolume - doubleSellVolume;stringRemaining := FloatToStr(TempRemaining);   so this are actually the last things to do. the other IF ELSE condition are pretty easy. (its like volume = volume) ---------------------------------------------------------------------- egsuh · 2020-06-13 11:55 Not sure following is your final code. I did some clean up to follow only logic. In the following code, there is one possibility that you will never get out of the while loop --- if the first IF condition (Point B) is never met, you'll never set stringCheck to 1, and the while condition will be true always. Also BuyVolume and SellVolume are not changed at least in this codes. So, once the first IF condition is not met by this sub-condition, then you will never enter into this section. And at Point A, if the query returns no records, sellPrice will be '', and FloatSellPrice := StrToFloat(sellPrice) will raise error, I guess. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    stringCheck := '0'; While ((floatSellPrice <= floatBuyPrice ) OR (stringCheck < '1'))   DO   BEGIN          // I collect the data which belongs to the lowest price, i have to do this every loop again, because the price is getting higher 0.1 after every loop          Form2.SQLQuery1.SQL.Text := 'SELECT * from sell WHERE price ='''+SellPrice+''';';             Form2.SQLQuery1.Open;        // Point A.    When this returns no record           FloatSellPrice := Form2.SQLQuery1.FieldByName('price').AsFloat;           sell_id := Form2.SQLQuery1.FieldByName('id').AsString;          name := Form2.SQLQuery1.FieldByName('name').AsString;          FloatsellVolume := Form2.SQLQuery1.FieldByName('volume').AsFloat;           sold := Form2.SQLQuery1.FieldByName('sold').AsString;            // Buyprice is higher or the same than sell price and buy volume is higher than sell volume; sold a checkpoint for the sells, it has to be unequal 1        IF ((floatSellPrice <= floatBuyPrice) AND (stringCheck = '0') AND (floatBuyVolume > floatSellVolume)  {-- and? --}   (sold <>1))    // Point B. THIS CONDITION         THEN BEGIN                 floatTempVolume := floatBuyVolume - floatSellVolume;                 stringTempVolume  :=FloatToStr(floatTempVolume);                 Form2.SQLQuery1.SQL.Text := 'INSERT INTO table 2 (id, price,volume) VALUE ('''+sell_id+''','''+name+''','''+stringTempVolume+''');';               Form2.SQLQuery2.SQL.Text := 'Update buy SET check = "1", date = current_timestamp WHERE buy_id ='''+buy_ID+''';';               Form2.SQLQuery3.SQL.Text := 'Update sell SET sold ="1", date = current_timestamp  WHERE  id = '''+sell_id+''';';                 stringCheck:= '1';                 Form2.SQLQuery1.ExecSQL;               Form2.SQLQuery2.ExecSQL;                 Form2.SQLQuery3.ExecSQL;                 Form2.SQLTransaction1.Commit;          END          ELSE  SellPrice:=FloatToStr( floatSellPrice + 0.1);   end ;   // end of while ---------------------------------------------------------------------- TRon · 2020-06-13 12:27 Quote from: Paulnewyork on June 13, 2020, 11:56:04 amHey, the idea with the sql statement works perfect! Good !  QuoteAlso i select all * information from both tables, because i need it for inserts later and i also implemented the earlist time condition. (eg. ORDER BY price ASC) the if else condition seems to work as well. (e.g. buyvolume > sellvolume) so the statement is final. Ok, that is good to know that it works also with adding the additional requirements. thanks for the feedback. Quoteso I just have two things to do: ok. Quoteif the buy volume is higher than the sell volume, ... You first determine if the action that you need to take is or isn't (can or can't be) part of the current active query (buyvolume > sellVolume), which in this instance seems to be (taken that there are no pre-requirements conditions that must be met in order to obtain the corect resultset), but.... Quote... i need to add the remaining volume to the db and then i have to check again, If that adding is done into the same DB then things can become complicated, and it then would probably be better to do either an additional query (followed by a update statement) or do it code-wise (just try to keep it apart from the queries as you initially did with your original issue). Quoteif another sell entry fits (to the same price but later time, or to a higher price). for that situation there should be a loop inside the IF ELSE condition?! the sql statement remains the same. Initially that sounds to me like an addition to the original query. If that cannot be done with using the same query (because you would narrow down the selection too much otherwise) then simply add another query. Only resort to actual coding that makes database related decisions when you only have to (or want to). Quotejust one problem with the remaining volume: If the stringRemaining/TempRemaing is 10 the INSERT works! But when the TempRemaining is decimal (e.g. 2.5) the INSERT doesn`t work and i get the error message: ERROR executin query: Data truncated for column  'volume' at row 1.' the data typ of volume is double in the db Ok, i have you seen mentioning this for a couple of times now. I will be brief and firm in my answer  1) never ever use strings in order to work with databases, unless the contents of the database-field actually is a string and only when it represents actual text (so not a field type that is stored as type text) 2) always use parameters in your queries If you do not follow those rules then you have a serious problem ahead of you, because of (if only) the following reason: - https://www.freepascal.org/docs- html/rtl/sysutils/tformatsettings.html If you do not take that into account then your code will never work somewhere else as those values are taken from your system/setup. It is a problem in its own, working for one platform but you open am additional can of worms if you wish to take multiplatform into account. Take a look at the code i posted. It is based on one of my first attempts with sql, to which i added some changes. It is a stand-alone Free Pascal program and i have adapted it a bit so you can copy-paste it into a Lazarus project (never ever do that to a working existing lazarus project, unless you don't mind screwing up that project). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program smalltest; {$MODE OBJFPC}{$H+} uses  classes, sysutils, db, sqldb, sqlite3conn; var  DBConnection  : TSQLite3Connection;  DBTransaction : TSQLTransaction;  DBQ           : TSQLQuery;   {$IFDEF LCL}  // For Lazarus Change MainForm.YourLogMem to point to a (active) Memo on your Form  LogMemo   : TMemo absolute MainForm.YourLogMemo;    {$ENDIF}   procedure WriteLog(S:String);inline;begin{$IFDEF LCL}LogMemo.Append{$ELSE}WriteLn(S){$ENDIF};end;  procedure WriteLog;begin WriteLog('')end;  procedure WriteLog(S:String;const a:array of const);begin WriteLog(Format(S,a));end;  procedure CreateDB;begin  DBConnection := TSQLite3Connection.Create(nil);   DBConnection.DatabaseName := ':memory:';  DBTransaction := TSQLTransaction.Create(DBConnection);  DBTransAction.Database := DBConnection;   DBQ             := TSQLQuery.Create(DBConnection);  DBQ.Database    := DBConnection;  DBQ.Transaction := DBTransaction;end; procedure DestroyDB;begin  DBConnection.Free;end; procedure CreateTable(aTableName: String; aFields: String);begin  DBQ.SQL.Clear;  DBQ.SQL.Add('CREATE TABLE ' + aTableName.QuotedString);  DBQ.SQL.Add('( ');  DBQ.SQL.Add(aFields);  DBQ.SQL.Add(' )');  DBQ.ExecSQL;end; procedure test;var  Statement : string;  Price     : currency;  doubt     : double;  isSold    : boolean;begin  // i have taken real instead of double, but it is the same affinity and should therefor work similar  CreateTable( 'test', '"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT , "price" REAL, "sold" BOOLEAN DEFAULT 0, "date" DATETIME' );  Statement := 'INSERT into test(price, date) values';  DBConnection.ExecuteDirect(Statement + '(   100.01, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '(   200.02, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '(   400.03, date(''mow'') );');  DBConnection.ExecuteDirect(Statement + '(   800.04, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '(  1600.05, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '(  3200.06, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '(  6400.07, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '( 12800.08, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '( 25600.09, date(''now'') );');  DBConnection.ExecuteDirect(Statement + '( 51200.10, date(''now'') );');   DBQ.SQL.Text := 'SELECT "id", "price", "sold", "date" FROM "test"';  DBQ.Open;   WriteLog('RecordCount = %d', [DBQ.RecordCount]);   while not DBQ.EOF do  begin    WriteLog('Current record number is = %d', [DBQ.RecNo]);     // for testing purpose, only make changes to the first record    if DBQ.RecNo = 1 then    begin    WriteLog('Test with record number %d', [DBQ.RecNo]);       // try a boolean      isSold := DBQ.FieldByName('sold').AsBoolean;      // we are using booltostr here, because the helper gains us no advantage (its dumb)      WriteLog('Is current record sold ? %s', [BoolToStr(isSold, 'yes', 'no')]);       // try with currency      price := DBQ.FieldByName('price').AsCurrency;      WriteLog('Price as currency = %.2f', [price]);       price := price + 10.20;      DBQ.Edit;      DBQ.FieldByName('price').AsCurrency := price;      DBQ.Post;        price := DBQ.FieldByName('price').AsCurrency;      WriteLog('Price as currency = %.2f', [price]);       // try with double      doubt := DBQ.FieldByName('price').AsFloat;      WriteLog('Price as double = %.2f', [doubt]);       doubt := doubt + 30.30;      DBQ.Edit;      DBQ.FieldByName('price').AsFloat := doubt;      DBQ.Post;        doubt := DBQ.FieldByName('price').AsFloat;      WriteLog('Price as double = %.2f', [doubt]);    end;    DBQ.Next;  end;  DBQ.Close;end; procedure RunningMan;begin  WriteLog('begin');  CreateDB;  try    test;  finally    DestroyDB;  end;    WriteLog('end');end; begin  RunningMan;end.  The same logic can be applied for the date/time, but i left that open so that you can try/test that yourself  edit: crap copy-paste error, change Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure WriteLog(S:String);inline;begin{$IFDEF LCL}LogMemo.Append{$ELSE}WriteLn(S){$ENDIF};end;into Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure WriteLog(S:String);inline;begin{$IFDEF LCL}LogMemo.Append{$ELSE}WriteLn{$ENDIF}(S);end; ---------------------------------------------------------------------- TRon · 2020-06-13 13:02 Quote from: egsuh on June 13, 2020, 01:55:49 pmNot sure following is your final code. I did some clean up to follow only logic. I had to work with that as well, so ...  QuoteIn the following code, there is one possibility that you will never get out of the while loop --- if the first IF condition (Point B) is never met, you'll never set stringCheck to 1, and the while condition will be true always. That is correct. That is why i suggested to entirely get rid of the loop and replace it by a proper query. That query has a resultset, and if that is empty then you'll know that beforehand, to which the proper decision can be made code-wise. I do not know if you already had seen my comment before you posted (in which case, sorry): in case you see your code run into such a loop then there should be an atomic bomb going off inside your head as a warning  Especially loops make a perfect candidate to solve with a sql statement. And it circumvents the drawback that you already mentioned of being "stuck" inside the loop, as you are able to check the result of such query beforehand. Nice cleanup btw , as i got confused by earlier posts. ---------------------------------------------------------------------- TRon · 2020-06-13 14:37 Quote from: Paulnewyork on June 13, 2020, 11:56:04 amjust one problem with the remaining volume: If the stringRemaining/TempRemaing is 10 the INSERT works! But when the TempRemaining is decimal (e.g. 2.5) the INSERT doesn`t work and i get the error message: ERROR executin query: Data truncated for column  'volume' at row 1.' the data typ of volume is double in the db I already made my say about it but, for my own curiosity can you share the actual statement ? I am seriously unable to cause that error- message, no matter what i try (and did some very strange/naughty/nasty things).  All research i was able to find that generate that message is pretty obvious in that someone tries to store into a field that is too small to be able to contain the posted data, and attempting to simulate that situation for a double fails in my test-cases. ---------------------------------------------------------------------- Paulnewyork · 2020-06-13 14:56 I am not at home now. I found on the internet that thing with parameters and decimal problems. That should be the solution. I can tell more tommorrow when i change it. Thank you so much! ---------------------------------------------------------------------- Paulnewyork · 2020-06-14 08:23 yes, it was the thing with parameter, now it works