dbTalk Databases Forums  

Is it possible to have an array in a table?

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


Discuss Is it possible to have an array in a table? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ramon F Herrera
 
Posts: n/a

Default Is it possible to have an array in a table? - 08-22-2009 , 03:07 PM






Can a table contain data arranged in two dimensions, and accessible
through a pair of integer subscripts?

I can live with 1-dimensional arrays, too.

TIA,

-RFH

Reply With Quote
  #2  
Old   
Ramon F Herrera
 
Posts: n/a

Default Re: Is it possible to have an array in a table? - 08-22-2009 , 03:09 PM






On Aug 22, 4:07*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:
Quote:
Can a table contain data arranged in two dimensions, and accessible
through a pair of integer subscripts?

I can live with 1-dimensional arrays, too.

TIA,

-RFH
Bonus question:

I believe it is possible to save an arbitrary file (let's say an MS
Word or PDF document) in Oracle. I'd appreciate the details on that.

TIA,

-Ramon

Reply With Quote
  #3  
Old   
John Hurley
 
Posts: n/a

Default Re: Is it possible to have an array in a table? - 08-22-2009 , 03:46 PM



On Aug 22, 4:09*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:

snip

Quote:
Bonus question:

I believe it is possible to save an arbitrary file (let's say an MS
Word or PDF document) in Oracle. I'd appreciate the details on that.

TIA,

-Ramon
asktom.oracle.com ... which also applies to your first question.

Reply With Quote
  #4  
Old   
Ramon F Herrera
 
Posts: n/a

Default Re: Is it possible to have an array in a table? - 08-23-2009 , 01:39 AM



On Aug 22, 4:46*pm, John Hurley <johnbhur... (AT) sbcglobal (DOT) net> wrote:
Quote:
On Aug 22, 4:09*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:

snip

Bonus question:

I believe it is possible to save an arbitrary file (let's say an MS
Word or PDF document) in Oracle. I'd appreciate the details on that.

TIA,

-Ramon

asktom.oracle.com ... which also applies to your first question.

Thanks, John. That is indeed a helpful resource.

In reference to arrays (or VARRAYs) I have a question for you folks
out there. According to the examples that I read, a VARRAY can be used
when there is a small number of items. The example mentions a person/
organization with a variable number of phone numbers, of to 6.

What about a larger number of items? In that case, is it:

- inefficient
- inelegant
- undesirable
- not recommended

to use VARRAYs perhaps?

The characteristic that I value the most about arrays is the ability
to iterate with an integer(s). Also important is the fact that if an
item is in position 52, I can rely on it being there next time.

TIA,

-Ramon

Reply With Quote
  #5  
Old   
Ramon F Herrera
 
Posts: n/a

Default Re: Is it possible to have an array in a table? - 08-23-2009 , 01:41 AM



On Aug 23, 2:39*am, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:
Quote:
On Aug 22, 4:46*pm, John Hurley <johnbhur... (AT) sbcglobal (DOT) net> wrote:

On Aug 22, 4:09*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:

snip

Bonus question:

I believe it is possible to save an arbitrary file (let's say an MS
Word or PDF document) in Oracle. I'd appreciate the details on that.

TIA,

-Ramon

asktom.oracle.com ... which also applies to your first question.

Thanks, John. That is indeed a helpful resource.

In reference to arrays (or VARRAYs) I have a question for you folks
out there. According to the examples that I read, a VARRAY can be used
when there is a small number of items. The example mentions a person/
organization with a variable number of phone numbers, of to 6.

What about a larger number of items? In that case, is it:

*- inefficient
*- inelegant
*- undesirable
*- not recommended

to use VARRAYs perhaps?

The characteristic that I value the most about arrays is the ability
to iterate with an integer(s). Also important is the fact that if an
item is in position 52, I can rely on it being there next time.

TIA,

-Ramon
I meant "up to 6"

-RFH

Reply With Quote
  #6  
Old   
Vladimir M. Zakharychev
 
Posts: n/a

