Output SYS_REFCURSOR when cursor structure is not known

If i have a variable of type "SYS_REFCURSOR".
This cursor will be passed to various procedures which open various recordset for that cursor, with various number of columns in cursor.
How to output cursor all columns?
1. Maybe java will have metadata information for cursor and can output the resultset of cursor. If so, then this is ok to choose this solution. also VbScript is ok, if it can help.
2. Maybe one can create table temporarily based on the cursor. And table objects have meta data in oracle system tables, so i can output all cursor data.
3. Maybe i can use so called try-catch clauses techique to help somehow. For example
Try
  fetch cur1 into varchar2_var1, .., varchar2_var5
catch (if error)
      try
          fetch cur1 into varchar2_var1, .., varchar2_var4
Till we know how many fields there are.
somehow this way to go next4. Maybe execute immediate can help somehow.

If you're not in 11g and you at least have some options of structures you want to try and fetch to, you can make use of the rowtype_mismatch exception by catching it and trying to fetch into a different structure until you find it, by nesting PL/SQL begin...exception...end; blocks.
You won't lose rows if you attempt to fetch into the wrong structure.
In the example below I try to fetch into a type with 2 columns and it fails then I attempt again against a 3-column type.
Note that the column type mismatch on implicit conversions will throw other exceptions as ORA-06504 or ORA-01722 for example.
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
Connected as fsitja
SQL> set serveroutput on
SQL>
SQL> DECLARE
  2    cur SYS_REFCURSOR;
  3    TYPE t_rec1 IS RECORD(
  4      col1 NUMBER,
  5      col2 VARCHAR2(100));
  6    v_rec1 t_rec1;
  7    TYPE t_rec2 IS RECORD(
  8      col3 NUMBER,
  9      col4 VARCHAR2(100),
10      col5 VARCHAR2(100));
11    v_rec2 t_rec2;
12  BEGIN
13    OPEN cur FOR
14      SELECT 1 col3, 'a' col4, 'b' col5 FROM dual;
15    FETCH cur
16      INTO v_rec1;
17    dbms_output.put_line('REC1.COL1: ' || v_rec1.col1);
18    dbms_output.put_line('REC1.COL2: ' || v_rec1.col2);
19  EXCEPTION
20    WHEN rowtype_mismatch THEN
21      FETCH cur
22        INTO v_rec2;
23      dbms_output.put_line('REC2.COL3: ' || v_rec2.col3);
24      dbms_output.put_line('REC2.COL4: ' || v_rec2.col4);
25      dbms_output.put_line('REC2.COL5: ' || v_rec2.col5);
26  END;
27  /
REC2.COL3: 1
REC2.COL4: a
REC2.COL5: b
PL/SQL procedure successfully completed
SQL>

