Can we return a Array of varchar2 from a function ?

Hello,
i have a sql query that returns some rows. I want to define that query inside a function and want to retrieve the results in an array .Finally i want to retrieve those values in array in my .NET runtime . How can i achieve this ?

bootstrap wrote:
CREATE OR REPLACE function f_func(dept varchar2) return (what will be return type here ?)As Tubs said - ref cursor.
Any other choice is likely very wrong.
select statement...returning a resultset containing more than one rows..Cursors are not result sets. Cursors are not result sets. Repeat this over and over again.
A cursor is a program. The results from it is the output of the program. There is no so-called result set created in memory containing the output of that cursor.
The flaw in your approach is to fetch the output of this program, and storing it in very expensive server memory (called the PGA in Oracle) - for returning data as a primitive non-scalar data structure to the client.
Returning a ref cursor (aka a pointer to a cursor) means that you give the client direct access to the interface of that cursor program. Allowing the client to directly fetch and consume the output of that program. Enabling the client to deal with the standard SQL (cursor) interface.
A significantly more performant and scalable method than to create a primitive result set cache in server memory for the output and then shipping that (as a non-standard data structure) to a client.
A ref cursor interface can returns millions of rows and GBs of data. How many rows do you think this approach of yours will take? How many clients can call that same PL/SQL interface of yours at the same time, before the memory footprint of caching SQL data in the PGA for external clients exceeds free server memory?
Do you realise what happens next? Swap daemons trashing badly consuming most of the CPU (even starving the kernel itself). If you're lucky, the server will crash quickly. If not, even console access to the server in attempt to fix mess will be something like typing one character every 60 seconds at the console.