Default Re: Is it possible to have an array in a table? - 08-23-2009 , 02:34 AM



On Aug 23, 10:39*am, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:
Quote:
On Aug 22, 4:46*pm, John Hurley <johnbhur... (AT) sbcglobal (DOT) net> wrote:

On Aug 22, 4:09*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:

snip

Bonus question:

I believe it is possible to save an arbitrary file (let's say an MS
Word or PDF document) in Oracle. I'd appreciate the details on that.

TIA,

-Ramon

asktom.oracle.com ... which also applies to your first question.

Thanks, John. That is indeed a helpful resource.

In reference to arrays (or VARRAYs) I have a question for you folks
out there. According to the examples that I read, a VARRAY can be used
when there is a small number of items. The example mentions a person/
organization with a variable number of phone numbers, of to 6.

What about a larger number of items? In that case, is it:

*- inefficient
*- inelegant
*- undesirable
*- not recommended

to use VARRAYs perhaps?

The characteristic that I value the most about arrays is the ability
to iterate with an integer(s). Also important is the fact that if an
item is in position 52, I can rely on it being there next time.

TIA,

-Ramon
Read up on nested tables and associative arrays in the docs for your
Oracle release. Note that true arrays (associative arrays aka INDEX BY
tables) are only available in PL/SQL. VARRAYs are somewhat limited
because they have finite predeclared capacity (you must declare
maximum VARRAY size,) and nested tables are unordered unless you
include an index column, always ORDER BY that index and maintain it
yourself. VARRAYs are stored in LOBs, so they become a bit less
efficient as they grow, but not dramatically.

Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

Reply With Quote
  #7  
Old   
Serge Rielau
 
Posts: n/a

Default Re: Is it possible to have an array in a table? - 08-23-2009 , 08:05 AM



Ramon,

Generally you should use side tables with referential integrity to store
such data.
Let's use your phone number example.
It is trivial for the DBMS to reverse lookup a name from a phone number
if the data is stored in relational format: (empid, number)
If you store your phone-numbers in an array there will be no indexing,
no statistics, no detection of duplicate numbers.

ARRAYs belong into the world of procedural logic, not relational, IMHO

Cheers
Serge
--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

Reply With Quote
  #8  
Old   
Ramon F Herrera
 
Posts: n/a

Default Re: Is it possible to have an array in a table? (again) - 08-31-2009 , 11:02 PM



On Aug 22, 4:07*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:
Quote:
Can a table contain data arranged in two dimensions, and accessible
through a pair of integer subscripts?

I can live with 1-dimensional arrays, too.

TIA,

-RFH
Thanks to everyone for their help...

I would like to provide a specific example of what I am trying to
accomplish. Let's say I run a circus and every day I get the totals
sold in a given week.

Categories are: ticket sales, cotton candy, souvenirs, etc.

My application needs to display the sales like this:

Ticket Sales
8/22/2009: $8492.10
8/15/2009: $9024.31
8/8/2009: $7893.03
8/1/2009: $8945.67

People keep on recommending the SQL paradigm, but the above looks to
me like something that must be handled by arrays.

I need to display the 6 most recent weeks and I keep on pushing the
most recent sales figures at the top, while I roll down and eventually
drop the oldest data. This kind of think MUST be handled with an
index, such as week-1 or week-2.

If I followed the relational model, I would need to hardcode records
such as:

CURRENT_WEEK
WEEK_MINUS_1
WEEK_MINUS_2
etc.

That would be a nightmare to code.

So, the question is how to implement the records (with arrays?) for a
rolling scenario like the above described.

Thanks!

-Ramon

Reply With Quote
  #9  
Old   
joel garry
 
Posts: n/a

Default Re: Is it possible to have an array in a table? (again) - 08-31-2009 , 11:27 PM



On Aug 31, 9:02*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:
Quote:
On Aug 22, 4:07*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:

Can a table contain data arranged in two dimensions, and accessible
through a pair of integer subscripts?

I can live with 1-dimensional arrays, too.

TIA,

-RFH

Thanks to everyone for their help...