Similar Messages

  • Creating DOMDocument when column names are not known

    I want to make a DOMDocument from a table of which I do not know the column names.
    I already got pretty far: I could generate XML elements having the name of each of the columns.
    I still have a problem when trying to retrieve the cell values from the table.
    The code is below.
    The problem I have is situated after the line:
    /* QUESTION : HOW DO I REPLACE get_rows.label BY something dynamic, i.e. I want to use the value o col_name as the column name */
    I do not know how to retrieve the value from the table but by hardcoding the column name (i.e. get_rows.label where label is a column name). What I want to use is the VALUE of the variable col_name as the column name.
    Many thanks in advance.
    The code:
    set serveroutput on
    DECLARE
    doc xmldom.DOMDocument;
    main_node xmldom.DOMNode;
    root_node xmldom.DOMNode;
    row_node xmldom.DOMNode;
    user_node xmldom.DOMNode;
    item_node xmldom.DOMNode;
    root_elmt xmldom.DOMElement;
    row_elmt xmldom.DOMElement;
    item_elmt xmldom.DOMElement;
    item_text xmldom.DOMText;
    CURSOR DF_ROWS IS SELECT * FROM DF_COUNTRY;
    /* get the column names */
    CURSOR DF_COLUMNS IS SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'DF_COUNTRY';
    col_name varchar(20);
    cell_value varchar(40);
    BEGIN
    /* OPEN DF_COLUMNS; */
    /* create a DOM document and append a root element */
    doc := xmldom.newDOMDocument;
    main_node := xmldom.makeNode(doc);
    root_elmt := xmldom.createElement(doc, 'ROOT');
    root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
    /* loop over the records */
    FOR get_rows IN DF_ROWS LOOP
    row_elmt := xmldom.createElement(doc, 'ROW');
    /* xmldom.setAttribute(item_elmt, 'num', get_users_rec.rownum); */
    row_node := xmldom.appendChild(root_node, xmldom.makeNode(row_elmt));
    /* Now loop over all the columns (cells) and create an element for each of them */
    FOR get_columns IN DF_COLUMNS LOOP
    col_name := get_columns.COLUMN_NAME;
    DBMS_OUTPUT.PUT_LINE(col_name);
    item_elmt := xmldom.createElement(doc, get_columns.COLUMN_NAME);
    item_node := xmldom.appendChild(row_node, xmldom.makeNode(item_elmt));
    /* QUESTION : HOW DO I REPLACE get_rows.label BY something dynamic, i.e. I want to use the value o col_name as the column name */
    item_text := xmldom.createTextNode(doc, get_rows.label);
    item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
    END LOOP;
    END LOOP;
    xmldom.writeToFile(doc, 'C:\ClinCapt\Output\test.xml');
    xmldom.freeDocument(doc);
    END;

    I needed to manipulate the XML afterwoods (i.e. combine it with queries to other tables in a single large XML document).Did you try to combine all these subsequent queries into one single query and pass it to the XML packages to generate the XML all at once (instead of doing it in stages).
    SQL> select dbms_xmlquery.getxml('select dname,
      2                              cursor(select empno, ename
      3                                     from scott.emp
      4                                     where rownum < 3) employees
      5                              from scott.dept where rownum < 3') from dual ;
    DBMS_XMLQUERY.GETXML('SELECTDNAME,CURSOR(SELECTEMPNO,ENAMEFROMSCOTT.EMPWHEREROWN
    <?xml version = '1.0'?>
    <ROWSET>
       <ROW num="1">
          <DNAME>ACCOUNTING</DNAME>
          <EMPLOYEES>
             <EMPLOYEES_ROW num="1">
                <EMPNO>7369</EMPNO>
                <ENAME>SMITH</ENAME>
             </EMPLOYEES_ROW>
             <EMPLOYEES_ROW num="2">
                <EMPNO>7499</EMPNO>
                <ENAME>ALLEN</ENAME>
             </EMPLOYEES_ROW>
          </EMPLOYEES>
       </ROW>
       <ROW num="2">
          <DNAME>RESEARCH</DNAME>
          <EMPLOYEES>
             <EMPLOYEES_ROW num="1">
                <EMPNO>7369</EMPNO>
                <ENAME>SMITH</ENAME>
             </EMPLOYEES_ROW>
             <EMPLOYEES_ROW num="2">
                <EMPNO>7499</EMPNO>
                <ENAME>ALLEN</ENAME>
             </EMPLOYEES_ROW>
          </EMPLOYEES>
       </ROW>
    </ROWSET>
    SQL>                                                      

  • BPM_DATA_COLLECTION fails with (Output device "" not known) error

    Hi all,
    I have an issue with Output BPM_DATA_COLLECTION_1 job in the satellite system  failing with 'Output device "" not known error.  Since it is collecting data for Solution Manager system why does is it trying to find an output device.
    It did not fail before and now I added another key figure (custom one) which is done the same way the other custom monitors are done in "Z_BPM_ECU_COLLECTOR" report and then in /SSA/EXM program, but the collector job started to fail.
    Also, for some reason there are two BPM_DATA_COLLECTION jobs, one is BPM_DATA_COLLECTION_1 and the other is BPM_DATA_COLLECTION_2.  _1 runs every 5 min and _2 is less frequent. They both seem to runt the same job which is /SSA/EXS. Why are there two jobs scheduled from solution manager in my satellite system?
    Thank you very much for your help!

    I am experiencing this same issue in our ECC 6.0 system.  We currently have ST-A/PI release 01M_ECC600 level 0001 applied to our system.  These jobs finish successfully in SM37, but I'm seeing the same error messages in our system logs (SM21).
    When I try to update the output device that is associated with these jobs, the user ID running the jobs is not valid since it's user type is Communication Data.
    Does anyone know if it ok to change the user for this job? Should it be run by DDIC?  I believe the jobs were created automatically when we applied ST-A/PI release 01M_ECC600 level 0001.

  • Should not create any output file when transform with xslt file

    I have a xslt file, which I have make code to check the order status value.
    If OrderStatus != 'Reject' --> create attribute, element for output file
    Else OrderStatus = 'Reject' --> do not create attribute/element ==> output is the empty file.
    Requirement: if OrderStatus = 'Reject' --> do not create any output file.
    how to do with this requirement?
    any help will be appreciated!

    Do you mean the xslt file always return the output file?
    I have tested this xslt file following (only xslt file, not run in BizTalk project):
    Create a blank console application using visual studio and add attached xslt file to newly created console app. Next open the XSLT file and select input file and output files and start xslt debugging to create output file.
    I want to edit the xslt file how to cannot create output file in the case OrderStatus = Reject.
    I don't say in particualr xslt file, its actually your map as a whole that returns a output message on successful execution.
    since you are testing the xslt file as individual file, you are able to control it as per need.  i mean you can write incomplete code or any kind of output elements that are not present even in schema. But when you set the map properties to use external
    xslt , map completely relies on xslt and xslt has to produce output that matches the output schema structure.
    So you better test your xslt by  setting it to your map. Once you set map properties to use xslt, you can test your map by right clicking on map and choosing test map.
    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Output device "" not known

    Hi Expert,
    I try to execute SWU3 for automatic customizing workflow on ECC 6.0.
    I have got error Output device "" not known and no background job is executing in my system .
    This error I am getting for this activities
    Schedule Background Job for Missed Deadlines
    Schedule Background Job for Work Items with Errors
    Schedule Background Job for Condition Evaluation
    Schedule Background Job for Deadline Monitoring
    I search in other topic, it mention that basis guy do something bot not clear how to solve it.
    Please help me.
    Thanks in advance.

    Hi Karri,
    Thanks for the reply.
    Yes I do have authorization for execute SWU3. My user ID have same authorization as sap*.
    WF-Batch User Exist, RFC for workflow localXXX also set.
    From thread : Error activating  SWU3 -   output device "" unknown
    I see this issue solve by basis, they adding some parameters to start and instance profile.
    But I have no idea which parameters.

  • Some of the options not enabled when cursor is placed on it.Eg:Ask a question in this screen Only in full screen mode it is enabled

    On a normal screen some of the functions are not enabled when cursor is placed on it.For example,in rediffmail the folders,settings, sign out, functions are not enabled in normal screen when cursor is placed on it.On full screen mode these are enabled.

    Have you got anything like addblockers or script blockers installed which may cause this problem ?
    Ensure you have javascript enabled
    * when you post in this forum do you see the formatting icons above where you type your message: ['''B'''] & [''i''] (The icons will not be seen with javascript disabled, or totally blocked)
    * use '''Firefox Button -> Options -> | Content | -> [] Enable javascript ''' (check / tick the box)
    * You appear to be '''using XP''' and menus may differ, by default it will start '''Tools -> Options''' instead of Firefox button

  • "This field name is not known" error when upgrading from VS 2003 to VS 2005

    When we upgraded our web servers from VS 2003 to 2005, our crystal reports web viewer began having a problem with reports that contained sub-reports.  We now are getting the following error on the web page.  The reports were developed in Crystal 10, but I upgraded them to Crystal 11 but still recieved the same error.
    Any help would be greatly appreciated.
    thank you
    This field name is not known. Error in File C:\DOCUME1\DMDEVB1\ASPNET\LOCALS~1\Temp\CategorybyStateProductDist {B0FCB37B-A7DB-4786-AD69-55568EC94923}.rpt: Error in formula . '{usp_wd_RptCategoryByStateProductDist;1.State} = {?@State} ' This field name is not known.

    HI Karl,
    Also Try to update the database connection for the report.
    You can do that by opening report in designer, then
    Go To Database Menu -> Setdatasource Location
    Connect to the datasource you want and update the datasource.
    Save the report.
    Hope this Helps !!!
    Prasad

  • Centre Cursor/Trackball does not open any folder when pressed

    I have a Blackberry Curve. I think it's a 8520 but can't find out the actual model number as the centre cursor/trackball will not let me enter any folder when pressed.  It will navigate but does not work or "enter" when pressed to open a file e.g. Cannot open text messages, Cannot mange connections, Cannot access Setup etc. etc. etc  Tried re-booting several times.  Phone goes through the usual set-up and verification as OK.  Screen sticks on "confirm current date & time" as the centre cursor will not allow me to OK or edit.

    The device has a physical keyboard? If so, you can navigate to the menu item with the trackpad and then hit the "enter" key on the bottom right of the keyboard. It looks like an arrow going down and to the left.
    1. Please thank those who help you by clicking the "Like" button at the bottom of the post that helped you.
    2. If your issue has been solved, please resolve it by marking the post "Solution?" which solved it for you!

  • HT4113 How do I change the passcode when the iphone is disabled?  Passcode not known.

    How do I change the passcode when the iphone is disabled?  Passcode not known.

    legenic wrote:
    Do not try to backup directly before the restore. If you do, the backup will also have the passcode information. So if you restore that backup, you'll just put the passcode back on.
    The backup does not contain the passcode.  Restoring the backup does not put it back on the phone.

  • Should not create any output file when invalid input source schema

    I have a xslt file, which I have make code to check the order status value.
    If OrderStatus != 'Reject' --> create attribute, element for output file
    Else OrderStatus = 'Reject' --> do not create attribute/element ==> output is the empty file.
    Requirement: if OrderStatus = 'Reject' --> do not create any output file.
    how to do with this requirement?

    I'd ask them over here.
    http://forums.asp.net/
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • Exception Structure Field not Found

    Hi all!
    I'm having a strange trouble with a webdynpro app.
    I have a BAPI with a structure as an Input parameter, and another structure as an Output parameter, as well as the Return table.
    I imported the model to my app, created the custom controller, added the fields to the view, everything seems all right, but when I deploy and run the app, I get the exception that the field Versn of the Output structure is not found:
    com.sap.tc.webdynpro.progmodel.context.ContextConfigurationException: DataNodeInfo(Main.Zbapi_Wty_Codigo_Averia_Input.Output.Wa_Averia_Output): structure field Versn not found
        at com.sap.tc.webdynpro.progmodel.context.DataAttributeInfo.init(DataAttributeInfo.java(Compiled Code))
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.initUnmappedAttributes(NodeInfo.java(Compiled Code))
        at com.sap.tc.webdynpro.progmodel.context.DataNodeInfo.doInit(DataNodeInfo.java(Compiled Code))
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java(Compiled Code))
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java(Compiled Code))
        ... 29 more
    This is the first time it happens, I've used other BAPIs with a similar structure, but I got no errors, so I don't understand what might be wrong this time.
    Has any of you have a problem like this??
    Thanx.
    Jesus

    hii ,
    Thanks for your response.
    I did rebuild the project, restarted my j2ee engine, re-deployed my application but still getting the same error:
    com.sap.tc.webdynpro.progmodel.context.ContextConfigurationException: DataNodeInfo(Tdc_DataCust.Zsm_Add_New_Project_Input.Project_Data_AddProject): structure field Skill_Id not found
        at com.sap.tc.webdynpro.progmodel.context.DataAttributeInfo.init(DataAttributeInfo.java:299)
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.initAttributes(NodeInfo.java:672)
        at com.sap.tc.webdynpro.progmodel.context.DataNodeInfo.doInit(DataNodeInfo.java:233)
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:657)
        at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:660)
    Please do suggest.

  • Organisation Structure is not replicating completely from R/3 to CRM

    Hi SAP Gurus,
    Plaese help me out in this issue.
    We are replicating organisation structure from R/3 to CRM. There is Org Structure in which there are some sub org units say 6, under main org unit with positions and jobs. When try to replicating by tcode PFAL with evaluation path OS-CP, it geneartes IDOC in R/3, all are succesfully processed and Green. IN CRM, these Idocs are red and yellow with staus 51 and 52. As a result of this partial, org structure is replicated to CRM. In CRM, the Idoc is failed and It shows following errors:-->
    1. Resource key 4AFBD7B949F406E9E10000000B7404B7 is not known (Status 51)
    2. HR: ALE inbound processing for HR master data (Status 52)
    3. No Filter, No Conversion, No Field converted.
    Plaese advice to resolve this issue.
    Thanks a lot,
    Kind Regards
    Ash
    Edited by: Raman Khatri on Nov 23, 2009 2:43 PM
    Edited by: Raman Khatri on Nov 23, 2009 2:47 PM

    You can copy exactly error ??..
    For replication you need use tx PIDE in R3.
    In folder CRM>R3 you assign "BP Classification: Consumer, Customer, Sales prospect, competitor" to account group in R3. The BP Classification is hard code in CRM and only are available 5 types of classification.
    In folder R3> CRM you assing Account group R3 to CRM Classifcation and grouping. Grouping CRM is done in SPRO > Cross-Application Components >SAP Business Partner > Basic Settings > Number Ranges and Groupings > Define Groupings and Assign Number Ranges.
    Then, you define filter for replication in tx R3AC1 and replicate with tx R3AS

  • "This field name is not known", VB6, CRXI RDC

    Implementing RDC/designer in VB6 code.
    The underlying DB is SQL SERVER 2005. I turned to the RDC / designer method because I couldn't figure out, in a way that worked, how to override the SQL Server db at run time on client machine. My reports continued to want to find the tables on my development platform, not the live data in production. I've been fighting this thing for 6 weeks. (Never had the problem with Access mdb's, but that's a moot point)
    Any help / advice is appreciated!!
    All is well with my reports containing 1 table, using the following code:
    module
    Public KReport As New CrystalReport2
    command button
    Set KReport = New CrystalReport2
    KReport.DiscardSavedData ' (may not be necessary, the report does not have saved data)
    KReport.Database.AddOLEDBSource Adodc1.ConnectionString, "Netlink_ProductMaster"
    KReport.Database.SetDataSource Adodc1.Recordset, 3, 1
    Load Form2
    Form2.CRViewer1.ReportSource = KReport
    Form2.CRViewer1.ViewReport
    Form2.Show
    However, in my report with multiple tables I get error "This field name is not known" but no indication as to which field is a problem. Here's my code: (Note - If I bypass the SetDataSource code the report displays fine. That won't work at user site)
    module
    Public LReport As New CrystalReport3
    command button
    Dim i%
    Dim result&
    Set LReport = New CrystalReport3
    LReport.DiscardSavedData
    For i% = 1 To LReport.Database.Tables.Count
    LReport.Database.AddOLEDBSource Adodc1.ConnectionString, LReport.Database.Tables(i%).Name
    LReport.Database.SetDataSource Adodc1.Recordset, 3, i%
    ' LReport.Database.Tables(i%).CheckDifferences result&
    ' LReport.ReadRecords ' This just moved the error to here rather than when Form2 was "shown"
    Next i%
    Load Form2
    Form2.CRViewer1.ReportSource = LReport
    Form2.CRViewer1.ViewReport
    Form2.Show

    Are the data structures identical?
    Did you try Database, Verify Database... (in Crystal Designer for that report)?

  • PP_ORDER Archive Class AR_GPD to be registered is not known

    Hi Experts,
    I am doing PP_ORDER archiving,but i am getting this error log,
    Job started
    Step 001 started (program PPARCHA1, variant PP_ARCH, user ID VEEMA)
    Archiving session 000009 is being created
    Class AR_GPD to be registered is not known
    Job cancelled after system exception ERROR_MESSAGE
    i think,need to create AR_GPD class in ACLV,for that i need Structure and Standard package Name...
    Thanks and Regards,
    Veera.

    Summary
    Symptom
    You are on SAP ECC 6.0 or ECC 7.0 (ERP2005 or ERP 2007). You don't use the industry solution GPD ('Grouping, Pegging, Distribution'). When you try to archive the object PP_ORDER or MM_EKKO, the pre-processing job completes fine, but the write job fails with the error: "Class AR_GPD to be registered is not known".
    Other terms
    archiving RM06EW47 WRONG_ACCESS_TO_ARCHIVE PP order delete
    Reason and Prerequisites
    The reason is missing customizing entries.
    Solution
    Please make the following changes in customizing/configuration:
    [1] Transaction ACLA:
    You need to add a new entry as follows:
    Class    Description                    Function Group
    AR_GPD    GPD Object Archive Class        AGPD
    [2] For this archiving class, you need to define the "Tables to be Archived" as follows:
    Structure        Do not delete
    PEG_TACTASS       check
    PEG_TASS          check
    PEG_TSTK          check
    [3] For the archiving class, define "tables from Which You Only Delete Entries:
    Tab. name
    PEG_TACTASS
    PEG_TASS
    PEG_TSTK
    [4] Transaction ACLA:
    Class P_ORDER -> Archiving classes used: include AR_GPD.
    [5] Transaction AOBJ:
    Archiving object MM_EKKO: Archiving classes Used -> AR_GPD
    Archiving object PP_ORDER: Archiving classes Used -> P_ORDER

  • In new iPad 4g, when sim card is not inserted, I can not find the enable 4g tap in the setting-cellular data tap, can some one please tell me if this is normal and if so, then when it appears, thanks

    In new iPad 4g, when sim card is not inserted, I can not find the enable 4g tap in the setting-cellular data tap, can some one please tell me if this is normal and if so, then when it appears, thanks

    If the SIM is out of your phone, find my phone needs a data connection, so could use wifi - IF in range of a wifi and one that it can join (ie. a known network or one that is wholly open so no login required).  Your phone could also simple be turned off, so not findable, or it may have been restored (plugged into iTunes and restored as new) again, making it permanently unfindable.  Honestly, for someone stealing an iPhone, this is likely the first thing they do - restore as new and it is theirs forever.
    Find my iPhone is tied to the users iCloud account - the find function is part of the iCloud account's services and it communicates with the iCloud servers over a data connection - either wifi or 3G.
    Have you set up your iCloud account on your replacement phone, and is it working properly on that phone?

Maybe you are looking for