OID queries

Bart Pietercil bart.pietercil at cognosis.be
Mon Jun 9 04:02:06 CDT 2008


Hi Ruslan,

On 09 Jun 2008, at 10:02, Ruslan Zasukhin wrote:

> On 6/9/08 10:45 AM, "Bart Pietercil" <bart.pietercil at cognosis.be>  
> wrote:
>
> Hi Bart,
>
>> why does this query not work:
>> select ** where OID = 176093659137
>>
>> gives unexpected token (wants to see FROM I guess)
>
> Right, should be
>
> SELECT **
> FROM T
> WHERE OID = 176093659137
>
>
>> But since an OID is unique in the database and as I understand the
>> first part of the ID refers to the table, shouldn't Valentina be able
>> to resolve this.
>
> Correction.
>
> VALUE of OID field is unique, right.
>    but OID, like any other field, belongs to some table.
>
>
>> I find this rather important since it spares me the addition of  
>> adding
>> a field to a table that identifies the table the id is coming from.
>
>> Just to make it clear I do not want to use an objectpointer because  
>> an
>> objectpointer is limited to pointing to a predefined table.
>
> Right, also note that
>
>    sizeof(ObjectPtr) == sizeof(ULONG)  == sizeof(ReCID) == 4
>
> But
>    sizeof(OID) == 8
>
> So to have kind of POINTER ON OID, you need to use in some table  
> ULLONG
> field.
>
>
>> In the design I need I need to be able to store a pointer to any
>> table. Normally I solve this by using 2 fields (ID (long) and
>> Tablename(varchar)).
>> However this functionality seems to be in the OID but not implement  
>> in
>> the SQL parser.
>
>
> I wonder, if you have see this page
>
> <http://www.valentina-db.com/dokuwiki/doku.php?id=paradigma:public:en:docume
> ntation:vkernel:vfield:oid&s=oid>
>
> It give example of simple function which allow by OID value found  
> table and
> record.
>
> Let me know if this is not enough

Well indeed this seems to point to the solution I am looking for  
however I don't see how to translate this to SQL

// This function returns a Table pointed by a given OID
// and this Table has the current record pointed by OID.
//
VTable VDatabase.GoToRecord( inOID )
{
     TableID tblID = (TableID)(inOID >> 32);

     // Find table by its ID
     VTable tbl = this->get_Table( tblID );
     if( tbl )
         tbl.Recid = inOID & 0xFFFFFFFF;

     return tbl;
}

Could I  write this as a stored procedure ?

TIA

Bart


More information about the Valentina mailing list