I would like to provide a specific example of what I am trying to
accomplish. Let's say I run a circus and every day I get the totals
sold in a given week.

Categories are: ticket sales, cotton candy, souvenirs, etc.

My application needs to display the sales like this:

Ticket Sales
8/22/2009: $8492.10
8/15/2009: $9024.31
8/8/2009: *$7893.03
8/1/2009: *$8945.67

People keep on recommending the SQL paradigm, but the above looks to
me like something that must be handled by arrays.

I need to display the 6 most recent weeks and I keep on pushing the
most recent sales figures at the top, while I roll down and eventually
drop the oldest data. This kind of think MUST be handled with an
index, such as week-1 or week-2.

If I followed the relational model, I would need to hardcode records
such as:

CURRENT_WEEK
WEEK_MINUS_1
WEEK_MINUS_2
etc.

That would be a nightmare to code.

So, the question is how to implement the records (with arrays?) for a
rolling scenario like the above described.

Thanks!

-Ramon
This sounds like a job for analytics. They're built into the engine,
optimizer understands them. Look at the docs, orafaq, asktom for
many, many examples.

See here: http://www.oracle.com/technology/obe.../outerjoin.htm

You might remember to state what you are trying to accomplish at the
start of a thread, rather than ask about how a more primitive
technology would do it.

jg
--
@home.com is bogus.
Is it possible to not be able to shift into neutral while the
accelerator is jammed wide open?
http://www3.signonsandiego.com/stori...ug-/?uniontrib

Reply With Quote
  #10  
Old   
Ramon F Herrera
 
Posts: n/a

Default Re: Is it possible to have an array in a table? (again) - 09-01-2009 , 12:36 AM



On Sep 1, 12:27*am, joel garry <joel-ga... (AT) home (DOT) com> wrote:
Quote:
On Aug 31, 9:02*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:



On Aug 22, 4:07*pm, Ramon F Herrera <ra... (AT) conexus (DOT) net> wrote:

Can a table contain data arranged in two dimensions, and accessible
through a pair of integer subscripts?

I can live with 1-dimensional arrays, too.

TIA,

-RFH

Thanks to everyone for their help...

I would like to provide a specific example of what I am trying to
accomplish. Let's say I run a circus and every day I get the totals
sold in a given week.

Categories are: ticket sales, cotton candy, souvenirs, etc.

My application needs to display the sales like this:

Ticket Sales
8/22/2009: $8492.10
8/15/2009: $9024.31
8/8/2009: *$7893.03
8/1/2009: *$8945.67

People keep on recommending the SQL paradigm, but the above looks to
me like something that must be handled by arrays.

I need to display the 6 most recent weeks and I keep on pushing the
most recent sales figures at the top, while I roll down and eventually
drop the oldest data. This kind of think MUST be handled with an
index, such as week-1 or week-2.

If I followed the relational model, I would need to hardcode records
such as:

CURRENT_WEEK
WEEK_MINUS_1
WEEK_MINUS_2
etc.

That would be a nightmare to code.

So, the question is how to implement the records (with arrays?) for a
rolling scenario like the above described.

Thanks!

-Ramon

This sounds like a job for analytics. *They're built into the engine,
optimizer understands them. *Look at the docs, orafaq, asktom for
many, many examples.

See here: *http://www.oracle.com/technology/obe...rjoin/outerjoi...

You might remember to state what you are trying to accomplish at the
start of a thread, rather than ask about how a more primitive
technology would do it.

jg
--
@home.com is bogus.
Is it possible to not be able to shift into neutral while the
accelerator is jammed wide open?http://www3.signonsandiego.com/stori...cer-kin-report...
Thanks Joel.

However, I am not sure that your suggestion is what I need:

- My data is not sparse
- I am not comparing anything

Assume that instead of dollar amounts I have the "Plate of the week".
No software can compare dishes. My interest is in shifting a large
number of weeks, several years.

The intrinsic nature of the data is tabular, let's say an array of 156
entries (3 years). It would be really easy to shift with indices.

-Ramon

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.