Subject Re: view generator
Author phoove27
> >I created and set a generator as follows:
> >
> >CREATE GENERATOR UNIQNO;
> >
> >SET GENERATOR UNIQNO TO 10000;
> >
> >
> >I also created a view as follows:
> >
> >CREATE VIEW "VUNIQNO"
> >(
> > "UNIQ_NO"
> >) AS
> > SELECT GEN_ID(UNIQNO, 1) FROM RDB$DATABASE;
> >
> >
> >In IBConsole, I connect to my database and click on VIEWS. Then
> >after double-clicking the VUNIQNO view I attempt to click on the
> >DATA tab. The following message appears:
> >
> >Dynamic SQL Error
> >SQL error code = -104
> >Token unknown ­ line 1, char 24
> >)
> >
> >
> >Can anyone tell me what I am doing wrong here? I am using Firebird
> >1.0 for Linux.
>
> Aaargh!!!
> This statement:
>
> SELECT GEN_ID(UNIQNO, 1) FROM RDB$DATABASE
>
> would "up" the generator by 1 each time it is called.


Yes, this is precisely the behavior that I need.


> To read the generator's last generated value, you need:
>
> SELECT GEN_ID(UNIQNO, 0) FROM RDB$DATABASE


I tried creating the view as you suggest, using a step of 0.
Unfortunately for me, I still get the same error message.


> As for what is giving you the error in IBConsole, it could be
> anything.


"Anything" is somewhat vague. Concrete suggestions would be most
helpful to me. Perhaps someone would be so kind as to create the
view that I have put forward here, and let me know what results they
obtain?


> It might be fun to put an SQL Monitor over IBConsole's
> query and see what it's doing to your statement. It works fine
> in IB_SQL and ISQL.


I really have no idea how to "put an SQL Monitor over IBConsole's
query". How do I do this? What is an SQL Monitor, and how do I
obtain one?


> Anyway, this is a pretty useless sort of view to make, considering
> that you can get exactly the same data back (and optionally push
> up the generator value) via the plain ol' statement.


Useless or not, I am trying to follow along with Marco Cantu on page
677 of his "Mastering Delphi 6" (Sybex, 2001).

I know I am begging for help here, and I know that "beggars can't be
choosers," but is it customary for responders to berate questioners
on this list? Doesn't such behavior tend to make people fearful of
posting both the initial question and any subsequent replies?

Thanks,
Paul