Subject Re: [firebird-support] PK and calculations on server side
Author Ann W. Harrison
At 01:19 PM 11/22/2004, Gediminas wrote:

>have two questions:
>table has 2 columns and both them defined PK.

I hope you mean that you have a table with fields A and
B and the primary key is defined as A,B.

>Everything is ok until
>table gets empty (removed all data) and insert is called - got error
>saying, that PK is violated & etc info.

That's unusual.

> Is this caused by the fact,
>that PK consists of all (2) table columns?

No, as far as I know there is no such requirement. Was the
error something like "attempt to store duplicate value visible
to active transaction"? If so, you've got another active
transaction. It can still see the records you deleted, so you
can't replace them yet.

>or it's strongly advised to
>have additional ID column for the table? FB1.5.x

No.

>need to implement computations on the server side - fear, that some of
>them would require complex logic and work with the selected dataset's.
>How to implement them - use SQL in the SP's (when question, how to
>work with the selected dataset's - create internal views for them?) or
>to write UDF's? what about performance in both cases? any other
>underwater rocks?

Stored procedures can work on selected data sets. UDF's take fixed
input and return a single value. You can not, for example, create
a stddev UDF because a UDF can't take a record set as input. Depending
on the logic, you may need to implement some functions as UDF's and
call them from stored procedures.

Regards,


Ann