Topic: SQl script
Hi , Please i need to understand how to enter an SQL script in My Visual Database
My Visual Database → SQL queries → SQl script
Hi , Please i need to understand how to enter an SQL script in My Visual Database
Hello.
You can use function SQLExecute to run SQL query, also you can get some value from database, example:
var
s: string;
begin
s := SQLExecute('SELECT firstname FROM tablename WHERE id=1');
function SQLQuery is more advanced, allows you to get data from database, example
var
Results: TDataSet;
s1, s2: string;
begin
SQLQuery('SELECT fieldname1, fieldname2 FROM tablename', Results);
while not Results.Eof do
begin
s1 := Results.FieldByName('fieldname1').asString;
s2 := Results.FieldByName('fieldname2').asString;
Results.Next;
end;
Also you can use button with action "SQL query"
I will probably be using Sqlite for some projects. I'm used to MySQL which has stored procedures and I want to use them extensively I think.
Is there a reasonable way to put SQL scripts and logic in either the database or something where I can sort of create a set of stored procedures and run them in MVD upon record update, or insert, or for validation.
Brand to to MVD so hopefully this is not a dumb question.
I will probably be using Sqlite for some projects. I'm used to MySQL which has stored procedures and I want to use them extensively I think.
Is there a reasonable way to put SQL scripts and logic in either the database or something where I can sort of create a set of stored procedures and run them in MVD upon record update, or insert, or for validation.
Brand to to MVD so hopefully this is not a dumb question.
MVD does not have special interface to manage stored procedures, so you should use free tools like MySQL Workbench or HeidiSQL to create stored procedures.
Example
CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
BEGIN
SELECT 'Hello';
END
How to call
procedure Form1_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
s: string;
begin
s := SQLExecute('call test();');
ShowMessage(s);
end;
Also you can call procedures using button with action "SQL Query"
Also you can call procedures using button with action "SQL Query"
Could someone comment more on that? How do you call a procedure using a button with action "SQL Query"??
At the end of this post, Dmitry talks about stored procedures in MYSQL.
The MYSQL stored procedure can also be called using the button with the "SQL Query" function.
Unfortunately, MVD cannot create a stored function.
My Visual Database → SQL queries → SQl script
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi