Subject Re: [IBO] Re: Help understanding query param anomaly
Author Helen Borrie
At 11:46 AM 1/03/2008, you wrote:
>> Why not show us the actual SQL so that one doesn't have to iterate
>through 1001 possible scenarios?
>
>Yes, that is a reasonable question: Am I the only one who is getting
>emails from Lyris ListManager when I post code:
>
>"The following lines in your email message did not appear to be
>Lyris ListManager commands and were skipped:"

Hmmm, somebody subscribed Xsome Lyris Listmanager thingie to the IBO list. After several days of getting automatically-generated rejection notices from some Lyris Listmanager server, I searched for it in the IBO subscriber list and removed and banned it. So, if it was you who did this "favour" for us, it wasn't appreciated, ta very much.


>blah blah blah
>
>Needless to say, I've become paranoid about submitting code on these
>Yahoo groups because sometimes it appears, sometimes it doesn't and
>sometimes SOME of it does and SOME doesn't which doesn't do much for
>intelligent postings.

Well, unless an individual subscribes to a list as a real person with a real email address, he's going to cause administrative problems somewhere.


>Here goes again - my fingers are crossed.
>
>PK (FOLDERID) is generated in a trigger.

Then, because this is an INSERT statement, you should omit FOLDERID from both the target list and the params unless you're going to use that FOLDERID for something later in your code, otherwise you're wasting a round trip by using GeneratorLinks here.

Your BeforeInsert trigger should be written so as to fire only if


>NewFolderName is returned from the InputQuery dialog, and is always
>exactly what it needs to be

The workflow is all wrong. Things happening at the wrong time and/or in the wrong sequence.

This part should be done once, before you invoke the InputQuery dialog:

> qryAddFolder.SQL.Clear;
> qryAddFolder.SQL.Add('INSERT INTO FOLDERSNOTES ');
> qryAddFolder.SQL.Add('(TEMPLATEID,FOLDERCAPTION) ');
> qryAddFolder.SQL.Add('VALUES(:TID,:FC)');

Adding this:
If not qryAddFolder Prepared then
qryAddFolder.Prepare;

Then, in your qryAddFolder object's BeforeExecute, do this:

1. Include this:
var
i: integer;

Then:
1. invoke the InputQuery dialog (or something better) to get the value for your NewFolderName parameter.

NewFolderName := xxxxxxxxxxxxxxxxxxxxx; (I'd write a function and call it)

And then code the body of the handler as follows:

2. with qryAddFolder do
for i:= 0 to ParamCount - 1 do
begin
Params[i].Clear;
case i of
0: Params[i].AsInteger := 0;// stuff for templates
1: Params[i].AsString := NewFolderName;
end;
end;

That's it. You can put FOLDERID back and adjust the assignments accordingly if you need to.

Helen