Subject Re: [firebird-support] Re: named parameter always replaced by '?'
Author Martijn Tonies
> > > I'm sorry, I was trying out a few procedures and I paste the wrong
> > > extract of a different procedure which is not related to the earlier
post.
> > >
> > > So the correct modified part of the stored procedure related to the
> > > earlier post is as follows:
> > >
> > > -----
> > > CREATE PROCEDURE TEST (
> > > FIELD1 INTEGER)
> > > RETURNS (
> > > FIELD2 INTEGER)
> > > AS
> > > Begin
> > > FOR SELECT FIELD2 FROM TABLE1
> > > WHERE FIELD1 = ? /* PRM_0 */
> > > INTO "FIELD2"
> > > DO
> > > BEGIN
> > > SUSPEND;
> > > END
> > > End
> > > ------
> > >
> > > I tried using upscene latest dbexpress trial driver, I notise '? /*
> > > PRM_0 */' was inserted into the procedure. Any clue?
> >
> >And this happens with "ParamCheck" = "False"?
>
> The "clue" is that he is getting a ParamCheck happening inside stored proc
> source. He should switch it off to stop the parser treating it as a
> parameter (which it's not).

I know that ;-)

> And correct the syntax of the SP to pre-empt the next exception (INTO
> "FIELD2" will cause an exception once he fixes the ParamCheck problem).

I think there's more to it ...

I remember something -- when setting SQL at DESIGN TIME in Delphi,
the ParamCheck is ignored -> it ALWAYS checks for parameters.
I reported this in QC, but it was "as designed".

(checking the source now)
See:
procedure TSQLQuery.QueryChanged(Sender: TObject);
var
List: TSQLParams;
begin
if not (csReading in ComponentState) then
begin
Close;
SetPrepared(False);

----->>
if ParamCheck or (csDesigning in ComponentState) then
begin
List := TSQLParams.Create(Self);
try
FText := SQL.Text;
List.Parse(FText, True);
List.AssignValues(FParams);
FParams.Clear;
FParams.Assign(List);
finally
List.Free;
end;
end else
FText := SQL.Text;
DataEvent(dePropertyChange, 0);
end else
FText := FParams.ParseSQL(SQL.Text, False);
SetFCommandText(FText);
end;


So you cannot get around this, but setting the SQL (if you
want to create a Procedure) at RUNTIME only.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com