How to set the result of the dynamic query in a refcursor ON param.

Hello

I created the following package.

CREATE OR REPLACE package LGIS
Is

Type T_Cust_Acct_Arr is table of number;

Type Invc_Base_Rec_Type is (Record
Invoice_Control_No Customer_History.Invoice_Control_No%Type,
Billing_Cycle_Id Eb_Oor_Cust_Online.Billing_Cycle_Id%Type,
Bill_Cycl_Occr_No Eb_Oor_Cust_Online.Bill_Cycl_Occr_No%Type,
Invoice_Dt Bill_Cycl_Occr_Inf.Invoice_Date%Type,
Invc_Acct_Id Eb_Oor_Cust_Online.Customer_Acct_Id%Type,
Acct_Id Eb_Oor_Cust_Online.Customer_Acct_Id%Type
);

Type Invc_Base_Refcur_Type is Ref Cursor
Return Invc_Base_Rec_Type;

Procedure P_Get_Approved_Whole_Invcs)
In_From_Invc_Dt by Date,
In_To_Invc_Dt by Date,
In_Cust_Acct_List in T_Cust_Acct_Arr,
Out_Eb_Invcs on Invc_Base_Refcur_Type
On_Error_No number
);

End LGIS;
/

CREATE OR REPLACE PACKAGE BODY Lgis
IS

PROCEDURE P_Get_Approved_Whole_Invcs)
In_From_Invc_Dt BY DATE,
In_To_Invc_Dt BY DATE,
In_Cust_Acct_List IN T_Cust_Acct_Arr,
Out_Eb_Invcs on Invc_Base_Refcur_Type
On_Error_No NUMBER
)
IS
S_Query VARCHAR2 (4000);
Invalid_Exception EXCEPTION;


BEGIN
On_Error_No: = 0;

IF In_Cust_Acct_List.COUNT > 0 THEN
FORALL i IN 1.In_Cust_Acct_List.COUNT
INSERT INTO EB_CUST_ACCT_WHOLE_TMP (Cust_Acct_Val)
VALUES (In_Cust_Acct_List (i));
END IF;


BEGIN
S_Query: = 'Select Ch.Invoice_Control_No,';
S_Query: = S_Query | ' Eoco.Billing_Cycle_Id,';
S_Query: = S_Query | ' Eoco.Bill_Cycl_Occr_No,';
S_Query: = S_Query | ' Bcoi.Invoice_Date,';
S_Query: = S_Query | ' Eoco.Customer_Acct_Id as Invc_Acct_Id';
S_Query: = S_Query | ' Eoco.Customer_Acct_Id as Acct_Id ';
S_Query: = S_Query | "Of Eb_Oor_Cust_Online Eoco,';
S_Query: = S_Query | "Customer_History Ch';
S_Query: = S_Query | ' Bcoi Bill_Cycl_Occr_Inf,';
S_Query: = S_Query | "Audit_Var_Log Avl,';
S_Query: = S_Query | "Audit_Var_Def Avd,';
S_Query: = S_Query | "Eb_Cust_Acct_Whole_Tmp Tmp';
S_Query: = S_Query | "Where Avd.Audit_Var_Cd ="CYCLE_APPROVAL"';
S_Query: = S_Query | ' And Avl.Audit_Var_Sub_Grp_Val = 0';
S_Query: = S_Query | "And Avl.Audit_Var_Char_Val =" COMPLETE "';
S_Query: = S_Query | ' And Eoco.Customer_Acct_Id = Tmp.Cust_Acct_Val';
S_Query: = S_Query | ' And Eoco.Customer_Acct_Id = Ch.Customer_Acct_Id';
S_Query: = S_Query | ' And Eoco.Billing_Cycle_Id = Ch.Billing_Cycle_Id';
S_Query: = S_Query | ' And Eoco.Bill_Cycl_Occr_No = Ch.Bill_Cycl_Occr_No';
S_Query: = S_Query | ' And Eoco.Billing_Cycle_Id = Bcoi.Billing_Cycle_Id';
S_Query: = S_Query | ' And Eoco.Bill_Cycl_Occr_No = Bcoi.Bill_Cycl_Occr_No';
S_Query: = S_Query | ' And Avd.Audit_Var_Id = Avl.Audit_Var_Id';
S_Query: = S_Query | ' And Avl.Audit_Var_Grp_Id = Bcoi.Audit_Var_Grp_Id';


