SQL stored procedure Staging.GroomDwStagingData stuck in infinite loop, consuming excessive CPU

Hello
I'm hoping that someone here might be able to help or point me in the right direction. Apologies for the long post.
Just to set the scene, I am a SQL Server DBA and have very limited experience with System Centre so please go easy on me.
At the company I am currently working they are complaining about very poor performance when running reports (any).
Quick look at the database server and CPU utilisation being a constant 90-95%, meant that you dont have to be Sherlock Holmes to realise there is a problem. The instance consuming the majority of the CPU is the instance hosting the datawarehouse and in particular
a stored procedure in the DWStagingAndConfig database called Staging.GroomDwStagingData.
This stored procedure executes continually for 2 hours performing 500,000,000 reads per execution before "timing out". It is then executed again for another 2 hours etc etc.
After a bit of diagnosis it seems that the issue is either a bug or that there is something wrong with our data in that a stored procedure is stuck in an infinite loop
System Center 2012 SP1 CU2 (5.0.7804.1300)
Diagnosis details
SQL connection details
program name = SC DAL--GroomingWriteModule
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
Store procedures executed
1. dbo.p_GetDwStagingGroomingConfig (executes immediately)
2. Staging.GroomDwStagingData (this is the procedure that executes in 2 hours before being cancelled)
The 1st stored procedure seems to return a table with the "xml" / required parameters to execute Staging.GroomDwStagingData
Sample xml below (cut right down)
<Config>
<Target>
<ModuleName>TransformActivityDim</ModuleName>
<WarehouseEntityName>ActivityDim</WarehouseEntityName>
<RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
<Watermark>2015-01-30T08:59:14.397</Watermark>
</Target>
<Target>
<ModuleName>TransformActivityDim</ModuleName>
<WarehouseEntityName>ActivityDim</WarehouseEntityName>
<RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName>
<ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName>
<Watermark>2015-01-30T08:59:14.397</Watermark>
</Target>
</Config>
If you look carefully you will see that the 1st <target> is missing the ManagedTypeViewName, which when "shredded" by the Staging.GroomDwStagingData returns the following result set
Example
DECLARE @Config xml
DECLARE @GroomingCriteria NVARCHAR(MAX)
SET @GroomingCriteria = '<Config><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><Watermark>2015-01-30T08:59:14.397</Watermark></Target><Target><ModuleName>TransformActivityDim</ModuleName><WarehouseEntityName>ActivityDim</WarehouseEntityName><RequiredWarehouseEntityName>MTV_System$WorkItem$Activity</RequiredWarehouseEntityName><ManagedTypeViewName>MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity</ManagedTypeViewName><Watermark>2015-01-30T08:59:14.397</Watermark></Target></Config>'
SET @Config = CONVERT(xml, @GroomingCriteria)
SELECT
ModuleName = p.value(N'child::ModuleName[1]', N'nvarchar(255)')
,WarehouseEntityName = p.value(N'child::WarehouseEntityName[1]', N'nvarchar(255)')
,RequiredWarehouseEntityName =p.value(N'child::RequiredWarehouseEntityName[1]', N'nvarchar(255)')
,ManagedTypeViewName = p.value(N'child::ManagedTypeViewName[1]', N'nvarchar(255)')
,Watermark = p.value(N'child::Watermark[1]', N'datetime')
FROM @Config.nodes(N'/Config/*') Elem(p)
/* RESULTS - NOTE THE NULL VALUE FOR ManagedTypeViewName
ModuleName WarehouseEntityName RequiredWarehouseEntityName ManagedTypeViewName Watermark
TransformActivityDim ActivityDim MTV_System$WorkItem$Activity NULL 2015-01-30 08:59:14.397
TransformActivityDim ActivityDim MTV_System$WorkItem$Activity MTV_Microsoft$SystemCenter$Orchestrator$RunbookAutomationActivity 2015-01-30 08:59:14.397
When the procedure enters the loop to build its dynamic SQL to delete relevant rows from the inbound schema tables it concatenates various options / variables into an executable string. However when adding a NULL value to a string the entire string becomes
NULL which then gets executed.
Whilst executing "EXEC(NULL)" would cause SQL to throw an error and be caught, executing the following doesnt
DECLARE @null_string VARCHAR(100)
SET @null_string = 'hello world ' + NULL
EXEC(@null_string)
SELECT @null_string
So as it hasnt caused an error the next part of the procedure is to move to the next record and this is why its caught in an infinite loop
DELETE @items WHERE ManagedTypeViewName = @View
The value for the variable @View is the ManagedTypeViewName which is NULL, as ANSI_NULLS are set to ON in the connection and not overridded in the procedure then the above statement wont delete anything as it needs to handle NULL values differently (IS NULL),
so we are now stuck in an infinite loop executing NULL for 2 hours until cancelled.
I amended the stored procedure and added the following line before the loop statement which had the desired effect and "fixed" the performance issue for the time being
DELETE @items WHERE ManagedTypeViewName IS NULL
I also noticed that the following line in dbo.p_GetDwStagingGroomingConfig is commented out (no idea why as no notes in the procedure)
--AND COALESCE(i.ManagedTypeViewName, j.RelationshipTypeViewName) IS NOT NULL
There are obviously other ways to mitigate the dynamic SQL string being NULL, there's more than one way to skin a cat and thats not why I am asking this question, but what I am concerned about is that is there a reason that the xml / @GroomingCriteria is incomplete
and / or that the procedures dont handle potential NULL values.
I cant find any documentation, KBs, forum posts of anyone else having this issue which somewhat surprises me.
Would be grateful of any help / advice that anyone can provide or if someone can look at their 2 stored procedures on a later version to see if it has already been fixed. Or is it simply that we have orphaned data, this is the bit that concerns most as I dont
really want to be deleting / updating data when I have no idea what the knock on effect might be
Many many thanks
Andy

First thing I would do is upgrade to 2012 R2 UR5. If you are running non-US dates you need the UR5 hotfix also.
Rob Ford scsmnz.net
Cireson www.cireson.com
For a free SCSM 2012 Notify Analyst app click
here

Similar Messages

  • Unable to use the values returned by a PL/SQL stored procedure in a XSQL page

    Hi,
    I've been messing around with XML and XSQL in particular. I was trying to write a xsql page to display a report with account totals...I have the following .xsql which calls a PL/SQL stored procedure :
    <?xml version="1.0"?>
    <xsql:query connection="pfcdm" xmlns:xsql="urn:oracle-xsql">
    <xsql:set-session-param name="zasset_total" value="100">
    <xsql:dml connection="pfcdm">
    rraman.sp_vw_id(zasset_total,zinvm_total,zmkt_val);
    </xsql:dml>
    </xsql:set-session-param>
    select 'Asset total is {@zasset_total}' as "ASSET_TOTAL" from dual
    </xsql:query>
    My procedure sp_vw_id returns the values that it should. But, I am not sure how to declare variables within a page, and to output the return values. There is very scanty documentation on the usage of <xsql:dml> or <xsql:ref-cursor-function>.
    Any response would be greatly appreciated.
    Thanks,
    Raja

    Here is the example from the Oracle9i (complete rewrite) of the XSQL Chapter in our Oracle documentation.
    Question
    I using <xsql:dml> to call a stored procedure which has one OUT parameter, but I was not able to see any results. The executed code results in the following statement:
    <xsql-status action="xsql:dml" rows="0"/>
    Answer
    You cannot set parameter values by binding them in the position of OUT variables in this release using <xsql:dml>. Only IN parameters are supported for binding. You can create a wrapper procedure that constructs XML elements using the HTP package and then your XSQL page can invoke the wrapper procedure using <xsql:include-owa> instead.
    For an example, suppose you had the following procedure:
    CREATE OR REPLACE PROCEDURE addmult(arg1 NUMBER,
    arg2 NUMBER,
    sumval OUT NUMBER,
    prodval OUT NUMBER) IS
    BEGIN
    sumval := arg1 + arg2;
    prodval := arg1 * arg2;
    END;You could write the following procedure to "wrap" it, taking all of the IN arguments that the procedure above expects, and then "encoding" the OUT values as a little XML datagram that you print to the OWA page buffer:
    CREATE OR REPLACE PROCEDURE addmultwrapper(arg1 NUMBER, arg2 NUMBER) IS
    sumval NUMBER;
    prodval NUMBER;
    xml VARCHAR2(2000);
    BEGIN
    -- Call the procedure with OUT values
    addmult(arg1,arg2,sumval,prodval);
    -- Then produce XML that encodes the OUT values
    xml := '<addmult>'&#0124; &#0124;
    '<sum>'&#0124; &#0124;sumval&#0124; &#0124;'</sum>'&#0124; &#0124;
    '<product>'&#0124; &#0124;prodval&#0124; &#0124;'</product>'&#0124; &#0124;
    '</addmult>';
    -- Print the XML result to the OWA page buffer for return
    HTP.P(xml);
    END;This way, you can build an XSQL page like this that calls the wrapper procedure:
    <page connection="demo" xmlns:xsql="urn:oracle-xsql">
    <xsql:include-owa bind-params="arg1 arg2">
    BEGIN addmultwrapper(?,?); END;
    </xsql:include-owa>
    </page>This allows a request like:
    http://yourserver.com/addmult.xsql?arg1=30&arg2=45
    to return an XML datagram that reflects the OUT values like this:
    <page> <addmult><sum>75</sum><product>1350</product></addmult>
    </page>

  • Why doesn't SSRS like an IF Statement in my SQL Stored Procedure???

    I have multiple IF Statements at the end of my SQL Stored Procedure Process that utilizes a @ReportTypeName Parameter to produce the chosen report result set
    IF @ReportTypeName = 'HMO-POS New To HFHP - No Prior Year Member Spans'
    BEGIN
    SELECT DISTINCT
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Contract Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Subscriber Member Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Pkg],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Division Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EFF DATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER FIRST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER LAST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Broker Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ADDRESS 1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER CITY],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER STATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ZIPCODE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE2],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE3],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EMAIL],
    CONVERT(VARCHAR,CAST(CONVERT(VARCHAR, [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH]) AS DATETIME),101) AS [INDV MEMBER BirthDate],
    FLOOR((CAST (GETDATE() AS INTEGER) - CAST(CONVERT(DATETIME, CONVERT(CHAR(8), [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH])) AS INTEGER)) / 365.25) AS [INDV MEMBER AGE]
    FROM [#TempTable_Distinct_Individual_Member_All_Info]
    WHERE (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] NOT IN
    (SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
    FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans])
    ORDER BY [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
    END
    IF @ReportTypeName = 'HMO-POS Renewals'
    BEGIN
    SELECT DISTINCT
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Contract Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Member Subscriber Member Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Pkg],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Division Nbr],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EFF DATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER FIRST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER LAST NAME],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV Broker Name],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ADDRESS 1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER CITY],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER STATE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER ZIPCODE],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE1],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE2],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER PHONE3],
    [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER EMAIL],
    CONVERT(VARCHAR,CAST(CONVERT(VARCHAR, [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH]) AS DATETIME),101) AS [INDV MEMBER BirthDate],
    FLOOR((CAST (GETDATE() AS INTEGER) - CAST(CONVERT(DATETIME, CONVERT(CHAR(8), [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER YMDBIRTH])) AS INTEGER)) / 365.25) AS [INDV MEMBER AGE]
    FROM [#TempTable_Distinct_Individual_Member_All_Info]
    INNER JOIN [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]
    ON [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR] = [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
    WHERE (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    ORDER BY [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR]
    END
    Microsoft Visual Studio and SQL Server Reporting Services did not like this! When I added my dataset and parameters accordingly, my Dataset had no fields...almost as if running the Stored Procedure in the background to get its Metadata was not working. I
    know this works because I tested it as a result of a straight EXEC Command. Why doesn't Microsoft Visual Studio and SQL Server Reporting Services not like this IF? I did end up getting around this by parameterizing the WHERE clause based on the @ReportTypeName
    chosen.
    WHERE (@ReportTypeName = 'HMO-POS New To HFHP - No Prior Year Member Spans'
    AND (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] NOT IN
    (SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
    FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]))
    OR (@ReportTypeName = 'HMO-POS Renewals'
    AND (CHARINDEX('HMO',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0
    OR CHARINDEX('POS',LTRIM(RTRIM([#TempTable_Distinct_Individual_Member_All_Info].[INDV Benefit Plan Name])),1) > 0)
    AND [#TempTable_Distinct_Individual_Member_All_Info].[INDV MEMBER NBR] IN
    (SELECT [#TempTable_Distinct_Individual_Member_Prior_Year_Spans].[INDV MEMBER NBR]
    FROM [#TempTable_Distinct_Individual_Member_Prior_Year_Spans]))
    I appreciate your review and am hopeful for a reply.
    Thanks!

    Hi ITBobbyP,
    I have tested on my local environment and can reproduce the issue, the issue can be caused by the temp table you are using which will also cause the data not display.
    I have use below sample table and record to have a test and details information below for your reference:
    Right click the DataSet to select the "DataSet Properties" and click the query designer to execute the stored procedure by click the "!" to check if you can get the data:
    If you got some error, the issue can be cause by the temp table invalid, so please make sure you have add the query to create and insert  recored to temp table like below:
    CREATE PROCEDURE vickytest0311_1
    @ReportTypeName nvarchar(50)
    AS
    create table #VickyTest
    column1 int,
    column2 varchar(20)
    insert into #VickyTest values (1,'Test1')
    insert into #VickyTest values (2,'Test2')
    insert into #VickyTest values (3,'Test3')
    IF @ReportTypeName ='Test1'
    BEGIN
    select * from #VickyTest
    where Column1=1
    END
    IF @ReportTypeName ='Test2'
    BEGIN
    select * from #VickyTest
    where Column1=2
    END
    GO
    3. I recommend you to not use the temp table and you will not need to add the create and insert statement in the stored procedure.
    4. If you still got no data, please try to click the "Refresh fields" as below:
    If you still have any problem, please feel free to ask.
    Regards,
    Vicky Liu
    Vicky Liu
    TechNet Community Support

  • PL/SQL Stored procedures vs C# code.

    Hi All
    We are going to start designing a kind of transactional application with huge volume of data (150 million records per month). Our selected DB engine is Oracle 10.g while C# is selected development language.
    Because of big volume of data performance is one of the most important factors for us, and the technical design should gain the best level of performance.
    What i'm looking for and studing for it is to define which kind of operation shall be done by Stored Procedure which will be written by PL/SQL or by C# classes?
    I don't interested in to handle complicated and complex jobs using PL/SQL stored procedures while the performance really deserve it.

    Hello,
    Well, my philosophy is to leverage the database as much as possible. I have worked with applications that had no "select", "insert", "update" or "delete" statements in them. Instead, stored procedures and functions inside of PL/SQL packages and bodies were used. Some people will argue strongly against that, but I belong to the "thick database" group rather than the "the database is just a persistence layer that I have to deal with" group. To me it makes sense to co-locate the code that works on the data with the data. If you are working with large volumes of data, I find the bulk operations available via PL/SQL to be very handy.
    Here's an AskTom thread that deals with this general issue:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:12083187196917
    Whilst the thread is primarily about Java, you can substitute just about any other language and the meaning will still carry over.
    Regards,
    Mark

  • Added new parm to an existing SQL stored procedure CR 11 doesn't like it

    Hi
    I have added a new parameter to an existing SQL stored procedure (SQL 2000).  This stored procedure is currently being called from a Crystal XI report.  It prompts for a date which works great.  (The report was created with this parameter).  I added a new parameter to the stored procedure.  When I do a preview in Crystal, it prompts for the new parameter, but is NULL when I look at the SQL query and it brings back no data.  If I try to verify the database, it tells me that I am missing parameter @ProcessType (varchar(5))--(name of new parameter).  I have physically added this parameter to the crystal report with the select expert and still no luck.  I have already tried renaming the procedure but am unable to update datasource location because of this parameter.  The report is very detailed and I do NOT want to create a new report.

    Unfortunately, I have tried and retried to do this.  Nothing changes.  I usually would get a message like database has changed, proceeding to fix report.  I don't get this.  It merely tells me database is up to date and only returns the 1 parameter, yet when I go to the datasouce and try to update it, it tells me that I have not supplied the new parameter.
    I have tried everything, from closing Crystal reports and then going so far as to reboot my machine, just in case their was some kind of caching going on.
    I have even asked other people I work with to look at it to make sure I am not doing something dumb...

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • Creating XML report using PL/SQL Stored Procedure

    Hi Friends,
    I am working on an xml report with the xml source as PL/SQL Stored Procedure.
    I am referring the exercise shown in the following link to understand the process:
       http://orclapp.blogspot.com/2012/02/developing-xml-publisher-report-using.html
    In the example shown in the above link I could not understand the following:
    1) In the following procedure, the out parameter 'retcode' is not used at all.
       What is the importance of this parameter.
        PROCEDURE REPORT (errbuf  OUT VARCHAR2, retcode  OUT VARCHAR2, p_product_id   IN     NUMBER)
    2)  After the xml data is prepared and put to 'l_result' Clob variable, the following
        Loop is executed. I am not able to appreciate why the following loop is required.
         LOOP
             EXIT WHEN l_length = l_retrieved;
             IF (l_length - l_retrieved) < 32000
             THEN
                SELECT SUBSTR (l_result, l_retrieved + 1) INTO l_xmlstr FROM DUAL;
                l_retrieved := l_length;
                fnd_file.put_line (fnd_file.output, l_xmlstr);
             ELSE
                SELECT SUBSTR (l_result, l_retrieved + 1, l_offset)
                  INTO l_xmlstr
                  FROM DUAL;
                l_retrieved := l_retrieved + l_offset;
                fnd_file.put_line (fnd_file.output, l_xmlstr);
             END IF;
         END LOOP;
    3) In the example it is not explained how the concurrent program gets the xml data?
       I assume it is written to a file using the following line of code:
        fnd_file.put_line (fnd_file.output, l_xmlstr);
       I would appreciate if anyone can throw some light into my above queries so that I can understand the process clearly.
    Thanks & Regards
    Hawker

    Hi 32000 in the code is a 'safe' size smaller than the max available 32767, the loops purpose is to move through the entire thing in chunks that will be manageable in the limits of the data type.
    Btw; if you are in Oracle e-business suite then you can also use Oracle reports very simply to create XML output.
    If you have reports developer all you need to do is put raw sql (without any 'artifice' to create XML) in the report SQL and then set the reports output to XML in the program definition in Oracle e-business.
    best regards,
    Robert.

  • How to send a Varying Array param to a PL/SQL Stored Procedure from Java

    * I am VERY new to jdbc, and even somewhat new to Java
    * I'm using Java 1.5, Oracle 10g.
    * I need to call the following PL/SQL Stored Procedure from Java:
    procedure setEventStatus
    i_deQueueStatus in deQueueStatus_type
    *deQueueStatus_type is the following (an array of deQueueStatus_OBJ):
    CREATE OR REPLACE TYPE deQueueStatus_OBJ as object
    eventID number (20),
    dequeuestatus varchar2(20)
    CREATE OR REPLACE TYPE deQueueStatus_TYPE IS VARYING ARRAY(500) of deQueueStatus_obj
    *I have created a Java object as follows:
    public class EventQueueDeQueueStatus
         long      eventID;
         String      dequeueStatus;
         EventQueueDeQueueStatus(long eventID, String dequeueStatus)
              this.eventID = eventID;
              this.dequeueStatus = dequeueStatus;
    I have an ArrayList of these.
    I need to pass this list to the Stored Procedure. How do I create a java.sql.Array so I can call CallableStatement.setArray to set the parameter? Or do I use something else? I have tried setObject with both the ArrayList and also with a primitive array, but got "Invalid Column Type" both times.
    Any help would be greatly appreciated. I just got this task today, and I have to make it work by Tuesday :-( !
    Thanks,
    Kathy

    Kathy,
    Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    Good Luck,
    Avi.

  • Executing a shell script from pl/sql stored procedure

    Hi,
    I have Oracle 8i on HP-UX.
    I am passing a shell script name as a parameter to a user defined function from a pl/sql stored procedure. This user defined function has insterface to a user defined Java class file in Aurora java virtual machine which is written using runtime class which can execute any OS command or any shell script. I am getting any OS command run successfully, but could not run my own shell script. It's is not getting environment variables of my own, so not getting executed. So please suggest how can get these env variables in my shell script and also suggest other sucurity concerns to be taken into consideration.
    If you have any questions please let me know.
    This is really a very urgent issue.....
    Please help me.
    Thanks
    Srinivasa Rao Kolla

    Your best bet is to use the dbms_pipe builtin package to send the command to the host

  • APEX - accepting OUT variable values from PL/SQL Stored Procedure

    I have created a page (Form) which is accepting values text fields.
    In the Page Processing section under Processing, I am passing the values to a PL/SQL Stored Procedure, which acts like an API. The procedure contains code to validate the entered data and finally insert the data into the base tables. The procedure also contains OUT variables in the parameter that would return status of processing and any error messages.
    Now, my question is, how can I make the page accept these OUT variables from the procedure. What I wish to do is, to capture these messages/processing status from the procedure in the page. For example, if there is a error in the data and the procedure is sending this message in the OUT variable, I need this to be displayed on the page as an error message.
    Is this possible in APEX?
    Regards,
    Santhosh Jose

    Hi VC,
    I just tried putting the string directly instead of the variable. Its still not giving me the expected results.
    HOWEVER, I think the reason was because of the EXCEPTION block in my code. I have an EXCEPTION block to handle exceptions. I commented the WHEN OTHERS section and now the error message is coming on the page.
    So what I have done now is as follows: At the point at which the error is expected, I am raising a handled exception. And within the exception handling, I am giving RAISE_APPLICATION_ERROR.
    WHEN ex_main_error*
    THEN*
    p_status := 2;*
    p_msg := 'ERROR Stage: '||lc_err_stage||' ERROR Message: '||lc_err_msg;*
    RAISE_APPLICATION_ERROR (-20001, p_msg);*
    This is working now! Which is very good news. Thanks once again for your help!
    Regards,
    Santhosh Jose

  • How to create an External Content Type with SQL Stored Procedures Parameters and query it in a SharePoint App

    Hi,
    I'm new to SharePoint 2013 I want to be able to query a MSSQL database from a SharePoint App I have tried to create an External Content Type (ECT) which is produced from a MSSQL stored Procedure, this procedure has several parameters which are needed to
    filter the data correctly.  From here I want to produce an external list which I can then query from a c# SharePoint app.  If I leave the filters in the ECT null then the list is of course empty or if enter a default values the results are limited
    for the app to query so are no good.
    I want to dynamically pass values to the ECT when querying from the app, is this not possible.  Should I just be returning everything in an external list and then letting the query in the app filter the data, this seems inefficient?
    Is this the best way to do this or should I be doing this differently?
    Please can someone point me in the right direction.
    Thanks

    Hi Pandra801,
    When you create a the external content type, please try to add a filter based on your select statement.
    http://arsalkhatri.wordpress.com/2012/01/07/external-list-with-bcs-search-filters-finders/
    Or, try to create a stored procedure based on your select statement, then create ECT using the SQL stored procedure.
    A step by step guide in designing BCS entities by using a SQL stored procedure
    http://blogs.msdn.com/b/sharepointdev/archive/2011/02/10/173-a-step-by-step-guide-in-designing-bcs-entities-by-using-a-sql-stored-procedure.aspx
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Help on writing pl/sql stored procedure to accept input in xml format

    Hi All,
    I need to write a pl.sql stored procedure which would be getting the input as an xml.
    The requirement is that xml data recieved in below fashion needs to be inserted to 3 different tables.
    The tags under the root node directly needs to be inserted into Table1
    The tags under the first element of the root node needs to be inserted into Table2
    Can anybody help me on how to write a stored procedure which could take up the below xml as input and insert the data received into 3 different tables.
    Any sample code.pointers to achieve this could be of great help.
    The structure of the xml would be as follows:
    <AssemblyProduct>
    <AssemblyHeader>
    <Name></Name>
    <AssemblyId></AssemblyId>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    </AssemblyHeader>
    <AssemblyHeader>
    <Name></Name>
    <AssemblyId></AssemblyId>
    </AssemblyHeader>
    <AssemblyHeader></AssemblyHeader>
    <ApplicationId></ApplicationId>
    <ApplicationName></ApplicationName>
    <ApplicationValidFrom></ApplicationValidFrom>
    <ApplicationValidTo></ApplicationValidTo>
    </AssemblyProduct>

    Well you could write your procedure to accept a parameter of XMLTYPE datatype and then use that value in a query inside the procedure to break the data up as required using something like XMLTABLE e.g.
    -- Nested repeating groups example:
    WITH t as (select XMLTYPE('
    <RECSET>
      <REC>
        <COUNTRY>1</COUNTRY>
        <POINT>1800</POINT>
        <USER_INFO>
          <USER_ID>1</USER_ID>
          <TARGET>28</TARGET>
          <STATE>6</STATE>
          <TASK>12</TASK>
        </USER_INFO>
        <USER_INFO>
          <USER_ID>5</USER_ID>
          <TARGET>19</TARGET>
          <STATE>1</STATE>
          <TASK>90</TASK>
        </USER_INFO>
      </REC>
      <REC>
        <COUNTRY>2</COUNTRY>
        <POINT>2400</POINT>
        <USER_INFO>
          <USER_ID>3</USER_ID>
          <TARGET>14</TARGET>
          <STATE>7</STATE>
          <TASK>5</TASK>
        </USER_INFO>
      </REC>
    </RECSET>') as xml from dual)
    -- END OF TEST DATA
    select x.country, x.point, y.user_id, y.target, y.state, y.task
    from t
        ,XMLTABLE('/RECSET/REC'
                  PASSING t.xml
                  COLUMNS country NUMBER PATH '/REC/COUNTRY'
                         ,point   NUMBER PATH '/REC/POINT'
                         ,user_info XMLTYPE PATH '/REC/*'
                 ) x
        ,XMLTABLE('/USER_INFO'
                  PASSING x.user_info
                  COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
                         ,target  NUMBER PATH '/USER_INFO/TARGET'
                         ,state   NUMBER PATH '/USER_INFO/STATE'
                         ,task    NUMBER PATH '/USER_INFO/TASK'
                 ) y
       COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
             1       1800          1         28          6         12
             1       1800          5         19          1         90
             2       2400          3         14          7          5And then you can extract and insert whatever parts you want into whatever tables as part of the procedure.

  • How to write a PL/SQL stored procedure in Oracle to call Webservice

    Can any one pelase send me a code on how to write a PL/SQL stored procedure in Oracle database to call the Webservice ?
    Thanks,
    Rajesh

    Were you able to solve this problem

  • How to call pl/sql stored procedure in JDBC query dialogbox

    Hi,
    how to call pl/sql stored procedure in JDBC query dialogbox(reports 9i) .
    Cheers,
    Raghu

    please refer : Re: problem If you have more doubts, please ask in that question.

  • How to call PL/SQL stored procedure using ODBC?

    Could anyone tell me how can I call PL/SQL stored procedure using
    ODBC? Are there any sample codes?
    Thanx!
    null

    You are correct on all counts, they all should work.
    Oracle Product Development Team wrote:
    : Hi,
    : I don't know the exact syntax in ODBC, but reasoning by analogy
    : with other API's, I'd bet one of the following works
    : (for a call to: procedure my_proc(n1 number, n2 number);):
    : "{ my_proc(1,2); }"
    : "{ call my_proc(1,2); }"
    : "{ begin my_proc(1,2); end }"
    : "begin my_proc(1,2); end;"
    : "begin my_proc(1,2); end"
    : Hope this helps. - Pierre
    : jiangbuf (guest) wrote:
    : : Could anyone tell me how can I call PL/SQL stored procedure
    : using
    : : ODBC? Are there any sample codes?
    : : Thanx!
    : Oracle Technology Network
    : http://technet.oracle.com
    null

Maybe you are looking for

  • SOLVED (8i): missing symbols in libclntsh

    To all of you out there with the problem of missing symbols in libclntsh.so.8.0: a) for some people it works immediately after installation, so it looks like the installation program doesn't produce that error all the time b) if you're one of those w

  • Deleting existing  record from the oracle

    My sender is a proxy,there is one field here which changes say cfield.Xi doesnot send some records if the change field status is 0 or 1 or 2,for other records it sends data to to the JDBC Receiver.When the Sender Cfield status changes from 0 or 1 or

  • Fullscreen thumbnail size

    When I went to the fullscreen editing mode, I made it so that I could scroll through 3 rows of pictures. But when I put the setting back the the default 1 row, the size of the thumbnails remained small. Is there any way that I can make them return to

  • Table Row Height Search Help

    Hello, I have a massive CS5 catalog file with tons of tables. All the data rows are to be 0.15 inches in height, but sometimes I find rows with heights a wee bit less or more than that. How can I do a search to find which rows do not equal 0.15 inche

  • Trouble with video media

    I've had a lot of problems for about a week viewing Youtube type video media. I'm not sophisticated enough to know what this type is called, but I just get a blank white or black space where the video should be. My computer is totally up to date, and