Similar Messages

  • Can i return an Array of Objects from c++ to java ??

    hello all,
    Can i return an Array of Objects from c++ to java ??
    If so how is it possible ??
    regards,
    gautam

    I suggest you look into the JNI, Java Native Interface. The answer is yes.

  • How can I return my iPhone4 to OS6 from OS7?

    How can I return my iPhone4 to OS6 from OS7?

    Several people on this discussion board have bought old phones that had not yet been updated and sold their updated phones.

  • How can servlet return data as download file from browser ? !!! URGENT !!!

    My servlet query data from database and would like to return the data as text file.
    How can I return data to the browser as user click a file to download ?
    How can I set the file name ? (default name is the servlet name that I don't want it to be)
    Which content type should I return to browser to prevent browser to display data immediately but save instead ?
    Thank you very much !

    I am having the same issue. Did you ever discover a way to change the "file name" in the browser. I've tried changing numerous HTTP header fields, to no avail.
    Marc

  • How to return more than one value from a  function

    hello everybody,
    Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
    2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
    Thanks.

    I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
    <code>
    class justArray {
    int x=0
    int y=0;
    int z= 0;
    ...somewhere
    justArray[] points= new justArray[4];
    points[0].x= ..
    points[0].y= ..
    points[0].z= ..
    points[1].x= ..
    return points[]
    </code>

  • Is it possible to return an array of objects from a web service?

    I have been trying to do this for a while now, and I have come to the conclusion that it may be impossible. To demonstate what I want to do I enclose a simple java file [1]. I have deployed this with Axis 2 and I enclose the responce [2], it is obciously not wat I want.
    Is it porrible to do this? If so, how?
    Thanks for any help,
    [1]
    package org.impress;
    public class SampleObject {
         public SampleElement[] noParameters(){
              SampleElement[] retArray = new SampleElement[2];
              retArray[0] = new SampleElement();
              retArray[0].name = "one";
              retArray[0].value = "alpha";
              retArray[1] = new SampleElement();
              retArray[1].name = "two";
              retArray[1].value = "beta";
              return retArray;
         public class SampleElement {
              public String name;
              public String value;
    }[2]
    <ns:noParametersResponse>
         <ns:return type="org.impress.SampleObject$SampleElement"/>
         <ns:return type="org.impress.SampleObject$SampleElement"/>
    </ns:noParametersResponse>

    Hi
    Can anybody help me with the code of how to return a resultset from a web service. i have put the resultset data's in an object array and tried to return it, but in the client side no data comes ,,, i mean it is printed as null.... and plz tell me where to specify the return type of a object in the wsdl file....
    thanks..

  • How can I return to Win 8.1 from Win 10

    I've updated to Windows 10 TP from win 8.1 few weeks ago, but I didn't backup anything. I find win 10 slow at startup. I want to return to windows 8.1, I've tried using Win 8.1 ISO file but Windows says "Windows
    8.1 setup has failed". Is there any another way to return to win 8.1 (or re-setup win 8.1 using ISO file)
           (I've tried using recovery but it just have "Uninstall Preview Updates" no "Recovery" in "Recovery and Maintaince your system" menu)

    Hi,
    As david suggested, if you want to go back to Windows 8.1, you need to reinstall it.
    This is documented in this article:
    Before you install Windows Technical Preview
    If you want to go back to your previous operating system      
          You'll need to reinstall your version of Windows from the recovery or installation media that came with your PC (typically DVD media). If you don't have recovery media:    
    For Windows 7 or Windows Vista: Before you update, you might be able to create recovery media from a recovery partition on your PC using software provided by your PC manufacturer. Check the support section of your PC manufacturer's
    website for more info.          
    For Windows 8.1 or Windows 8: You might be able to create a USB recovery drive. For more info, see
    Create a USB recovery drive. If you didn’t create a USB recovery drive before you installed the preview, you can
    create installation media for Windows 8.1.
    Best regards
    Michael Shao
    TechNet Community Support

  • Best way to return an array of values from c++?

    I have a a group of structs made of a mix of primitive types in c++. I need to return these to Java but Im not sure the best way to return them quickly.
    Should I create a class corresponding to the structure in Java then create the class in C++ and set its fields and return that? Or should I create arrays of different primitive types and return those? Can I even do that? Say, store a group of arrays of different types in a jobjectArray and return that? If I can, what would be the return type? Object[][]?

    Java side:
    package jni;
    import java.nio.ByteBuffer;
    import java.nio.ByteOrder;
    * @author Ian Schneider
    public class Struct {
        static {
            System.loadLibrary("struct");
        public static void doit() {
            ByteBuffer bytes = ByteBuffer.allocateDirect(structSize());
            bytes.order(ByteOrder.nativeOrder());
            getData(bytes);
            System.out.println("int : " + bytes.getInt());
            System.out.println("double : " + bytes.getDouble());
        private static native void getData(ByteBuffer bytes);
        private static native int structSize();
        public static void main(String[] args) throws Exception {
            doit();
    }C side (I'm not a C programmer, so be nice):
    #include "jni_Struct.h"
    struct foo {
      int x;
      double y;
    } foo;
    JNIEXPORT void JNICALL Java_jni_Struct_getData
      (JNIEnv * env, jobject obj, jobject buf) {
      struct foo * f = (void*) malloc(sizeof(foo));
      f->x = 123;
      f->y = 456.;
      void * data = (void *) (*env)->GetDirectBufferAddress(env,buf);
      memcpy(data,f,sizeof(foo));
      free(f);
    JNIEXPORT jint JNICALL Java_jni_Struct_structSize
      (JNIEnv * env, jobject obj) {
      return sizeof(foo);
    }This is a bit simplistic as foo is static in size (no pointers), but hopefully you get the point.

  • Can i return an iPod to apple from a third party seller

    I got an ipod from amazon. Found out it was from a third party seller and not amazon itself. I got it out and set it up. I recieved a case for it in the mail 2 days later and went to put it on. At that point I realized that it does not have a rear facing camera. I want to return it, but they won't take it back because I opened it. I didnt know it didnt have a rear facing camera. Anything I can do besides trying to sell it myself?

    Apple will not take it.
    Sell it.

  • Can't get an array of characters from a string!

    If I have a string eg "Hello World", how do I get an array containing the characters eg. [H,e,l,l,o, ,W,o,r,l,d]
    Can any one help me please?

    Or to get the chars you want from a String object you can do this:
    String helloString = new String("Hello World");
    char[] helloArray = helloString.toCharArray();

  • How can I return to previous firefx versions from version 4. Hate it.

    At 84, I'm too old a dog to start re-learning, the new 4 version is completely different, and I can't figure out how to configure menus, and etc. Please tell me how to go back to previous version 3.XXX

    http://support.mozilla.com/en-US/kb/Installing+a+previous+version+of+Firefox
    http://www.mozilla.com/en-US/firefox/all-older.html

  • Returning values to PL/SQL from OLAP function

    We've recently migrated our express application into Oracle 9i. We need to call a function and return the value back to a PL/SQL procedure. I thought that DBMS_AW.execute would work, but the documentation and the actual code seem to differ. The documentation leads me to believe that there are two parameters to the execute procedure, one being the DML command, and the other being the output from the DML command. When I attempt to compile, I get an error as the DB thinks that only one parameter should be specified. Has anyone written any pl/sql that returns the values of an OLAP function?
    thanks in advance!
    btw, we are on 9.2.0.4.1

    Thank you for pointing me at this package. I've now tried it, but am seeing some 'odd' behaviour. I am using the packages as such:
    lv_res := dbms_aw.eval_text('aw attach aw_ceis_imp;call f_comp_v');
    when I review the results in lv_res, it echos the command that I sent 'aw attach aw_ceis_imp;call f_comp_v'. Are there any docs that show examples of using the dbms_aw.eval_text functions?

  • Returning an array type from a local method in Web Dynpro Java application

    Hi,
    In my project, we have a requirement to display 18 rolling months along with the year, starting from current month.
    How I am going to approach is that I will get the system date and get the current month and send the month and year value to a local method which will return 18 rolling months along with the year.
    But, when I tried to create a new method there is no option to return an array type. It was greyed out.
    So, we can not return an array type from a method from Web Dynpro for Java application?
    If so, what is the alternative and how am I going to achieve it?
    I will appreciate your help!
    Regards
    Ram

    HI
    You can create new methods in
      //@@begin others
      private ArrayList MyMethod(){
           // ** Put your code here
           return new ArrayList();
      //@@end
    Other option are create a context node with cardinality 0...n with one or more attributes, and in your method create the needed registers into this node. To read this values, you only need to read your context node.
    Best regards
    Edited by: Xavier Aranda on Dec 2, 2010 9:41 AM

  • Return array of varchar from oracle to java

    Hi,
    I am trying to return an array of varchar from database to java. However, when I print the values in java, it prints hexadecimal values like this.
    0x656E7472792031
    0x656E7472792032
    0x656E7472792033
    0x656E7472792034
    I am using oracle 9.2.0.5.0 and jdk 1.4
    This happens only when the NLS character set of the database is WE8MSWIN1252 (default character set).
    It works fine on databases with UTF8 and US7ASCII character sets.
    Any leads to the reason behind this behaviour is greatly aprpeciated.
    Here's the code snippet...
    <code>
    //USER DEFINED TYPE
    create or replace type SimpleArray
     as table of varchar2(30)
    </code>
    <code>
    // FUNCTION RETURNING USER DEFINED TYPE
    create or replace function getSimpleArray return SimpleArray
     as
     l_data simpleArray := simpleArray();
     begin
      for i in 1 .. 10 loop
          l_data.extend;
          l_data(l_data.count) := 'entry ' || i;
        end loop;
        return l_data;
      end;
    </code>
    <code>
    // JAVA METHOD
    public static void main(String[] args)
         try {
              Class.forName("oracle.jdbc.driver.OracleDriver");
              String url = "jdbc:oracle:thin:@localhost:1521:db1252";
              Connection conn = DriverManager.getConnection(url, "ring", "ring");
              CallableStatement stmt = conn.prepareCall("{? = call "
                             + "getSimpleArray" + "}");
              Array rs = null;
              ResultSet rsltSet = null;
              stmt.registerOutParameter(1, Types.ARRAY, "SIMPLEARRAY");
              stmt.execute();
              rs = stmt.getArray(1);
              String[] values = (String[]) rs.getArray();
              System.out.println(rs.getBaseTypeName());
              System.out.println(values.length);
              for (int i = 0; i < values.length; i++) {
                   System.out.println(values);
              rsltSet = rs.getResultSet();
         } catch (Exception e) {
              System.err.println("Got an exception! ");
              System.err.println(e.getMessage());
    </code>
    Thanks,
    Vivek

    Actually, check nls_charset12.zip. It looks like 9.2.0.5 driver contains only the *.zip version. Make sure that the file exists in the directory pointed by the CLASSPATH. Use full path, do not use %ORACLE_HOME%.
    I have reproduced your problem without nls_charset12.zip and I could not reproduce it with the file in the class path. Double-check how classpath is set in your environment. Maybe it is overriden by some configuration or batch file.
    -- Sergiusz

  • External java function that should return String array

    Hi everyone,
    I have a split function in plsql that takes 10 times longer a java tokenizer function that i was written. So, i want to use java external function to split my plsql strings into pieces.
    I can write a java external procedure that returns types like int, float and String types. I have no problem about it.
    My problem is returning an array of strings. I found a book that has an example about how can we get directory list in plsql with java external procedure.
    (code)
    import java.io.File;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
    public class JFile {
    public static oracle.sql.ARRAY dirlist (String dir)
    throws java.sql.SQLException
    Connection conn = new OracleDriver().defaultConnection( );
    ArrayDescriptor arraydesc =
    ArrayDescriptor.createDescriptor ("DIRLIST_T", conn);
    File myDir = new File (dir);
    String[] filesList = myDir.list( );
    ARRAY dirArray = new ARRAY(arraydesc, conn, filesList);
    return dirArray;
    CREATE OR REPLACE FUNCTION dirlist (dir IN VARCHAR2)
    RETURN dirlist_t
    AS
    LANGUAGE JAVA
    NAME 'myFile.dirlist(java.lang.String) return oracle.sql.ARRARY';
    (code)
    I could compile this source file in localhost but not remotehost. There are jar files ( import oracle.sql.*; import oracle.jdbc.*; ) that should be added to remote classpath. ( others have already added java classpath ). But, which classpath i should add? Oracle has own JVM and Classpath, probably i should upload these jar files to oracle classpath. Am i wrong? How can i do? Can you explain in detail? How can i return string array from java external function in Oracle ?
    I am using Oracle 11.1.0.7 on Solaris Sparc Machine.

    Hi,
    What do you mean "compile in remote host"
    Aren't you using the loadjava tool? - that should be enough, the RDBMS already "has" the jars needed.
    [A must read|http://download.oracle.com/docs/cd/B28359_01/java.111/b31225/chone.htm#BABCFIIF]
    Regards
    Peter

Maybe you are looking for

  • BPC:NW - Best practices to load Transaction data from ECC to BW

    I have a very basic question for loading GL transaction data into BPC for variety of purposes, would be great if you can point me towards best practices/standard ways of making such interfaces. 1. For Planning When we are doing the planning for cost

  • Convert Danish PDF files cant show the Danish letters

    Hvordan indstiller jeg Adobe convert til at skrive de Danske bogstaver æ, ø og å når der konverteres til en Word fil?

  • Urdu support in Oracle Forms 9i

    Requirement: ============ We have an application in Oracle Forms & Report 9i Rel 2 and Database 9i Rel 2. There is a client requirement to provide Urdu support in this application. We have to enter Urdu data in few forms and print it in PDF reports.

  • How to retrive the records with in the range

    hi, I want to read the records from the table with in the date range. for example select empID,empName from EmpTable where stardat to lastdate please somebody help me... thanx in advance cinux

  • Check Box on the Crystal Reports

    Hi, I want to print Check Box from Boolean data. It shows True/False. How can I print check box instead of True/False? Thanks,