Subject AW: [firebird-support] question table numbers in select
Author Olaf Kluge
Hi Set.



I think the 2nd Way ist the better. In the first, I must integrate each new
table.



The solution with views is great. Hitherto I wanted to implement this on the
table-level for a better clarity.



Thanks for your great thought for thought :o)



Have a nice weekend.



Best regards.



Olaf

>>>Now I get the tablename from tcategory and I would like to update the
>>>record in the right table.
>>Your suggestion is a viable way. It does not seem to be possible
>>without a statement?
>
>I don't think I understand, in order to do an update, I always use an
>UPDATE statement, in order to select I always use a SELECT statement,
>I'd even say I use a COMMIT statement to commit my transactions. So what
>exactly do you mean with STATEMENT?
>I would like to update the table without a text-execute-statement. In
>this community I have learned that a execute statement 'insert into '
>|| :tablename || . is slower than an real statement. You know what I
>mean?

Ah, OK! I can think of two other options. The obvious is:

EXECUTE BLOCK(ID INTEGER, STATE VARCHAR(55)
AS
DECLARE VARIABLE S VARCHAR(255);
BEGIN
SELECT C.TABLE
FROM CATEGORIES C
JOIN MEMBERS M ON C.CATEGORY = M.CATEGORY
WHERE M.ID = :ID
INTO :S;
IF (S = 'TCOMPRESSOR') THEN
BEGIN
UPDATE TCOMPRESSOR SET STATE = :STATE
WHERE ID = :ID;
END
IF (S = 'TVALVE') THEN
BEGIN
UPDATE TVALVE SET STATE = :STATE
WHERE ID = :ID;
END
END;

The other one is to merge TCOMPRESSOR and TVALVE into one table (at least
for the STATE field, possibly for others or all fields), and then consider
having VIEWs to make it appear to the user that this field is part of the
same table as other fields specific to TCompressor or TValve.

HTH,
Set





[Non-text portions of this message have been removed]