Subject Re: [ib-support] Re: generator of generators
Author Lucas Franzen
Duilio,

> > No, it's not possible. You cannot perform any DDL in server code
> modules.
>
> ok
>
> >I think your idea is really bad-bad-bad!!!
>
> frankly I see no other way to do it.
>
> Maybe I did not make the problem clear enough.
>
> I have N companies accessing a (common) database.
>
> Every time a record is inserted by company X, it must be uniquely
> identified.
>
> As M users of company X can access the database at the same time, the
> only safe way to get a unique ID is to use a generator.
>
> Theoretically, a single generator could be used by all users of all
> companies, but this is not wanted.
>
> So every company must have its own generator.
>
> If you see another solution, please let me know.
>
> >How could you possibly know which generator generated a particular
> number?
>
> every company is identified by a number, say N.
>
> >Are you planning to read Gen_id (generatorname, 0) to count records?
>
> I am planning to read
>
> Gen_id (generator_N, 1)

But this isn't possible in SP's and triggers either, since you can't
user the generatorname as a variable (i.e. the only possible way to
distinguish which of the generators Generator_1 .. Generator_N should be
used is to write a IF .. ELSE IF .. ELSE IF construct for every possible
value from 1..N to match the appropriate generator).

So this can't be a solution either, I think.

Why don't you use a common generator for all?
Your selects have to respect the Company number anyway, otherwise you're
showing data from a different company.

>
> to get the number of the next record inserted by company N.

No. With Gen_id (generator_N, 1) you won't get the number of records
inserted for a company, you'll getthe number of "tried" (and maybe
cancelled or later deleted) inserts plus 1 for the company.

>
> I am eager to hear how you would solve the problem and why you judge
> so bad (3 times bad) my idea :)
>
> Thank you
>
> Duilio
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/