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

  • Home
  • SEARCH
  • 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 6806517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:43:14+00:00 2026-05-26T19:43:14+00:00

I currently have the following funciton in an oracle database that returns a concatenated

  • 0

I currently have the following funciton in an oracle database that returns a concatenated string seperated by pipes. It’s a legacy application that is being updated to use .net 3.5. The exiisting application concatenates the returned result set into a VARCHAR2 data type. What I want to do is return the entire result set back to my .net client. The MS SQL equivalent of what I’m trying to accomplish is a simple “SELECT * FROM TBL WHERE id = @id” I’m not use to some of the concepts Oracle uses. I’t seems like e blend of OOP and SQL querying. I’ve read multiple examples on this but can’t seem to find exactly what I’m looking for. Can you please help?

CREATE OR REPLACE FUNCTION DOCSADMIN.GET_DOCS (
    RECID IN NUMBER) -- RECORD ID
    RETURN VARCHAR2 -- CONCATENATED STRING WITH PIPES
IS
    RETVAL          VARCHAR2(5000) :='';
    DOCSTRING       VARCHAR2(5000) :='';    
    DOCNAME      VARCHAR2(5000) :='';
    DOCNUMBER    NUMBER;
    STATUS       VARCHAR2(5000) :='';
    DOCTYPE      VARCHAR2(5000) :='';
    EDITDATE     DATE :='';
/******************************************************************************
   NAME:       GET_DOCS
   PURPOSE:    Pulls associated docs from profile table
******************************************************************************/


   CURSOR GETDOCINFO IS SELECT DOCNUMBER, DOCNAME, CUSTOM_STATUS, DOCUMENTTYPES.DESCRIPTION, LAST_EDIT_TIME
        FROM PROFILE, DOCUMENTTYPES, FORMS WHERE NAD_APID = IN_APID AND PROFILE.FORM = FORMS.SYSTEM_ID AND 
        DOCUMENTTYPE = DOCUMENTTYPES.SYSTEM_ID AND FORM_NAME = 'DOCS_PROFILE' ORDER BY DOCNUMBER;

BEGIN

    OPEN GETDOCINFO;
        --GET THE FIRST RECORD
        FETCH GETDOCINFO INTO DOCNUMBER, DOCNAME, STATUS, DOCTYPE, EDITDATE;
        --LOOP THROUGH ALL ASSOCIATED DOCS AND GRAB INFO
        WHILE GETDOCINFO%FOUND LOOP

            BEGIN

                DOCSTRING := DOCNUMBER || '|~|' || DOCNAME || '|~|' || STATUS || '|~|' || DOCTYPE || '|~|' || WS_EDITDATE;

                RETVAL := RETVAL || DOCSTRING || '|^|';

                GOTO STARTOVER;

            END;

            <<STARTOVER>>

            FETCH GETDOCINFO INTO DOCNUMBER, DOCNAME, STATUS, DOCTYPE, EDITDATE;

        END LOOP;

   CLOSE GETDOCINFO;

   RETURN RETVAL;

   EXCEPTION
     WHEN NO_DATA_FOUND THEN
       NULL;
     WHEN OTHERS THEN
       -- Consider logging

 the error and then re-raise
       RAISE;
END GET_DOCS;
/
  • 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-26T19:43:15+00:00Added an answer on May 26, 2026 at 7:43 pm

    Well, you could convert the function in to a procedure and have an OUT parameter of the SYS_REFCURSOR type. With Oracle and .Net you can pass back a cursor and iterate through that as a reader.

    Sample Oracle procedure:

    CREATE OR REPLACE PROCEDURE TEST_SCHEMA.TEST_PROCEDURE (
      out_DATA OUT SYS_REFCURSOR;
    ) AS
    BEGIN
      OPEN out_DATA FOR
      SELECT col1,
             col2
        FROM TEST_SCHEMA.TEST_TABLE;
    END test_procedure;
    

    Sample .Net end:

    using (OracleConnection connection = new OracleConnection("connstring"))
    using (OracleCommand command = connection.CreateCommand()) {
      command.CommandType = CommandType.StoredProcedure;
      command.CommandText = "TEST_SCHEMA.TEST_PROCEDURE";
      command.Parameters.Add("out_DATA", OracleType.Cursor)
          .Direction = ParameterDirection.Output;
    
      connection.Open();
      command.ExecuteNonQuery();
      OracleDataReader reader = 
          command.Parameters["out_DATA"].Value as OracleDataReader;
    
      if (reader != null) {
        using (reader) {
          while(reader.Read()) {
            string col1 = reader["col1"] as string;
            string col2 = reader["col2"] as string;
          }
        }
      }
    }
    

    Be sure to close the cursor after you’re done using it (accomplished above by the using (reader) statement).

    So in your case, you could probably create a procedure that outputs the original cursor in your function, then just iterate over the cursor in .Net as listed above. Just a note, the column names from the Oracle side are important and will match what you’re using in .Net.

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

Sidebar

Related Questions

I currently have the following code in an NSOperation that has an observer for
I currently have the following script using CSS Sprites that toggles between active and
I have the following string in Oracle as one continuous line, where instead of
I currently have the following JavaScript/jQuery script that gets an external html page using
I have a webservice function that returns something like the following: New Orleans, Louisiana
I currently have the following code coming from a database table: <h1 class=widgetHeader>My Friends</h1>
I currently have the following js code function clearMulti(option) { var i; var select
I`m currently working on a script, and I have the following situation. function somnicefunction()
I have the following function that deletes the LaTeX command surrounding the current cursor
I currently have the following table definition: <table border=1 cellspacing=0 bordercolor=#CEDFEF cellpadding=1> I am

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.