dbTalk Databases Forums  

creating a timecode type?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss creating a timecode type? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mh@pixar.com
 
Posts: n/a

Default creating a timecode type? - 02-24-2009 , 01:37 AM






Here's a question from a coworker. The data type is a video timecode,
which is a standard used in video cameras, video editing programs, and
video players such as quicktime.

I've never created a custom type before, so I'm hoping to get
some good advice for him here... thanks!

My coworker writes:
Quote:
We'd like to store time values in Oracle like this:

numerator int64
denominator int64
flags byte (normal, infinite, indeterminate)

Ideally we would also like to perform logical operations like =, < and
on them.

I imagine three paths forward:

1. Encode them into a string and use custom functions to perform
comparison operations.
2. Encode them into three separate fields and use custom functions to
perform comparison operations.
3. Tell Oracle about this new data type at a lower level.

I can imagine that someone else in the world has wanted to add timecode,
or complex numbers or astronomical positions or some other wacky data
type - does Oracle have a nice solution for this?

--
Mark Harrison
Pixar Animation Studios


Reply With Quote
  #2  
Old   
Laurenz Albe
 
Posts: n/a

Default Re: creating a timecode type? - 02-24-2009 , 04:32 AM






mh (AT) pixar (DOT) com wrote:
Quote:
Here's a question from a coworker. The data type is a video timecode,
which is a standard used in video cameras, video editing programs, and
video players such as quicktime.

I've never created a custom type before, so I'm hoping to get
some good advice for him here... thanks!

My coworker writes:
We'd like to store time values in Oracle like this:

numerator int64
denominator int64
flags byte (normal, infinite, indeterminate)

Ideally we would also like to perform logical operations like =, < and
on them.

I imagine three paths forward:

1. Encode them into a string and use custom functions to perform
comparison operations.
2. Encode them into three separate fields and use custom functions to
perform comparison operations.
3. Tell Oracle about this new data type at a lower level.

I can imagine that someone else in the world has wanted to add timecode,
or complex numbers or astronomical positions or some other wacky data
type - does Oracle have a nice solution for this?
You can create a custom object type with the CREATE TYPE statement.

For comparisons, define a MAP member function.

Code for object type member functions is typically written in PL/SQL
or Java.

Some pointers (for Oracle 10.2):

CREATE TYPE and CREATE TYPE BODY in the SQL Documentation:
http://download.oracle.com/docs/cd/B...b14200/toc.htm

How to do it in PL/SQL (contains a MAP function):
http://download.oracle.com/docs/cd/B...61/objects.htm

How to do it in Java (Chapter 5 and 6 are particularly interesting):
http://download-uk.oracle.com/docs/c...b14187/toc.htm

Yours,
Laurenz Albe


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.