Redirect the refcursor output of an SP to a table ?

hi.
i have an SP which returns a refcursor. now what i need is to get this output to a table so that i can manupulate the data.
this is how i executed the table
var a refcursor
exec packagename.spname(:a,'inputchar');
print :a;
please help.
i tried create table temp as select * from :a
and
create table temp as select * from table (cast a as a)
but both didnt work..
what am i missing here ????

novicedba wrote:
the SP is not mine. so i cannot alter it.So? That does not make something less wrong.
suppose the refursor returns itemcode, purchase_time, price. and details of 100+ items are returning in thi refcursor. what i need is first to get the results. and then filter it only to view detaild of one item. Why? That cursor does work (in the SQL engine) to find the relevant rows (using indexes and/or tables reading data blocks). It does +"x"+ amount of work to output the results for that SQL select statement.
Now you want to filter, in PL/SQL or another client language, the output of that cursor. That filtering should be done by the SQL engine - as it is best suited for doing that work. And the workload of +"x"+ that was needed, can now be +"x/2"+ as a result - as the filtering and elimination of columns not needed from the SQL projection can significantly decrease the workload and increase performance.
So what benefits are there to filter the output of a cursor? NONE! There are no benefits. Not a single one.
this is why i need to get the Output into a table.The cursor returns data from the SQL engine. This data needs to be pushed from the SGA db buffer cache all the way to the client language. In the case of PL/SQL, into the private heap space of the process (called the PGA).
Then you take that very same data, create an insert SQL cursor, and send that data back to the SQL engine to be inserted.
So what benefits are there pushing and pulling SQL data like this across memory and process and even platform boundaries, when the both the read data and write data processes could have been done as a SQL "+insert .. select+" cursor? NONE! There are no benefits. Not a single one.
(no wonder this sounds like TSQL coz i am more familiar to TSQL than PL ;) (irrelevant stuff) )Treating PL/SQL like TSQL 'cause your are "familiar" with TSQL is, bluntly put, idiotic. PL/SQL is not TSQL. Oracle is not MS-SQL Server.
if i am going for a cast.. what should i do ?I would go instead for the manuals.. and educate myself on the concepts and fundamentals of the product and languages I'm using. And design and write robust and performant and flexible and scalable code.

