Subject RE: [ib-support] Re: Firebird API, specifying table reservation.
Author Henrik Sitter
Hi Dan,

I'll try this out (tomorrow, I'm a bit tired now).
Thanks a lot :)

Henrik

-----Original Message-----
From: nitaligavino <Dan.Crea@...> [mailto:Dan.Crea@...]
Sent: Tuesday, January 14, 2003 4:58 PM
To: ib-support@yahoogroups.com
Subject: [ib-support] Re: Firebird API, specifying table reservation.

Hi Henrik:

Here is an example of how I build up a TPB when I want table
reservation. I typically build this up dynamically:

static char isc_tpb[] =
{
isc_tpb_version3,
isc_tpb_write,
isc_tpb_concurrency,
isc_tpb_nowait,
isc_tpb_lock_write, // OR isc_tpb_lock_read
7, // Length of table name to follow
'M',
'Y',
'T',
'A',
'B',
'L',
'E', // Table name must be UPPER case.
isc_tpb_protected // Reservation type
};

I had some trouble when I first worked with this, the documentation
seemed to be incorrect as their examples did not work. Anyway, this
is what I found works.

The key was getting the table reservation information correct. For
some reason the array needs to be built in this specific order:

isc_tpb_lock_write, // OR isc_tpb_lock_read
7, // Length of table name to follow
... table name here in upper case
isc_tpb_protected // Reservation type

If multiple tables are being reserved then it would look like:

...
isc_tpb_lock_write,
8,
'M',
'Y',
'T',
'A',
'B',
'L',
'E',
'1',
isc_tpb_protected,
isc_tpb_lock_write,
8,
'M',
'Y',
'T',
'A',
'B',
'L',
'E',
'2',
isc_tpb_protected

Hope this helps.

Best regards,
Dan

--- In ib-support@yahoogroups.com, "Henrik Sitter"
<henrik.sitter@e...> wrote:
> Hello,
>
> I'm working a bit with the Firebird API (version 1.0.0) and have the
> following code for the Transaction Parameter Buffer (tpb):
>
> static char isc_tpb[] = {isc_tpb_version3,
> isc_tpb_write,
> isc_tpb_read_committed,
> isc_tpb_no_rec_version,
> isc_tpb_wait,
> isc_tpb_protected,
isc_tpb_lock_write,
> "LEVERANDOR"
> };
>
> isc_start_transaction(status_vector, &tr1, 1, &db1,
static_cast<unsigned
> short>(sizeof(isc_tpb)), isc_tpb);
>
> This returns a transaction handle tr1 = 0.
>
> If I change the code to:
>
> static char isc_tpb[] = {isc_tpb_version3,
> isc_tpb_write,
> isc_tpb_read_committed,
> isc_tpb_no_rec_version,
> isc_tpb_wait,
> };
>
> isc_start_transaction(status_vector, &tr1, 1, &db1,
static_cast<unsigned
> short>(sizeof(isc_tpb)), isc_tpb);
>
> that is if I drop specifying a table reservation for the table
> LEVERANDOR, a valid transaction handle is returned.
>
> So the question is, can/can't I use table reservation in Firebird
> v.1.0.0, and if I can, what is the flaw in my code?
>
> Henrik



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/