Subject Re: [firebird-support] Two newbie questions
Author Dimitry Sibiryakov
On 18 Mar 2004 at 8:53, FrankE@... wrote:

>1. How do you do a 'select 50 * 100'. Firebird seems to require a 'from'
>clause. Is there some standard one row dummy table to use for this purpose?

RDB$DATABASE usually is used. But why you want to select a
constant? If you are writing a Stored Procedure, use assignment.

>I want to do an insert on a table that has a generator and I need to get
>the generated value back. I was going to do a 'select gen_id(some_gen, 1)'
>and then do the insert with the value that was returned.

That's right way to go.

>2. I would like to do a 'CONSTRAINT SOME_CONSTRAINT CHECK (x = (SELECT
>z.ID FROM Z z WHERE z.OTHER_ID = y))' where x and y are columns from the
>row being inserted. Basically x and y have a 1..* relationship in a
>different table (Z) and I want to make sure that is enforced when adding to
>the table in question.I believe that I will have to use an insert trigger
>for this check instead.

I'd use FOREIGN KEYs. Did you try CONSTRAINT SOME_CONSTRAINT
FOREIGN KEY (x, y) REFERENCES z (ID, OTHER_ID)?

SY, Dimitry Sibiryakov.