Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

selecting from oracle nested table

 
   Database Forums (Home) -> Oracle RSS
Next:  Running Legacy DTS on x64 2005 cluster  
Author Message
Tim B

External


Since: Jul 20, 2006
Posts: 5



(Msg. 1) Posted: Fri Nov 02, 2007 3:57 am
Post subject: selecting from oracle nested table
Archived from groups: comp>databases>oracle>misc (more info?)

The task I have is to output some messages from a procedure in a package.
The package is run in a shell script from plsql by piping the output from
the proc to a file. There is a need to have 4 different types of messages in
the report with some sorting. I want to output to one file only.

A possible solution is to accumulate the messages in 4 collections - I'm
starting with nested tables of varchar2- and then dbms_output.putline() the
messages at the end of the proc, in correct sorted order. I'm not familiar
with all the nuances of using nested tables and have run into a couple of
snags.

This is what I have so far. The commented-out code in add_message() and
main_line() does not compile, but Toad is not giving me any useful
information as to why. Any suggestions would be appreciated.



CREATE OR REPLACE PACKAGE collections_test
AS
PROCEDURE main_line;
PROCEDURE init_message_tables;
END collections_test;


CREATE OR REPLACE PACKAGE BODY collections_test

IS

TYPE messages_table IS TABLE OF VARCHAR2 (100);
messages1 messages_table;
messages2 messages_table;

PROCEDURE init_message_tables
IS
BEGIN
messages1 := messages_table ();
messages2 := messages_table ();
END init_message_tables;


Procedure add_message (m_table messages_table, message varchar2)
IS
v_count number;
BEGIN
-- m_table.extend;
-- v_count:= m_table.COUNT;
-- m_table(v_count + 1) := message;
null;
END add_message;

PROCEDURE main_line
IS
-- CURSOR messages
-- IS
-- SELECT *
-- FROM TABLE (messages1);

BEGIN
init_message_tables();
add_message(messages1, 'blue');
add_message(messages2, 'green');
END main_line;

END collections_test;

 >> Stay informed about: selecting from oracle nested table 
Back to top
Login to vote
William Robertson

External


Since: Jun 08, 2007
Posts: 30



(Msg. 2) Posted: Fri Nov 02, 2007 3:57 am
Post subject: Re: selecting from oracle nested table [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Nov 2, 5:38 am, "Tim B" wrote:
> The task I have is to output some messages from a procedure in a package.
> The package is run in a shell script from plsql by piping the output from
> the proc to a file. There is a need to have 4 different types of messages in
> the report with some sorting. I want to output to one file only.
>
> A possible solution is to accumulate the messages in 4 collections - I'm
> starting with nested tables of varchar2- and then dbms_output.putline() the
> messages at the end of the proc, in correct sorted order. I'm not familiar
> with all the nuances of using nested tables and have run into a couple of
> snags.
>
> This is what I have so far. The commented-out code in add_message() and
> main_line() does not compile, but Toad is not giving me any useful
> information as to why. Any suggestions would be appreciated.
>
> CREATE OR REPLACE PACKAGE collections_test
> AS
> PROCEDURE main_line;
> PROCEDURE init_message_tables;
> END collections_test;
>
> CREATE OR REPLACE PACKAGE BODY collections_test
>
> IS
>
> TYPE messages_table IS TABLE OF VARCHAR2 (100);
> messages1 messages_table;
> messages2 messages_table;
>
> PROCEDURE init_message_tables
> IS
> BEGIN
> messages1 := messages_table ();
> messages2 := messages_table ();
> END init_message_tables;
>
> Procedure add_message (m_table messages_table, message varchar2)
> IS
> v_count number;
> BEGIN
> -- m_table.extend;
> -- v_count:= m_table.COUNT;
> -- m_table(v_count + 1) := message;
> null;
> END add_message;
>
> PROCEDURE main_line
> IS
> -- CURSOR messages
> -- IS
> -- SELECT *
> -- FROM TABLE (messages1);
>
> BEGIN
> init_message_tables();
> add_message(messages1, 'blue');
> add_message(messages2, 'green');
> END main_line;
>
> END collections_test;

So don't use TOAD Wink

Presumably the error is something like

PLS-00363: expression 'M_TABLE' cannot be used as an assignment target

because m_table is passed as an IN parameter, when it should be IN OUT
NOCOPY.

 >> Stay informed about: selecting from oracle nested table 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Oracle Spatial Selecting Overlaps returning no results (wh.. - Hello- I'm looking for advice on a problem I've hit with Oracle 10g spatial. I am storing a large number of rows with a feature_rectangle column defined for each entry(which is just a variable sized solid 2d rectangle). I have followed a table & in...

data type TABLE of Oracle - Hi, I'm writing a PL/SQL program to send emails. I copied a email packages from the web and it works fine. However, I have problem if I put the email ids as variable instead of hardcoded in the calling program. The package header is as follows: create...

Newbie: Generate XML for data from Oracle Table Rows - Hi, I am very new to Oracle. My customer has a requirement, where in I need to generate the XML scripts for the data that we are appending with in the table. eg: for the table col1 col2 col3..

8 Join Table... Access to Oracle... Think your good? Try a.. - OK, so I was given this very large query that is trying to create a very large grid table to hold all the necessary information. I really dont like it and suggested breaking it up, but the boss is the boss, and they want to keep it the same so..

Partitioning Nested Tables - Hi, Is it possible to partitioning nested tables? I mean, I have a large table with some columns as nested tables, the main table is partitioned, can I partition the nested tables too? Thanks Sérgio Carvalho
   Database Forums (Home) -> Oracle All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]