Subject | Re: [IBO] TIBOQuery inserts a null record |
---|---|
Author | mspencewasunavailable |
Post date | 2006-09-04T14:00:32Z |
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
substitution *must* be done prior to statement prep., so
anything that gets plugged in by the substituion is static
until and unless the statement gets re-prepared.
In the meantime, I've just taken it out altogether for
testing, because the SESSION_ID is only critical if there
are multiple users. IOW there's no WHERE clause and no macro
stuff on the select at all. This has caused no change in
behavior.
of one. Macro substitution clearly has to happen prior to
statement prep. At that point, the substituted text is
*static* and won't be changed (unless it involved
introducing a parameter which would then get parsed...).
Did you think I supposed that I could changed the value
which gets substituted for <<SESSIONID>> after preparation?
Does anybody actually ever think that?
The only question is whether IBO is doing an "unnecessary"
re-prepare because it considers the existence of an assigned
OnMacroSubstitute procedure to be the same as an SQL change.
macro. Even *I* thought a macro here was a bad idea,
especially when I could just do a straight assignment
(FieldByName('SESSION_ID').AsInteger := x;) and the
parameter part would get done without further intervention
on my part.
Ouch!
not with you. But I added a primary key to the table (and
removed the macro stuff) and still get the null rows, so
evidently, I'm doing something else wrong. I'll keep
working to isolate things further. Something will turn up
eventually.
Michael D. Spence
Mockingbird Data Systems, Inc.
>other
> At 01:24 PM 4/09/2006, you wrote:
> >--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@> wrote:
> > >
> > > At 04:17 AM 4/09/2006, you wrote:
> > > >1) The TIBOQuery I'm using has the following items set (I've
> > > >redacted some of the fields for brevity):
> > > > (Really long stuff removed)
> > > >
> > > >As you can see, Description and for that matter, all of the
> > > >fields are now null. What could cause this?of)
> > >
> > > Don't use macros to try to define parameters - use the correct
> >syntax, viz.
> > >
> > > WHERE SESSION_ID = :session_id
> > >
> > > Architecturally, it's a bad decision in any case to
> >provide "static"
> > > SQL for a statement that has search values that are going to
> > > change. Even in the best case (where the timing is taken care
> >itre-
> > > causes an enormous amount of overhead because the whole query,
> > > including structures related to the XxxxSQL statements, get
> > > invalidated and the statement itself has to be unprepared and
> >prepared.Man
> > >
> > > In this case, where you are depending on OnMacroSubstitute to
> >alter
> > > the value in SESSION_ID, you're almost certainly encountering a
> > > timing issue. If you need to apply a pre-execution change to a
> > > search value, use a parameter and apply the change in the
> >BeforePost event.
> >
> >
> >I see what you're saying, but the SESSION_ID *is* static.
> >It's set to a unique value when the application starts and
> >never changes (for a given app instance) after that. Here's
> >the IBMonitor log for that select:
> >
> >SELECT "Date", "Code", "Serv ID", "Description", "Qty","Amount",
> > "Base Price", "Tax Code", "Tax", "Extended", "Crew","Zone",
> > "Route", "Cost", "Scheduled", "Qty Used", "Man Hours","Old
> > Date", "Old Code", "Old Serv ID", "Old Qty", "Old Amount","Old
> > Base Price", "Old Tax Code", "Old Tax", "Old Qty Used", "Old
> > Hours", SESSION_ID , EDITINV.RDB$DB_KEY FROM EDITINV WHERESQL
> > SESSION_ID = 67
> >
> >In other words, SESSION_ID will always be 67 until I stop
> >the app and start it again. Suppose "Code" had values "A"
> >and "B" and I only wanted to see WHERE "CODE" = A. Are you
> >saying I should use a parameter for a case like that?
>
> No. But this isn't the same thing. When you use a macro in an
> statement, you're saying "Every time you process this statement,run
> the macro in place of the macrotised piece". So the actual*string*
> that the parser process is changed and, even though *you* knowthat
> it's going to be the same every time, IBO doesn't; as far as it'sfor
> concerned, "changing the string" is "changing the specification
> the output". This is different to both a hardcoded string thatthat
> doesn't change and to a parameterised statement. Please confirm
> you understand what I'm saying here as it's crucial. Basically,anticipate.
> you're introducing backwaters of logic that IBO has no reason to
>I understand perfectly well what you're saying. Macro
substitution *must* be done prior to statement prep., so
anything that gets plugged in by the substituion is static
until and unless the statement gets re-prepared.
In the meantime, I've just taken it out altogether for
testing, because the SESSION_ID is only critical if there
are multiple users. IOW there's no WHERE clause and no macro
stuff on the select at all. This has caused no change in
behavior.
>difference
> >And just out of curiousity, what would the timing issues be
> >if SESSION_ID changed? (I'm not trying to debate
> >architecture here, I'm just trying to learn.)
>
> Even your question indicates that you don't understand the
> between a variable and a replaceable parameter.many
>
> You assign a statement to an object - a dataset, in this case. At
> various points in the processing of this statement for a myriad of
> purposes, IBO passes through a cycle of steps (read, implemented
> behaviours for objects) that are sequence dependent. Of course,
> objects are involved, each with its own event cycle arranged insuch
> a sequence that everything happens at the right time (where "time"example,
> and "timing" refers to milestones in the sequence, not how long it
> takes or whether it is lunchtime..)
>
> But you intervene with a macro, for which, at a certain point, IBO
> has to process the OnMacroSubstitute event handler. So, for
> if it finds it had to do that at a point where the statement isOh. Well, then there's no timing issue here and no possibility
> prepared and all it needs is to go and read the Params and Fields
> arrays, it's potentially in a place where there's a hole - a state
> change that it doesn't know about.
of one. Macro substitution clearly has to happen prior to
statement prep. At that point, the substituted text is
*static* and won't be changed (unless it involved
introducing a parameter which would then get parsed...).
Did you think I supposed that I could changed the value
which gets substituted for <<SESSIONID>> after preparation?
Does anybody actually ever think that?
The only question is whether IBO is doing an "unnecessary"
re-prepare because it considers the existence of an assigned
OnMacroSubstitute procedure to be the same as an SQL change.
> From the monitor output, atthe
> point where the InsertSQL was being executed, the "SESSION_ID"Not relevant. The InsertSQL *uses* a parameter, not a
> parameter of the Insert statement was zero.
macro. Even *I* thought a macro here was a bad idea,
especially when I could just do a straight assignment
(FieldByName('SESSION_ID').AsInteger := x;) and the
parameter part would get done without further intervention
on my part.
>right
> Now whether that's exactly the cause of the problem, or something
> else down track, or because you're referring to this SESSION_ID
> thingy (be it variable, parameter or whatever) with and without
> double-quotes, I could not guess and I don't have the time or the
> inclination to do the forensics. I'd rather see you do it the
> way than waste my effort trying to find how you can make it workparameters
> doing it the wrong way.
>
> > > you accept the concept that substitutable (replaceable)
> > > are *not* variables. There are several ways to come to griefwhen
> > > you treat them as though they were....from a stone.
> > >
> >
> >Don't think so, I've used this in several other tables and
> >it's worked just fine. All of these tables contain a very
> >small number of rows (like, 12 or maybe 20) and are only in
> >the database so that VCL controls can get at their data. If
> >Firebird had per-session temporary tables, then it would've
> >been much simpler for me to use them.
>
> Fine; then I guess you just need to keep trying to squeeze blood
Ouch!
>futile
>
> >I'll bet there's some error case in IBObjects that's getting
> >provoked by the fact that there isn't a primary key at all
> >on this table. It's just a (very short) list of stuff whose
> >order is not important. The XxxxxxSQL statements don't get
> >autogenerated, which is probably also a bad sign. I could
> >certainly see that this might be related to unsuitable
> >keylinks.
>
> Sure could. But I guess it's fodder for a whole new round of
> argument to defend the principle that tables in relationaldatabases
> need keys. Please have that argument with someone else....No argument from me about things like that, and especially
not with you. But I added a primary key to the table (and
removed the macro stuff) and still get the null rows, so
evidently, I'm doing something else wrong. I'll keep
working to isolate things further. Something will turn up
eventually.
Michael D. Spence
Mockingbird Data Systems, Inc.