IF (In_From_Invc_Dt IS NULL AND In_To_Invc_Dt IS NOT NULL) THEN
S_Query: = S_Query | "And Bcoi.Invoice_Date < = In_To_Invc_Dt';
END IF;

IF (In_To_Invc_Dt IS NULL AND In_From_Invc_Dt IS NOT NULL) THEN
S_Query: = S_Query | ' And Bcoi.Invoice_Date > = In_From_Invc_Dt';
END IF;

IF (In_From_Invc_Dt IS NOT NULL AND In_To_Invc_Dt IS NOT NULL) THEN
S_Query: = S_Query | ' And Bcoi.Invoice_Date > = In_From_Invc_Dt';
S_Query: = S_Query | "And Bcoi.Invoice_Date < = In_To_Invc_Dt';
END IF;


RUN IMMEDIATELY S_Query IN Out_Eb_Invcs;
EXCEPTION
WHILE OTHERS THEN
On_Error_No: = - 1;
RAISE Invalid_Exception;
END;
Exception
When Invalid_Exception then
On_Error_No: = - 1;
Return;
While others then
On_Error_No: = - 1;
END P_Get_Approved_Whole_Invcs;
Lgis END;
/

It compiles without error. But at runtime, I get the following error:

ORA-06504: PL/SQL: return variables of the game results or the query types do not match

Please help solve this problem.

Thank you
Olivier

Maybe it will work for you too->

