Getting New RecID after SQL INSERT

Ruslan Zasukhin sunshine at public.kherson.ua
Fri Aug 20 19:28:41 CDT 2004


On 8/20/04 6:59 PM, "halldorg at vortex.is" <halldorg at vortex.is> wrote:

Hi Haldor,

> I think the issue is that Valentina employs a rather unusual "pointer" based
> relational schema, in most rdbms system the relation between tables is defined
> in terms of the primary key and all primary key values are transferred to the
> child....

Haldor, but Valentina (especially 2.0) honestly support few models

1) RDBMS model with primary key
2) ObjectPtr links 
3) Binary links (new to 2.0)

Valentina 2.0 in very beauty way build common abstraction for these 3
models. And I think function

    last_id()

Can have 100% the same sense for all models.
Actually I think we will need 2 functions

    last_id()   -- returns primary key, if you use PK and Relational model
    last_rec_id() -- works always for all models.


> In the case that started the original question Valentina is not really being
> used as a relational db, but rather a "pointer" based db - which is fine in
> itself but might cause some confusion when discussed in sql/relational terms.

Rigth, Frank have ask about SQL way.

If to use Cursor and Cusor.AddRecord()
Then we can get new RecID.

Frank want do this directly in SQL.
And this is correct wish.
Valentina claim that it EXTEND relational model.


> It is common to use rec_id of sql tables as unique reference but less common
> to use it as the relational key between tables - most rdbms use separate
> constructs such as "sequences" to provide running unique numbering systems for
> 
> that purpose(I hope V2 will sequences ?)
> 
> Methods such as "select max(rec_id)" from the internal record id could work to
> 
> get the latest inserted record in a single user db but in a server environment
> 
> it can hardly be relied on.
> 
> The first consideration should be to see if the database design could be
> improved and a suitable unique key other than rec_id found, or at least if the
> 
> rec_id is the only key, consider if creating a separate number field to
> manually create the relation may be a better choice.
> 
> Internal rec_id's are essential when working with "current" record but really
> a careless(lazy) way of constructing tble relations.

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list