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 894269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:21:23+00:00 2026-05-15T14:21:23+00:00

I have a select query on a relational table in a plsql procedure. I

  • 0

I have a select query on a relational table in a plsql procedure.

I want to convert the results of this query into a user defined type object to return via odp.net.

How would I go about doing this?

  • 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-05-15T14:21:24+00:00Added an answer on May 15, 2026 at 2:21 pm

    (this is from one of my other post today)
    this is a walkthrough on getting started: http://www.oracle.com/technology/obe/hol08/dotnet/udt/udt_otn.htm

    while this is a bit more detailed: http://download.oracle.com/docs/html/E10927_01/featUDTs.htm

    but the real meat & potatoes are already installed on your computer after you install ODP in the Samples directory: %ORA_HOME%\product\11.1.0\client_1\odp.net\samples\2.x\UDT

    but the pl/sql side of things:

    First create the singleton udt to handle one row at a time

     CREATE TYPE TESTTYPE IS OBJECT(COLA VARCHAR2(50) , COLB NUMBER(10) );
     create or replace procedure GetTestType(lTestType OUT NOCOPY TESTTYPE)
     IS
      BEGIN
         SELECT TESTTYPE('ValA',123) 
           INTO LTESTTYPE
           FROM DUAL ;
      END GetTestType ;
    

    follow the directions in the above links to get the .net side insynch

    NOW FOR A COLLECTION:

    CREATE TYPE TESTTYPETABLE IS TABLE OF TESTTYPE ;
    
    CREATE OR REPLACE PROCEDURE GETTESTTYPETABLE(lTestTypeTable OUT NOCOPY TestTypeTable)
     IS
      BEGIN
         SELECT TESTTYPE(COLA,COLB)
                   bulk collect INTO lTestTypeTable
             FROM (
                 SELECT 'ValA' COLA ,123 COLB
                   FROM DUAL
                   UNION
                 SELECT 'ValB' COLA ,234 COLB
                   FROM DUAL
                   UNION
                 SELECT 'Valc' COLA ,456 COLB
                   FROM DUAL
             ) ;
    
    END GETTESTTYPETABLe;
    

    then in the .net side of things this will effectively be a value of TESTTYPE()

    Now to save you some time you can use the RETURNING clause on INSERT/UPDATE/DELETES
    as such

    create table testTable (colA varchar2(50) , colB number(10) );
    CREATE SEQUENCE TESTSEQ START WITH 1 NOCACHE;
    
    DECLARE
    lTestTypeTable TestTypeTable ; 
    BEGIN
        UPDATE TESTTABLE
          SET
          COLA = '1' ,
          COLB = 'a'
        WHERE COLA IS NULL
         RETURNING TESTTYPE(COLA,COLB)  --NOTE IF YOU HAVE ONE ROW YOU MAY DROP THE BULK COLLECT AND PUT IT INTO THE SINGLE ROW TYPE
         BULK COLLECT INTO
         lTestTypeTable
         ;
    END ; 
    /
    
    
    
    DECLARE
    lTestType TestType; 
    BEGIN
        INSERT INTO TESTTABLE(COLA, COLB)
        VALUES ('BBB' , testSeq.NEXTVAL )  
         RETURNING TESTTYPE(COLA,COLB)
         INTO
         lTestType
         ;
    
         DBMS_OUTPUT.PUT_LINE('MY NEW SEQUENCE # IS SET TO ' || lTestType.COLB) ;
    END ; 
    /
    

    unfortunately it seems that you cannot do a

    insert into TT ... SELECT * from .. RETURNING Type(x,y) BULK COLLECT INTO lVariable;
    

    so instead of rote COPING FROM THIS SITE, IT TELLS OF A “work-around” TO GET THE BULK COLLECT TO WORK IN AN INSERT STATEMENT
    http://www.oracle-developer.net/display.php?id=413

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 499k
  • Answers 499k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The variables you're creating in your panels aren't "saved" in… May 16, 2026 at 12:35 pm
  • Editorial Team
    Editorial Team added an answer Finally solved the issue, Solution: Previously i placed the pchart… May 16, 2026 at 12:35 pm
  • Editorial Team
    Editorial Team added an answer You can try handling the relevant ObjectDataSource event. In your… May 16, 2026 at 12:35 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have five tables: tab_template template_group group user_group user Tab_template's are organized into groups
I have some relational MySQL database with dozens of tables... My query is 1000
I have a select query which is used over and over with different where
Ok, so I have a query: select distinct(a) from mytable where b in (0,3)
I have a relation mysql database setup. and I want to pull all the
I'm trying to make a SELECT on three relational tables like these ones: table_materials
hi i tried a select query that contains an left outer join on SQL
My Query does not work when I have not set the ProcessorID in myComputer
I´d love to do something like this, but with a working syntax of course
I'm experiencing my first mysql INSERT tests and I'm using these tables: table employees

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.