CREATE OR REPLACE Package Body Lgis
Is
     Procedure P_Get_Approved_Whole_Invcs
     (
          In_From_Invc_Dt In Date,
          In_To_Invc_Dt In Date,
          In_Cust_Acct_List In T_Cust_Acct_Arr,
          Out_Eb_Invcs Out Invc_Base_Refcur_Type,
          On_Error_No Out Number
     )
     Is
          S_Query Varchar2(4000);
          Invalid_Exception Exception;
     Begin
          On_Error_No := 0;

          If In_Cust_Acct_List.Count > 0 Then
               Forall I In 1..In_Cust_Acct_List.Count
               Insert Into Eb_Cust_Acct_Whole_Tmp (Cust_Acct_Val)
               Values (In_Cust_Acct_List (I));
          End If;

          Begin
               S_Query := '     Select      Ch.Invoice_Control_No Invoice_Control_No, '
                        ||'                 Eoco.Billing_Cycle_Id Billing_Cycle_Id, '
                        ||'                 Eoco.Bill_Cycl_Occr_No Bill_Cycl_Occr_No, '
                        ||'                Bcoi.Invoice_Date Invoice_Dt, '
                        ||'                Eoco.Customer_Acct_Id As Invc_Acct_Id,'
                        ||'                Eoco.Customer_Acct_Id As Acct_Id '
                        ||'     From      Eb_Oor_Cust_Online Eoco, '
                        ||'                Customer_History Ch, '
                        ||'                Bill_Cycl_Occr_Inf Bcoi, '
                        ||'                Audit_Var_Log Avl, '
                        ||'                Audit_Var_Def Avd, '
                        ||'                Eb_Cust_Acct_Whole_Tmp Tmp '
                        ||'     Where      Avd.Audit_Var_Cd = '||chr(39)||'CYCLE_APPROVAL'||chr(39)
                        ||'     And      Avl.Audit_Var_Sub_Grp_Val = 0 '
                        ||'     And      Avl.Audit_Var_Char_Val = '||chr(39)||'COMPLETE'||chr(39)
                        ||'     And      Eoco.Customer_Acct_Id = Tmp.Cust_Acct_Val '
                        ||'     And      Eoco.Customer_Acct_Id = Ch.Customer_Acct_Id '
                        ||'     And      Eoco.Billing_Cycle_Id = Ch.Billing_Cycle_Id '
                        ||'     And      Eoco.Bill_Cycl_Occr_No = Ch.Bill_Cycl_Occr_No '
                        ||'     And      Eoco.Billing_Cycle_Id = Bcoi.Billing_Cycle_Id '
                        ||'     And      Eoco.Bill_Cycl_Occr_No = Bcoi.Bill_Cycl_Occr_No '
                        ||'     And      Avd.Audit_Var_Id = Avl.Audit_Var_Id '
                        ||'     And      Avl.Audit_Var_Grp_Id = Bcoi.Audit_Var_Grp_Id '

               If (In_From_Invc_Dt Is Null And In_To_Invc_Dt Is Not Null) Then
                    S_Query:=S_Query||'     And Bcoi.Invoice_Date <= In_To_Invc_Dt ';
               End If;

               If (In_To_Invc_Dt Is Null And In_From_Invc_Dt Is Not Null) Then
                    S_Query:=S_Query||'     And Bcoi.Invoice_Date >= In_From_Invc_Dt ';
               End If;

               If (In_From_Invc_Dt Is Not Null And In_To_Invc_Dt Is Not Null) Then
                    S_Query:=S_Query||'     And Bcoi.Invoice_Date >= In_From_Invc_Dt '
                                    ||'     And Bcoi.Invoice_Date <= In_To_Invc_Dt ';
               End If;

               Dbms_Output.Put_Line ('Test');
               Open Out_Eb_Invcs For S_Query;
               Dbms_Output.Put_Line ('Test1');
               Loop
                    Fetch Out_Eb_Invcs Into Ibrt_Type;
                    Exit When Out_Eb_Invcs%notfound;
                    Dbms_Output.Put_Line ('Invoice_Control_No: ' || Ibrt_Type.Invoice_Control_No);
                    Dbms_Output.Put_Line ('Billing_Cycle_Id: ' || Ibrt_Type.Billing_Cycle_Id);
                    Dbms_Output.Put_Line ('Bill_Cycl_Occr_No: ' || Ibrt_Type.Bill_Cycl_Occr_No);
                    Dbms_Output.Put_Line ('Invoice_Dt: ' || Ibrt_Type.Invoice_Dt);
                    Dbms_Output.Put_Line ('Invc_Acct_Id: ' || Ibrt_Type.Invc_Acct_Id);
                    Dbms_Output.Put_Line ('Acct_Id: ' || Ibrt_Type.Acct_Id);
               End Loop;
               Dbms_Output.Put_Line ('Test2');
               Close Out_Eb_Invcs;

               /* Exception
               When Others Then
               On_Error_No := -1;
               Raise Invalid_Exception; */
          End;
     Exception
          When Invalid_Exception Then
               On_Error_No := -1;
               Return;
     /* When Others Then
     On_Error_No := -1; */
     End P_Get_Approved_Whole_Invcs;
End Lgis;

Your problem is now fixed.

Kind regards.

LOULOU.

Tags: Database

