mardi 9 juin 2015

Generate random ROWID

I'm trying to create a random ROWID for testing purposes. I know it's not the way to go, but since I have no data (yet) I just need to guarantee when inserting the "value" of the ROWID (using ROWIDTOCHAR function) I have a different string everytime.

I've been reading DBMS_ROWID from Oracle documentation and I've found a way to generate a ROWID for testing purposes using the ROWID_CREATE function.

DBMS_ROWID.ROWID_CREATE (
   rowid_type    IN NUMBER, 
   object_number IN NUMBER,
   relative_fno  IN NUMBER,
   block_number  IN NUMBER,
   row_number    IN NUMBER) 
  RETURN ROWID;

My question is: Is there a way to instantiate a random ROWID using this funcion? (Like a random function to generate the IN parameters)

Accordingly to what I've read in the DBMS_RANDOM page

  • DBMS_RANDOM.RANDOM produces integers in [-2^^31, 2^^31).
  • DBMS_RANDOM.VALUE produces numbers in [0,1) with 38 digits of precision.

And I'm not sure if the generated values are always valid to be IN parameters and generate a ROWID.




Aucun commentaire:

Enregistrer un commentaire