Similar Messages

  • Can you redirect the audio output of iTunes via Apple TV?

    I currently have iTunes running on Windows XP with an Airport Express connected to my home stereo. I toggle the iTunes audio between my PC and the Airport Express via the iTunes speaker setting. With Apple TV, will I be able to toggle the audio output from the Apple TV interface?
    Thanks,
    Chaaad

    No, you can use AppleTV like an Express to have audio playing in iTunes relayed to it, but you can't play something on AppleTV and direct the output to the Express.
    AC

  • Redirect the class output.

    Hi!
    I am new to java.
    I have a class file that print to output a result from three parameters I pass to it, this class are byte code compiled and I am not have the source code.
    I want to know how to redirect this output to an variable into my program.
    thank in advance.
    Paulo

    It's possible, although slightly involved. If you look at the System class, you'll see a method [url http://java.sun.com/j2se/1.4/docs/api/java/lang/System.html#setOut(java.io.PrintStream)]setOut. This allows you to set the stream to which the other class is writing its output. So what to set it to? Well, you presumably want to get the output as a String, so I suggest the following: import java.io.*
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    System.setOut(new PrintStream(out));
    // Call other class here.
    String output = out.toString();

  • Redirecting the servlet output to jsp

    Hi i need to redirect my servlet out put to jsp
    in result set's every row i have 9 columns
    this result set how can i redirct to jsp
    plz can any one let me know with an example
    thanks a lot in advance

    inamdar wrote:
    Hi i have never used DTO's and DAO classes
    plz colud u let me know without using that..Huh? It is never too late to start with it. Just create two simple classes. A DTO class is basically a simple javabean with private (encapsulated) properties and a public getter and setter for each property. A DAO class is basically a class which contains purely JDBC code.
    Sample DTO:public class MyData {
        private Long id;
        private String name;
        private Integer value;
        public Long getId() { return id; }
        public String getName() { return name; }
        public Integer getValue() { return value; }
        public void setId(Long id) { this.id = id; }
        public void setName(String name) { this.name = name; }
        public void setValue(Integer value) { this.value = value; }
    }Sample DAO:public class MyDataDAO {
        public List<MyData> listAll() {
            String listAllQuery = "SELECT id, name, value FROM data";
            List<MyData> myDataList = new ArrayList<MyData>();
            Connection connection = null;
            Statement statement = null;
            ResultSet resultSet = null;
            try {
                connection = getConnectionSomehow(); // DriverManager or Connection Pool, your choice.
                statement = connection.createStatement();
                resultSet = statement.executeQuery(listAllQuery);
                while(resultSet.next()) {
                    MyData myData = new MyData();
                    myData.setId(new Long(resultSet.getLong("id")));
                    myData.setName(resultSet.getString("name"));
                    myData.setValue(new Integer(resultSet.getInt("value")));
                    myDataList.add(myData);
            } catch (SQLException e) {
                // Handle it. Print it, throw it, log it, mail it, your choice.
                e.printStackTrace();
            } finally {
                // You can write an utility class/method for those lines as well.
                if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { e.printStackTrace(); } }
                if (statement != null) { try { statement.close(); } catch (SQLException e) { e.printStackTrace(); } }
                if (connection != null) { try { connection.close(); } catch (SQLException e) { e.printStackTrace(); } }
            return myDataList;
    }Sample Servlet code:List<MyData> myDataList = new MyDataDAO().listAll();
    request.setAttribute("myDataList", myDataList);
    request.getRequestDispatcher("someJspFile.jsp").forward(request, response);Sample JSTL code in someJspFile.jsp:<table>
        <c:forEach items="${myDataList}" var="myData">
            <tr>
                <td>${myData.id}</td>
                <td>${myData.name}</td>
                <td>${myData.value}</td>
            </tr>
        </c:forEach>
    </table>Simple and clean, isn't it?

  • Refcursor output in sqldeveloper

    Hi,
    Can you pls let me know how to view the refcursor output using sqldeveloper?
    Regards,

    Sure.
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.16
    satyaki>
    satyaki>
    satyaki>create or replace procedure gen_cur(str in varchar2,rc in out sys_refcursor)
      2  is  
      3    str1  varchar2(500);
      4  begin  
      5    str1 := 'select empno,ename,hiredate,sal           
      6             from emp           
      7             where '||str;              
      8            
      9    open rc for str1;  
    10  exception  
    11    when others then    
    12      dbms_output.put_line(sqlerrm);
    13  end;
    14  /
    Procedure created.
    Elapsed: 00:00:10.03
    satyaki>
    satyaki>declare
      2   type a is record
      3    (                   
      4      empno    number(4),                   
      5      ename    varchar2(30),                   
      6      hiredate date,                   
      7      sal      number(10,2)                 
      8    ); 
      9   rec a;   
    10   b sys_refcursor; 
    11   src varchar2(300);
    12  begin  
    13    src:= 'sal between 2000 and 7000';
    14    gen_cur(src,b);  
    15    loop    
    16      fetch b into rec;     
    17      exit when b%notfound;           
    18      dbms_output.put_line('Employee No:'||rec.empno||' - '||                          
    19                           'Name:'||rec.ename||' - '||                          
    20                           'Hire Date:'||rec.hiredate||' - '||                          
    21                           'Salary:'||rec.sal);  
    22    end loop;  
    23    close b;
    24  exception  
    25    when others then    
    26      dbms_output.put_line(sqlerrm);
    27  end;
    28  /
    Employee No:7566 - Name:JONES - Hire Date:02-APR-81 - Salary:2975
    Employee No:7698 - Name:BLAKE - Hire Date:01-MAY-81 - Salary:2850
    Employee No:7782 - Name:CLARK - Hire Date:09-JUN-81 - Salary:4450
    Employee No:7788 - Name:SCOTT - Hire Date:19-APR-87 - Salary:3000
    Employee No:7839 - Name:KING - Hire Date:17-NOV-81 - Salary:7000
    Employee No:7902 - Name:FORD - Hire Date:03-DEC-81 - Salary:3000
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.61
    satyaki>Regards.
    Satyaki De.

  • Problem in displaying data in the smartform output.

    Dear Freinds,
                    I have a requirement as per my requirement i have to display the employee dependents details in the smartform output.
    I have taken a table in smartform and collected all teh employee dependents details . Each dependents his own  details around 8 fields. so iam displaying in the smartform it is working till now no problem ........iam getting data as below
    Dependentrelation | dependentname|passportno|expirydate|visano|visadate|visa expire date| ResidenceNo|Residence issuedate|
    spouse                 | Raja                   |123456       |10/09/2009|122233|10/01/2009|10/01/2010 | 1001             |10/01/2009
    These are the one of the dependentds details iam having till now , like this i have another dependts details. Now the problem i have
    to add some fields to this list ( to this internal table) ...........if iam adding one more feild data is getting truncated as i dont have any more fields to add to right in the horizontal line........how can i solve this issue and how can i add further fields to this list
    like date of birth of the dependents and gender
    please could any one tell how i can solve this issue.
    regards
    divya.

    If this is a Tablethen only thing you can do is re-size the grid and font size to adjust your data. Like, displaying HEADINGS & DATAs in 2 rows instead of 1, etc.
    Nothing else can be done. Otherwise you have to trim down the data to adjust in one page.

  • Connecting the Sequence Operator to the Mapping Output Parameter?

    my OWB Client: 10.2.0.2.8
    my OWB Repository: 10.2.0.2.0
    I need to obtain a sequence number (from the Sequence Operator), then output it
    using the Mapping Output Parameter, if possible.
    I have tried two things:
    1. Connect Sequence Operator nextval variable to the Mapping Output Parameter.
    This generates error:
    "Table,View Or Sequence reference 'xx_SEQ.NEXTVAL' not allowed in this
    context"
    2. Join the Sequence Operator nextval variable with a source table, then
    connect a port from the dataflow to Mapping Output Parameter.
    This generates error:
    "Mapping Input Parameter and Mapping Output Parameter are intended to be
    executed before and after the data flow of the mapping and cannot accept
    inputs from any part of the data flow."
    From what I have seen so far, it appears it may not be possible to use the
    Sequence Operator along with the Mapping Output Parameter. If Im wrong, please
    let me know of an example of how the Sequence Operator and Mapping Output
    Parameter can be connected.
    Thanks

    User -
    Look at adding a Post-Mapping Process to your mapping, there you have a choice of built in functions or custom ones that could return a sequence value for you. You may have to create the sequence outside of OWB ...
    TXB

  • How to achieve the below output

    Hi All,
        I have a source table, and i need to generate the below output using Data Services.
    Source Table:
    Legacy_number
    Legacy_name
    Address
    z_inscope
    z_sold_to
    z_ship_to
    z_invoice_to
    123
    sam
    123 main st
    Y
    y
    N
    N
    345
    PAUL
    234 oxford st
    y
    y
    N
    N
    345
    PAUL
    234 oxford st
    y
    n
    n
    y
    456
    alex
    34 e ave
    y
    y
    n
    n
    456
    alex
    34 e ave
    y
    n
    y
    n
    456
    alex
    34 e ave
    y
    n
    n
    y
    Output Table:
    Legacy_number
    Legacy_name
    Address
    z_inscope
    z_sold_to
    z_ship_to
    z_invoice_to
    123
    sam
    123 main st
    Y
    y
    N
    N
    345
    PAUL
    234 oxford st
    y
    y
    N
    y
    456
    alex
    34 e ave
    y
    y
    y
    y
    We nee to generate a table which need to have only single Legacy_number in output table and z_inscope, z_sold_to, z_ship_to,z_invoice_to have to check their values in source table and replaced their columns with the following priority order Y,y,N,n in Output table.
    for explanation  see below example.
    1. for 345 Legacy number we have y & n for z_sold_to column. In output table that column need to be replaced with y as y priority is higher than n.
    2. for 456 Legacy number we have n & y & n for z_ship_to column. In output table that column need to be replaced with y as y priority is higher than n.
    Thanks in advance.

    Hello
    This is possible using lots of various techniques.  You allude to a technique in your question - priority.
    For each z column (I hate adding a z - is this from ECC?!), add a new column via a query and assign a priority to each value.  In a second query get the max priority for each column for the key (this will return only 1 row per key), then convert the priority back to the actual value.
    Michael

  • Redirect the output of SQL*Plus to the file

    Hi all,
    I have the following command to run:
    sqlplus username/password @myfile.sql
    I don't know how to redirect the output to the file.
    Also in the script myfile.sql I have the defined variable, &VP and
    How can I substitute this variable(&VP) at the run time.
    Thanks,
    JP

    Assumed you like to replace your defined variable VP by number 4. SInce it is posintional parameter,instead of wrinting &VP, write
    VP:=&1
    sqlplus>spool redirect.txt
    sqlplus>@myfile.sql 4
    sqlplus>spool off

  • IS IT POSSIBLE TO REDIRECT THE OUTPUT TO ANOTHER PAGE?

    Hi all,
    Is it possible to redirect the output when I excute my query in iSQL*plus to another predifined html page?
    If yes how do I do this?
    Thanks a mill

    You could do this..just read on..
    It would generate a html page for you...and..so on..!
    In addition to plain text output, the SQL*Plus command-line interface enables you to generate either a complete web page, or HTML output which can be embedded in a web page. You can use SQLPLUS -MARKUP "HTML ON" or SET MARKUP HTML ON SPOOL ON to produce complete HTML pages automatically encapsulated with <HTML> and <BODY> tags.
    By default, data retrieved with MARKUP HTML ON is output in HTML, though you can optionally direct output to the HTML <PRE> tag so that it displays in a web browser exactly as it appears in SQL*Plus. See the SQLPLUS MARKUP Options and the SET MARKUP command for more information about these commands.
    SQLPLUS -MARKUP "HTML ON" is useful when embedding SQL*Plus in program scripts. On starting, it outputs the HTML and BODY tags before executing any commands. All subsequent output is in HTML until SQL*Plus terminates.
    The -SILENT and -RESTRICT command-line options may be effectively used with -MARKUP to suppress the display of SQL*Plus prompt and banner information, and to restrict the use of some commands.
    SET MARKUP HTML ON SPOOL ON generates an HTML page for each subsequently spooled file. The HTML tags in a spool file are closed when SPOOL OFF is executed or SQL*Plus exits.
    You can use SET MARKUP HTML ON SPOOL OFF to generate HTML output suitable for embedding in an existing web page. HTML output generated this way has no <HTML> or <BODY> tags.

  • Can't redirect the Runtime exec output

    I'm trying to get mysqldump to give me some output which I can redirect to the tmp1 location
                   String tmp2 = "mysqldump";
                   Runtime rt1 = Runtime.getRuntime();
                   if(File.separatorChar == '\\') {
                        tmp2 = "\"C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqldump\"";
                   tmp1 = tmp2 + " > " + tmp1;
                   rt1.exec(tmp1);All I want to see at this point is just the error message telling me how to use mysqldump.
    After that I'll do something useful.
    I'm running under NetBeans and if I don't try to redirect I get nothing in the output window.
    Of course, if I run it from a Command box, I see the expected output.
    I know I'm running the program because if I change it to the nonsense mysqldump3, it will tell me that it can't find the file.
    I can't figure out where the output is going and how to capture it.
    Any ideas would be appreciated.
    Ilan

    Ilan wrote:
    Hi Sabre,
    Since I didn't understand your code, I'll use it as a chance to learn something.
    I don't understand what cmd.exe is doing. It is just opening a DOS box?No! It is interpreting the command string.
    Why do you need that? (Maybe I do and I don't know so....)You need to learn a good bit more about your operating system. Get a good book on Windows.
    >
    The simplest thing would be String command = "mysqldump > file.sql".
    Why shouldn't that work?1) Because the directory containing your mysqldump is not in the PATH.
    2) Because the redirection operator '>' is only applicable when interpreted by the command processor (cmd.exe). Reads your Windows manual.
    >
    The reason I need the explicit path is because mysqldump isn't on my Windows path (Linux is nicer that it is in usr/bin, so there is no problem.)
    So I detect Windows and for Windows put the path and command in quotes.
    (Now that I think about it, cmd.exe probably wouldn't work in Linux anyway.)On Linux you will need your shell to interpret the redirection operator '>' .
    >
    What is that "/C" all about? Go to drive c:?
    Your first attempt looks like a confusion with mysqldump, once without a path followed by a path.
    That one I don't understand at all.
    How do I go about getting control of the stderr, if I don't already have control?
    BTW, I haven't yet tried it in Linux. First I'll get the Windows version going.
    Thanks for your reply. I'll try to learn from it.You need to read, read again, study and then implement the recommendations in http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html .
    Sorry if this sounds like I'm passing the buck but your lack of knowledge of Windows, Linux and Runtime.exec() means I cannot help without writing a large tutorial.

  • How to redirect the tomcat (5.0) console output to a text file

    Hello,
    I am looking for a way of redirecting the tomcat console output [the System.out.println("xyzabc")�s from the java classes running on the container] to a text file.
    The reason is that the programmers need to have that console�s output and the server (windows) have to be rebooted often (no wonder: windows) and then Tomcat start as a service -> console is not visible.
    Thanks!

    The console out put should still be in the log files if tomcat is running as a windows service. It will either be in logs\stdout_xxxx.log and logs\stderr_xxxx.log or in logs\catalina.xxxx.log.
    If you are using 5.5.
    It will either be in logs\stdout.log and logs\stderr.log or in logs\catalina.out.
    if you are using 5.0

  • Redirecting the output

    Hi Satya, Thanks for helping me out couple of times earlier. I am having one more problem.
    I am able to get the runtime values of the server, but while I am unable to redirect the output to a dat file in the local box, from which I am extracting the results. I tried to use redirect(), but not able to make it work. I need help with the right command and any suggestions, that I can use to output the results to a dat file.
    Thanks again.

    Not sure I understand what you are trying to achieve. When you use redirect('./foo.dat') wlst will write the output that comes out of WLST to foo.dat. You should be able to read this file and get the outout and parse it.
    I am not sure what you are trying to do, can you post any errors you are seeing?
    -satya
    BEA Blog: http://dev2dev.bea.com/blog/sghattu/

  • Junk Characters in Report Output(While redirecting the output to text file)

    While generating the report (Reports 9i) output to a text file, I get the report output that contains junk characters. The other output formats viz. pdf, rtf have no problem.
    Please share how to correct it.
    Thanks.

    Yes, the MODE is set to Character and DESFORMAT is set to DFLT.
    Still the problem exists.
    Any idea please?

  • Redirecting the output of java compilation to a text file

    i tried to redirect the result of the java compilation to the text file using
    javac zz.java > compile.txt
    It works if the program has no errors and it did not work if it have errors. Wat is the reason it did not work for wrong programs.

    This has nothing to do with Java. It's your command shell.
    If you're on linux, then it's because the errors go to stderr and you're only redirecting stdout. I assume Windows is similar, but I don't know much about that.
    For bourne shell family on linux (sh, ksh, bash, zsh), you'd do
    javac zz.java > compile.txt 2>&1I'm not sure what the syntax is for csh family.

Maybe you are looking for