Similar Questions

  • How to set the dynamic download location?

    I need to set the location of default download as x:\downloads\2012_07 if the current month is July and x:\downloads\2012_08 if the current month is August but not manually, therefore automatically, what can I do with prefs.js (i.e.) user_pref ("browser.download.dir"?),
    Your help will be very appreciated.

    prefs.js alone cannot do what you want. You would need an addon with these characteristics "date" to actively change this pref Windows calendar-based. Try this addon and see how it works for you - don't use it myself.

    https://addons.Mozilla.org/en-us/Firefox/addon/automatic-save-folder/

  • How to set the printer wireless ad Hoc mode to CP1025nw with automatic stop is off? IE never automatic.

    How to set the printer wireless ad Hoc mode to CP1025nw with automatic stop is off? IE never automatic.

    Thank you very much for your help, if necessary.

    Quite a few questions, send, but I will do what I can to answer them.

    I recommend first to buy a router, even if it's one you won't connect to internet and it network with others your PC and printer. This will give you the best features and the results of what you're trying to do.

    In addition, the automatic stop of the printer function can be disabled and is not affected by the type of connection. Usually, you can go through the configuration Menu and select tools to change the options there on the energy saving features.

    Finally, the auto off function on your computer is a Windows question, but one easy answer. If you're on a laptop, you can right click on the battery in the tray (lower right corner) and change the settings for energy conservation.

    You might be better off installing the printer via the USB cord and alternately inspiring when you use it, but which is not optimal if you are printing only a few documents on an irregular basis. A network connection is the easiest to manage across multiple computers, honesty, but you have certain requirements for this connection and limits as well.

    I hope this information is useful!

  • How to set the path of the report in a plugin for model

    I'm trying to figure out how to set the path of the report in a plugin process model. I can't find a way to have access to it. It seems this would be a reasonable thing to do since the plug-ins are for the treatment of the results. Does anyone know how to do this? We generally use the sequential process model, but I try to keep my plug-in as independent as possible.

    Thank you.

    If I understand correctly, you want your plug-in, when enabled, change the settings of all other instances of the report OR plugin as their reports share the same directory that your plug-in is configured to use.

    If so, your plug-in can access and change the settings of all other instances of plugin. All instances are passed to all the points of plugin entries in the subproperty of the plugins of the ModelConfiguration parameter table. You can browse this table. Any element of the array with an equal to "NI_ReportGenerator.seq" Base.SequenceFilename is an instance of the report OR plugin. Its report options are stored in the element under PluginSpecific.Options.

    You can change the report options to what you want. Note that the recall of the ReportOptions model is called from template-plugin Initialize entry point, then you might want to ensure that your changes are applied after that, so they are not replaced. To do this, you could make your changes in the Initialize entry point of your plugin and make sure your plugin runs last. To rotate the last, you can set the FileGlobals.ModelPluginComponentDescription.Default.Base.RunOrder in your file of plug-in with a value greater than 0, for example 1.0 (see Help for TestStand > Fundamentals > process template Architecture > plug-in for the model process Architecture > Structure of the plugin sequence files > plugin model of entry Points > Order Execution of Point of entry at run time).

  • How to set the maximum fan speed. on X230t (Windows 8)?

    How to set the maximum fan speed. on X230t (Windows 8)?

    I use TPfancontrol to set the speed of the fan in the X230t. However, this will result in excessive wear on your bearing X230t fan, which causes a premature fan failure. Is there a reason why you want to run the fan at max speed?

  • How to set the name of the author and where I find all of the debug option token during the race or the creation of the application on QNX IDE?

    How to set the name of the author and where I find all of the debug option token during the race or the creation of the application on QNX IDE?

    Here is the error

    Failure of deployment: Info: request shipment: install and launch
    Info: Action: install and launch
    News: Native debugging: on
    Info: File size: 219949
    Info: Installing com.example.UIBB10AppTest1.testDev_B10AppTest15dd51c62...
    Info: Treatment 219949 bytes
    actual_dname:
    actual_id:
    actual_version:
    result::failure 881 the application author does not match the author token of debugging

    The author information is located in the bar - descriptor.xml in the tab "General". But the information must be defined automatically. In addition, you must install the token debug on your device.

    If everything is configured properly there is only one problem that happened to me. I had several chips debugging Momentics. I had to remove all chips debugging and leave alone the I want to use. Perhaps, you have also several debugging chips installed in Momentics. This seems to be a bug in Momentics who can't handle several chips debugging.

  • How to set the key numb to activate at startup

    How to set the key numb to activate at startup on computer laptop gateway running windows 7?

    Original title: numb locking button

    Hello Wan,

    Thanks for the quick response. We appreciate your time and your efforts.

    By default the NUM LOCK status is the same as it was before you shut down the computer properly. If it is on when you shut it down it will be on when you turn on the computer again.

    A few users have solved this problem by disabling fast boot option in the BIOS (Basic Input Output System). I would ask disable youFast Boot to the BIOS and check if that helps.

    For more information about how to disable Fast Boot in the BIOS, I would ask you to contact the manufacturer of the system.

    Note:

    BIOS change / semiconductor (CMOS) to complementary metal oxide settings can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the configuration of the BIOS/CMOS settings can be solved. Changes to settings are at your own risk.

    Hope the helps of information provided. Let us know the results and do not hesitate to post on the Microsoft Community, in case you have problems when you are working on Windows.

  • How to set the size of default when page scan document in

    How you set the default page size in the analysis in the document

    I found the answer in the Acrobat/kb/scanning-letter-size-documents-results-in-legal-PDF

    It's in PDF format by Scanner > Scan button click Options customized to the right of the name of the scanner.

    From here he choose Show the Scanner's Native Interface.   Then choose the correct page size

    which is shaded on so I couldn't choose.  It worked in all cases.

    I have Acrobat XI and Photosmart HP 7520.   Thanks for the replies.

  • How to set the doctype node using dbms_xmldom?

    Hi all

    IM using oracle 10g. I generated an xml file using dbms_xmldom.

    I need set the version xml and doctype to my xml file.

    XML version I've defined using dbms_xmldom.writeTofile.

    But not able to set the doctype... tried with dbms_xmldom.makedocumenttype... But no result...

    How to set the doctype using dbms_xmldom?

    Concerning
    Sankar MN

    Published by: SankaraNarayanan.M.N on October 17, 2011 05:40

    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_xmldom.htm#i1121082

  • How to set the height width for an Image field in a web App?

    I have a webApp to save the image of user with description, title. But when I display all items pictures are great, I want to know how to set the height and width for images?

    Hello

    To do this properly, you need to resize the image. Prefably before you put it in British Colombia. While you can to scale the image in CSS, you don't want to do. Why? Because the images are still very large and probably not optimized properly for the web.

    This means that the page with these images will take a long time to load for people, and people will not be happy on the display of your site.

    You must use a software such as photoshop, if you or iphoto on a mac for example for editing, crop and size of the images before uploading. If you do everything you can use free web based tools such as this one:
    http://Pixlr.com/editor/

    You can also do in British Colombia itself in the file manager. If you click on the image you can see options to resize. The downside to this is's done it by pure mathematics. He doesn't know what is in the picture and the results can make the image etc. shrivelled.

  • How to set the background color of a page_item?

    I was pasting "background-color: #5CD65C" in a number of places, like the 'attributes of the HTML table cells' under the label and the tabs of the item, but get no results. Can someone tell me how to set the background color of a cell, please?

    Hi Doug,.
    One method is to add a style to your header html in page attributes, if you add the below css styling and the change of the name of the item page (#P2_FIRST_NAME) to your he should style correctly:

    Thank you

    Paul

  • How to set the value of a field from the LOV of another field.

    I'm trying to figure out how to set the value of a field (P_PROGRAM) to the value of another field of based lov (P_STATE).

    The P_PROGRAM field is a hidden field. The P_STATE field is a required field and is based on a list of values for the State Codes.

    When a user selects the State to P_STATE, the field of the P_PROGRAM should be set to this value, as well.

    I tried different ways to get there via a function call on the post for the calculation of the field P_STATE, defining the source P_PROGRAM to the value of the page item P_STATE put varialbles, creating a process before SENDING, and they all still come back as having a NULL value for P_PROGRAM, therefore impossible to create the file in the db as the PROGRAM is a mandatory field in the table.

    Can you please help? Thank you, Laura

    Laura,

    It is always helpful if you provide information about the Apex version you are using. The Apex 4 you can use Dynamic Actions to achieve this. In earlier versions is possible using processes to submit or javacsripts, as well.

    Heres how you do in 3.x with treatment to submit, to make it work in 4.0 as well.

    1 do the P_STATE ' select list submits the Page.
    2. Add a calculation on the point P_PROGRAM, or write to him assign a value based on a process. The treatment should be OnLoad after the header
    3. If the page does not have an unconditional branch that loops on itself, add a. NOTE: The direction must be the last branch (larger sequence number) and should have checked "Save Session State".

    This is what will happen
    a. when the State is selected Page will be submitted
    (b) it will take the unconditional branch to himself and save the value of P_STATE
    c. the calculation process / fills the value of the P_PROGRAM element when the page reloads

    Kind regards

  • How to set the default prompt of dashboard?

    Hello
    In my dashboard prompt, I get values such as:

    March 2010
    Apr 2010
    May 2010
    June 2010

    How to set the default value for the month in progress (June 2010). I don't want to use "specific value. I want to use the 'SQL result' to populate the default value.

    Appreciate your help

    You can use select to_char (trunc (sysdate), 'Mon-YYYY') of the double

    see you soon,
    Vineeth

  • How to set the field "default" of a quick dashboard to yesterday?

    Hello world

    I have a dashboard the guest on a date (full name Date.Date and type Date).
    I also have a simple report with two columns: Date.Date and a measure (whatever the name).

    I've managed to filter the day before the current date in the report by adding an advanced SQL filter:
    Date.Date = Cast (TimestampAdd(SQL_TSI_DAY,-1,@{system.currentTime}) as Date)

    Now, I would like to invite him to select the day before the current date by default.
    The filter on Date.Date would be "invited" or more.

    How to set the field "Default" from the command prompt?

    Thanks in advance

    Hello

    go to the command prompt...
    Select SQL results of as default: drop-down list.
    here... you have to write your SQL logic...
    who uses by default the previous date
    something like that...

    * Select case when 1 = 0 then anydate column of another timestampadd (sql_tsi_day-1, CURRENT_DATE) of the end SubjectArea name*.

    write like this... and report back...

    Thank you & best regards
    Kishore Guggilla

  • How to set the number of e-mail messages that are stored on my iPhone

    How to set the number of e-mail messages that are stored on my iPhone – so when I don't have a network connection I can see a 'large' number of messages in my Inbox etc.

    This is series is not defined in the world

    You must go to settings-> mail, contacts, and calendars and check the settings of your e-mail provider offers in this area

Maybe you are looking for

  • Setting the mode BIOS LBA - Satellite A100 - 011 PSAARE

    I have the tool 'EASEUS Partition manager', and when I start this tool, I have an error message "Manager Easeus partition detected an error on the disk 1" "start LBA value partition xxxxxxxxxxxxxxxxx is invalid". "." Using the tool says:--------Chang

  • graphic multithreaded WPF error

    When I create 2 wires that respectively show 2 graphics, an error occurs. When I commented "_controlDispatcher1.BeginInvoke (aps1 [f], simulatedData)", no error occurs. code in MainWindow.xaml.cs line: 320 complete code to testmultithread.zip

  • Windows Defender won't let me to open the startup programs

    Hello, I have a Vista ultimate on my computer. I use Norton Security. I want to delete some startup programs. Go to the Control Panel, clicking Startup Programs - Windows Open saying that Windows Defender is disabled... I click on the link to activat

  • Store the function does not.

    My backup will not work.  It starts, but stops at half way through and gives this error message: incorrect function (0 x 80070001).  What can I do to fix this?

  • Drives hot swap in BIOS not safe to remove the value

    I have a Doc Icy as the docks of the internal disks in a Bay with two power switches front of 5.25 inch front - one for the 2.5 inches dock bay and one for the Bay dock of 3.5 inches.  In the last inserted here readers as well as internal hard drives