I have a CREATE FUNCTION statement in a text file. I need to add this function to a Pervasive database (v13 minimum) at runtime using ADO and the OLEDB provider. I could use ODBC if that is what it takes.
I have set up an ADOCommand object and an ADOQuery object. I drop the function if it exists like so:
cmd.CommandText := format('DROP FUNCTION IF EXISTS %s', [GetFunctionName(sl.Text)]); // sl is a StringList containing the content of the file
cmd.Execute;
Then I try to execute the CREATE FUNCTION text like so:
qry.SQL.Text := sl.Text; // sl is a StringList containing the content of the file
qry.Prepared := true;
qry.Parameters.Clear;
qry.ExecSQL;
{ or this way
cmd.CommandText := sl.Text; // sl is a StringList containing the content of the file
cmd.Parameters.Clear;
cmd.Execute;
}
I get this error using either a Command or Query to execute the text:
I think this is because variables in PSQL are identified by a leading ":" and ADO thinks they are parameter placeholders. Here is a snippet from my CREATE FUNCTION text as an example:
CREATE FUNCTION FormatDate(:sDate char(8))
--Version 2
--Comment Convert Sympac date string to DD/MM/YYYY
--Group Conversion
RETURNS char(10)
AS
BEGIN
DECLARE :dd char(2)
DECLARE :mm char(2)
DECLARE :yyyy char(4)
How can I run my CREATE FUNCTION text using ADO? Thanks in advance :)