Recent

Author Topic: problem with zquery  (Read 452 times)

Gebo

  • Jr. Member
  • **
  • Posts: 67
    • chahpander for lingeries
problem with zquery
« on: December 09, 2025, 12:30:40 pm »
I trying to change some value in mariadb by procedure my code in lazarus is
Code: Pascal  [Select][+][-]
  1. [code=pascal]
  2. procedure TForm6.SpeedButton1Click(Sender: TObject);
  3. begin
  4.   ZQuery2.Close;
  5.   ZQuery2.SQL.Text:='CALL `comeback`(:bckin, :id, :bckto)';
  6.   ZQuery2.ParamByName('bckin').AsDate:=DateTimePicker1.Date;
  7.   ZQuery2.ParamByName('bckto').AsString:=ComboBox1.Text;
  8.   ZQuery2.ParamByName('id').AsInteger:=ZQuery1.FieldByName('id').AsInteger;
  9.   ZQuery2.ExecSQL;
  10.  
  11.   Form6.Activate;
  12. end;
  13.  
[/code]

and the procedure code in mariadb is
Code: Pascal  [Select][+][-]
  1. CREATE DEFINER=`root`@`localhost` PROCEDURE `comeback`(
  2.         IN `bckin` DATE,
  3.         IN `id` INT,
  4.         IN `bckto` VARCHAR(50)
  5. )
  6. LANGUAGE SQL
  7. DETERMINISTIC
  8. CONTAINS SQL
  9. SQL SECURITY DEFINER
  10. COMMENT ''
  11. BEGIN
  12. UPDATE maintenence SET maintenence.back_in_date=bckin,maintenence.back_to=bckto WHERE maintenence.id=id;
  13. END
  14.  
If I called it from Heidisql ,It works well but from lazarus doesn't work and no errors appeare.
« Last Edit: December 09, 2025, 01:04:42 pm by Gebo »
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

Zvoni

  • Hero Member
  • *****
  • Posts: 3230
Re: problem with zquery
« Reply #1 on: December 09, 2025, 01:01:38 pm »
and are you connecting with the Mariadb-root-account from your Lazarus-program?
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Gebo

  • Jr. Member
  • **
  • Posts: 67
    • chahpander for lingeries
Re: problem with zquery
« Reply #2 on: December 09, 2025, 01:07:05 pm »
yes ,I connect with root user from zconnection.
I have done it before in the same application but I don't know why stopped this time.
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12595
  • FPC developer.
Re: problem with zquery
« Reply #3 on: December 09, 2025, 01:15:15 pm »
Add a SQL Monitor, and see what gets sent?

Zvoni

  • Hero Member
  • *****
  • Posts: 3230
Re: problem with zquery
« Reply #4 on: December 09, 2025, 01:24:41 pm »
hmm.... besides your issue:
I don't like the "CONTAINS SQL"
--> https://mariadb.com/docs/server/server-usage/stored-routines/stored-procedures/create-procedure
Quote
CONTAINS SQL means that the function contains at least one SQL statement, but it does not read or write any data stored in a database. Examples include SET or DO.
Replace that with "MODIFIES SQL DATA"
Quote
MODIFIES SQL DATA means that the function contains statements that may modify data stored in databases. This happens if the function contains statements like DELETE, UPDATE, INSERT, REPLACE or DDL.


In regards to your issue:
1) The only thing "fishy" is the missing ";" after the last END in your Stored Procedure
It would also mean there is the DELIMITER-Clause missing
2) I don't remember exactly, if a SP needs a BEGIN Transaction/Commit-Block itself
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Gebo

  • Jr. Member
  • **
  • Posts: 67
    • chahpander for lingeries
Re: problem with zquery
« Reply #5 on: December 09, 2025, 02:59:47 pm »
Thanks all for your interest.
the problem was clientcode and catalogue in zconnection not assigned.
I like programming I begun by vb,vb.net,c# and finally free pascal and lazarus .I like martial arts sports and I am a kickboxer and made our team sport club called black eagle school I have a website for modern clothes..

 

TinyPortal © 2005-2018