Recent

Author Topic: MySQL import of a stored procedure using Lazarus  (Read 1588 times)

malmax71

  • Newbie
  • Posts: 3
MySQL import of a stored procedure using Lazarus
« on: March 13, 2018, 08:46:36 am »
Hello.
When writing a utility for updating its software, the task is to update the database. The database contains stored procedures and functions. Accordingly, the SQL script contains constructions of the form:
Code: SQL  [Select]
  1. DELIMITER $$
  2. CREATE FUNCTION ...
  3. BEGIN
  4.   ...
  5.   RETURN ...;
  6. END$$
  7.  
I tried to use the TSQLScript component, but it gave an error to this construct.
Actually the question: Is it possible to load such SQL scripts with Lasarus?

mangakissa

  • Hero Member
  • *****
  • Posts: 865
Re: MySQL import of a stored procedure using Lazarus
« Reply #1 on: March 13, 2018, 01:16:21 pm »
You need TSQLQuery. This function returns a kind of dataset. You can also use out parameters. These will be placed into the prarams property.
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

malmax71

  • Newbie
  • Posts: 3
Re: MySQL import of a stored procedure using Lazarus
« Reply #2 on: March 13, 2018, 02:31:52 pm »
You need TSQLQuery. This function returns a kind of dataset. You can also use out parameters. These will be placed into the prarams property.
I don't need returns a kind of dataset. I need execute SQL script, containing many different queries. Queries type UPDATE, ALTER etc. consist 1 string ended semicolon, is not a problem. But query type CREATE FUNCTION consist many strings whith semicolons and it cause an error in components TSQLQuery or TSQLScript.

rvk

  • Hero Member
  • *****
  • Posts: 3511
Re: MySQL import of a stored procedure using Lazarus
« Reply #3 on: March 13, 2018, 03:06:37 pm »
Actually the question: Is it possible to load such SQL scripts with Lasarus?
Yes, it is.

mangakissa

  • Hero Member
  • *****
  • Posts: 865
Re: MySQL import of a stored procedure using Lazarus
« Reply #4 on: March 14, 2018, 08:28:53 am »
Quote
The database contains stored procedures and functions
Quote
I don't need returns a kind of dataset. I need execute SQL script, containing many different queries. Queries type UPDATE, ALTER etc
These are two different things. First you're talking about a 'stored procedure' which is executed by TSQLQuery.
If you want to execute several query in sequence, TSQLscript is your man. But you cant combine stored procedures and queries in a script
Lazarus 1.84 (32b) / FPC 3.0.4
Windows 10

rvk

  • Hero Member
  • *****
  • Posts: 3511
Re: MySQL import of a stored procedure using Lazarus
« Reply #5 on: March 14, 2018, 10:20:59 am »
But query type CREATE FUNCTION consist many strings whith semicolons and it cause an error in components TSQLQuery or TSQLScript.
You need to fiddle with the "Terminator" property.
TSQLScript doesn't 'understand' DELIMITER.

PittJunior

  • Newbie
  • Posts: 2
Re: MySQL import of a stored procedure using Lazarus
« Reply #6 on: March 20, 2018, 08:32:07 am »
Where can I find out the basics?