Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8156649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:01:13+00:00 2026-06-06T17:01:13+00:00

I select data from several tables. Then i need to edit the data returned

  • 0

I select data from several tables. Then i need to edit the data returned from the cursor before returning. The cursor will then be passed to a perl script to display the rows.

To that i build a pl/sql table as in the following code. What i need to know is how to return the to that table ?

At present i get the error “table or view doesn’t exist”. Test code i use for a simple table is attached here.

CREATE OR REPLACE FUNCTION test_rep
RETURN SYS_REFCURSOR
AS

CURSOR rec_Cur IS 
    SELECT  table1.NAME, 
        table1.ID 
    FROM TESTREPORT table1;
TYPE rec_Table IS TABLE OF rec_Cur%ROWTYPE INDEX BY PLS_INTEGER;
working_Rec_Table rec_Table;    

TYPE n_trade_rec IS RECORD
(
    NAME    VARCHAR2(15), 
    ID      NUMBER
);
TYPE ga_novated_trades IS TABLE OF n_trade_rec index by VARCHAR2(15);
va_novated_trades    ga_novated_trades;
v_unique_key VARCHAR2(15);

TYPE db_cursor IS REF CURSOR;
db_cursor2 db_cursor; 

BEGIN

    OPEN rec_Cur;
    FETCH rec_Cur BULK COLLECT INTO working_Rec_Table;

    FOR I IN 1..working_Rec_Table.COUNT LOOP
        v_unique_key := working_Rec_Table(I).NAME;
        va_novated_trades(v_unique_key).NAME    := working_Rec_Table(I).NAME;
        va_novated_trades(v_unique_key).ID      := working_Rec_Table(I).ID;
     END LOOP; --FOR LOOP

     OPEN db_cursor2 FOR SELECT * FROM va_novated_trades; --ERROR LINE

     CLOSE rec_Cur;
     RETURN db_cursor2;

END test_rep;
/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:01:14+00:00Added an answer on June 6, 2026 at 5:01 pm

    Basically there is a way to select from a table type in oracle using the TABLE() function

    SELECT * FROM table(va_novated_trades);
    

    But this works only for schema table types and on plsql tables (table types defined in the SCHEMA and not in a plsql package):

    CREATE TYPE n_trade_rec AS OBJECT
    (
        NAME    VARCHAR2(15), 
        ID      NUMBER
    );
    CREATE TYPE ga_novated_trades AS TABLE OF n_trade_rec;
    

    But I still think you should try to do it all in a query (and/or in the perl script),

    For example, there is one field where i have to analyse the 4th
    character and then edit other fields accordingly

    This can be achieved in the query, could be something like:

    select case when substr(one_field, 4, 1) = 'A' then 'A.' || sec_field
                when substr(one_field, 4, 1) = 'B' then 'B.' || sec_field
                else sec_field 
           end as new_sec_field,
           case when substr(one_field, 4, 1) = 'A' then 100 * trd_field
                when substr(one_field, 4, 1) = 'B' then 1000 * trd_field
                else trd_field 
           end as new_trd_field,
           -- and so on
    from TESTREPORT
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to select data from 2 tables in my DB - comments and
I have some data SELECT [field names] FROM [several joined tables] WHERE [some criteria
I have a DataTable which I select from database (Well, these data cross several
I am trying to select data from two tables and insert it into another
I need to select data from one table and insert it into another table.
I am using SQL Server 2008 and I need to select all data from
I'm trying to create a windows form application that manipulates data from several tables
I've got an sql query that selects data from several tables, but I only
I try to select data from database table with many conditional clauses where my
I am using jdbc to select data from a mysql database. I am performing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.