About stored procedures

whenever i write a stored procedure in Oracle8.0.5 i get procedure created with compilation erros..what does this mean? any logs where i can see what errors exatly have occured? how to check if the procedure has been created at all or not....
my procedure looks like ...
CREATE OR REPLACE PROCEDURE DEL_LOGIN_ID (uid IN Varchar2(20)) IS
BEGIN
     delete lst_pg where login_id :=uid;
     delete user_track where login_id :=uid;
     delete hrspent where login_id := uid;
     delete bookmark where login_id := uid;
     delete user_task where login_id := uid;
     delete user_sugg where login_id := uid;
     delete userinfo where login_id := uid;
END;
and i call it using
call del_login_id(666)

hi Gunjan
if you look at your code
CREATE OR REPLACE PROCEDURE DEL_LOGIN_ID (uid IN Varchar2(20)) IS
BEGIN
delete lst_pg where login_id :=uid;
delete user_track where login_id :=uid;
delete hrspent where login_id := uid;
delete bookmark where login_id := uid;
delete user_task where login_id := uid;
delete user_sugg where login_id := uid;
delete userinfo where login_id := uid;
END;
you are specifying the command wrongly.
" login_id := uid "
you should give as
login_id = uid
the former statement is called assignment . you should not do
that operation at that place.
correct your statements and then recompile your procedure.
your procedure is very fine excepting that " := " operator.
replace them with " = " . thats all.
Secondly
Delete statement is specifically meant for deletion of records
from table only. Since Table is the only unit of data storage
in oracle . even though you can execute delete command against
a view but inturn it is executed on the base table only.
You can use any of the delete statements
DELETE table1;
or
DELETE FROM table1;
both will work .
Try that
all the best
[email protected]

Similar Messages

  • Documentation about Stored Procedure in SBO

    Hi experts,
    I need some documentation about the how to use of Stored Procedured in SBO, what is valid and what is not valid for SAP. I want to know If only Execute SP from SBO, but no INSERT, DELETE or UPDATE in any SBO database table is valid for Support SAP??
    Thanks.

    Hi,
    You can refer to Note No. [ 896891|https://websmp130.sap-ag.de/sap(bD1odSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=896891] regarding the Support Scope.
    You can check the link mentioned in the following thread
    Re: Tracking Opportunity
    Regards,
    Jitin
    SAP Business One Forum Team

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • PHP / MySQL / Stored Procedures

    I'm trying to call a stored procedure on my site which uses
    php / mySQL 5.x. I've got the procedure working in the database so
    that when I call it from within a MySQL client it executes and
    returns the results I need, but Dreamweaver doesn't even "see" the
    stored procedure.
    By this I mean If I use the recordset wizard, go to advanced,
    select the relevant database and then expand the Stored Procedures
    tab none are listed.
    Searching through Adobe help, it lists nothing about Stored
    Procedures with PHP/MySQL apart from that MySQL doesn't support
    them. The later versions of MySQL do support Stored Procedures, but
    has anyone got them working with Dreamweaver? If so how!??!!
    Any help much appreciated.

    Talk Rowing wrote:
    > Well thanks for setting me straight - even if you are
    the bearer of bad news.
    > I've filed a feature request as you suggested. Can't
    believe Adobe don't offer
    > this.
    Stored procedures have been available in MySQL only since
    version 5.0,
    which was released in October 2005, one month after
    Dreamweaver 8. It
    would have been nice to include support for stored procedures
    in CS3,
    but no new functionality was added to any of the server-side
    features of
    Dreamweaver. I have my fingers crossed for next time.
    > On another note I don't suppose you could point me in
    the direction of some
    > tutorials on how to create a recordset from a stored
    procedure manually? I've
    > tried google and not come across a lot...
    My server doesn't support MySQL 5.0, so apart from the
    information in
    the MySQL documentation, I don't know a great deal about
    using stored
    procedures:
    http://dev.mysql.com/doc/refman/5.0/en/stored-procedures.html
    One of the problems is that many hosting companies are still
    using older
    versions of MySQL (a lot still offer only 3.23). I'm
    currently in the
    process of moving to a new server with support for both PHP 5
    and MySQL
    5.0. Once I've had time to experiment, I hope to know a lot
    more.
    David Powers, Adobe Community Expert
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Adding a stored Procedure to the Report

    Hi,
    I am developing a report using crystal plugin in eclipse.I have problems in adding a stored procedure to the report .I write the following command in SQL SCRAPBOOK dbo.StoredProcedure @Param1="param1",@Param2="param2",@Param3="None" and run it. It runs successfully ,but when i try to add it to report nothing is being added to it.
    I am using a Sybase database and driver(com.sybase.jdbc3.jdbc.SybXADataSource)
    Any suggestions regarding this would be of great help.
    Thanks in advance
    Siva
    Edited by: Siva_velicheti on Jun 1, 2010 12:10 PM

    Hmm, not sure about stored procedures, but you can get SQL queries to work like below....
    @method to get ResultSet from SQL query with user, pwd, and dbConnectionInfo
    @param query, scrollType, user, password, dbName, db
    @throws SQLException 
    @throws ClassNotFoundException
             private static ResultSet getResultSetQueryDBInfo(String query, int scrollType, String user, String password, String dbName, String db)
             throws SQLException, ClassNotFoundException
                  String DBUSERNAME =  user;
                  final String DBPASSWORD = password;
                  final String CONNECTION_URL = "jdbc:oracle:thin:@" + dbName + ":1521:" + db;
                  Connection connection = DriverManager.getConnection(CONNECTION_URL, DBUSERNAME, DBPASSWORD);
                  DatabaseMetaData meta = connection.getMetaData();
                  System.out.println("getResultSetQueryDBInfo - Connected to URL : " + meta.getURL());
                  System.out.printf("getResultSetQueryDBInfo - as user: %s\n", meta.getUserName() );
                  Statement statement = connection.createStatement(scrollType, ResultSet.CONCUR_READ_ONLY);
                  System.out.println("getResultSetQueryDBInfo method - executing query: \n");
                  return statement.executeQuery(query);

  • Stored procedures - when to use?

    Hello
    I'm a self-taught ASP developer who never found out about
    stored procedures until recently. I've got a hacker trying to put
    me out of business, livelihood, psychological health etc. by
    repeatedly attacking my database with SQL injections. So I have
    thousands of pages on 30 websites to go through and recode, using
    SPs.
    An easy - and probably stupid question - do I need to use SPs
    when there is no user variable involved? i.e. I know they're
    required when I want to
    "SELECT Field FROM Table WHERE ID =" &
    Request("Variable")
    But is the following format OK, or should it be converted to
    an SP too?
    "SELECT Field FROM Table "
    Thanks for any guidance!
    Square

    > An easy - and probably stupid question - do I need to
    use SPs when there
    > is no
    > user variable involved? i.e. I know they're required
    when I want to
    The basic premise of SQL injection is that it takes end-user
    inputted
    strings and sends it directly to SQL.
    NEVER trust your end users. ;o)
    So, in the example you gave, you're not grabbing any
    user-created strings
    and passing it along, so no, one can't SQL inject that.
    You can avoid SQL injection without SPs, but it takes a lot
    of work. You
    need to filter all user input first to ensure it is 'clean'
    of malicious
    code, and then pass it on. It's usually easier to just use
    SPs, so that's
    usually the stock answer.
    -Darrel

  • Ask about UTL_FILE in Stored Procedure

    Hi
    I was trying to do an insert in a table which then trigger a stored procedure to write the inserted data to a text file. However, I have some issues here in the Stored Procedure. Thanks for trying to help... [Insert -> Table -> Trigger -> Stored Procedure -> Text File]
    ----User will execute this sql
    ----insert into tester.test_table values ('ab');
    CREATE TABLE TESTER.TEST_TABLE
      LINECODE  VARCHAR2(2 BYTE)
    ----Just for testing purpose
    CREATE TABLE TESTER.TEST_REC_TABLE
      LINECODE  VARCHAR2(2 BYTE)
    CREATE OR REPLACE TRIGGER TESTER.TRIGGER_AUDIT
    AFTER INSERT OR UPDATE
    ON TESTER.TEST_TABLE REFERENCING OLD AS OLD NEW AS NEW
    FOR EACH ROW
    DECLARE
      sLineCode VARCHAR2(2);
    BEGIN
       sLineCode := '';
        IF UPDATING THEN     
          sLineCode := :NEW.LINECODE;
          TRIGGER_PACKAGE.WRITE_FILE(sLineCode);
        END IF;  
        IF INSERTING THEN
          sLineCode := :NEW.LineCode;
          TRIGGER_PACKAGE.WRITE_FILE(sLineCode);
        END IF;
    EXCEPTION
        WHEN others then null;
    END TRIGGER_AUDIT;
    CREATE OR REPLACE PACKAGE BODY TESTER.TRIGGER_PACKAGE
    is
       procedure WRITE_FILE(in_LineCode in varchar2)
       is
         sLineCode varchar2(2);  
         v_FileHandle UTL_FILE.FILE_TYPE;
    ----some checking of the input data for NULL 
       begin  
        if ((rtrim(in_LineCode) IS NULL) or (in_LineCode is null)) then
            sLineCode := 'XX';
        else
            sLineCode := in_LineCode;          -------->PROBLEM HERE?
        end if;
        if (length(sLineCode) > 2) then
          sLineCode := substr(sLineCode,1,2);
        end if;
        Insert into TEST_REC_TABLE (LineCode) values (sLineCode); ----insert data to another table for testing
        EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY FILEDIR AS ' || '''' || 'c:\' || '''';
        v_FileHandle := UTL_FILE.FOPEN('FILEDIR','Test_Table.txt','w'); ----write to text file in C:\Test_Table.txt
        UTL_FILE.PUT_LINE(v_FileHandle, 'Inserted ' || sLineCode || ' @ ' || TO_CHAR(SYSDATE,'DD-MM-YYYY HH:MI:SS AM'));
        UTL_FILE.FCLOSE(v_FileHandle);           
       exception
          when others then null;
       end;
    end TRIGGER_PACKAGE;
    1) The problem I faced is that when I perform INSERT sql for the new data, it can be successfully be inserted into both tables TEST_REC_TABLE and TEST_TABLE, but it just does not write to the text file.
    2) However, when I just execute the procedure I will get XX for the input data as it is NULL. This XX data will then be seen in TEST_REC_TABLE as "XX" record and Test_Table.txt as "Inserted XX @ 10-01-2014 04:56:06 PM". UTL_FILE did write to textfile so my guess is that it could be due to my poor understanding of logic in the checking of the input data for NULL. Tried but I am still clueless, thanks for pointing out the issue.

    > 1) I'm just testing and learning here with trigger insert...
    Good. In that case its just a wrong choice that you have decided to write to a file from trigger. Oracle base is a good site. They have examples too. Please check that ORACLE-BASE - Database Triggers Overview.
    > 2) How should I do then?
    Just create the object one time
    CREATE OR REPLACE DIRECTORY FILEDIR AS <path>
    The path should be a location in your server where oracle is installed.
    > 3) How should I do then? Use this ?
    EXCEPTION
          WHEN OTHERS THEN
               DBMS_OUTPUT.PUT_LINE
                    ('ERROR ' || TO_CHAR(SQLCODE) || SQLERRM);
               NULL;
    Don't do any thing. Just remove the exception handling. Don't handle unknown exceptions. If at all you want to handle them for logging purpose RAISE it at the end like this.
    exception
      when others then
        <log your messages>
        raise;
    And about exception handling one of the forum member BluShadow has written a nice article PL/SQL 101 : Exception Handling. That would be a nice read.

  • How to call stored procedure from javascript? (about Google Suggest, AJAX)

    Hi I want to implement a text field so that it behaves like [Google Suggest|http://www.google.com/webhp?complete=1&hl=en] .
    I read this post .
    Now I've setup everything according to that document. But it just doesn't work. And I don't know why.
    I think problems may fall into the following three categories:
    1. Does the text field and the page invoke the proper javascript?
    2. Does the javascript successfully call the stored procedure?
    3. Can the stored procedure correctly return the formatted result?
    I am affirmative for 1 and 3, but I'm not sure about 2. Because I don't know how to tell if a stored procedure has been called? Is there a PL/SQL statement that I can query in SQL*Plus?
    Also, I would to know how to debug AJAX in APEX. It involves many things.
    Last, I used APEX 3.2 and Oracle XE. I cannot find either dads.conf or marvel.conf file. Is "/apex/" the virtual directory for APEX?
    Thanks a lot!

    Hello,
    I recently also ran into problems with this and I will post my solution here:
    1) if you need to pass parameters to your procedure, create it using "Flexible Parameter Passing". Then parse the parameters out of the array and put them in local variables inside your PL/SQL procedure.
    Example:
    CREATE OR REPLACE PROCEDURE MATTHIASH.incsearch(name_array IN owa.vc_arr,
         value_array IN owa.vc_arr) as
      l_List1 varchar2(4000);
      l_List2 varchar2(4000);
      l_query varchar2(255);
      l_separator varchar2(10) default '';
      qu varchar2(4000) default '';
      hl varchar2(4000) default '';
    BEGIN
      FOR i IN 1 .. name_array.COUNT 
      LOOP
           IF name_array(i) = 'qu' THEN
                qu := value_array(i);
           ELSIF name_array(i) = 'hl' THEN
                hl := value_array(i);
           END IF;
      END LOOP;
      l_query := qu||'%';
      FOR x IN (
      select object_name, object_id from user_objects
      where upper(object_name) like upper(l_query) and upper(object_type) = upper(hl) order by 1 asc)
      LOOP
        l_list1 := l_List1 || l_separator || '"' || x.object_name || '"';
        l_list2 := l_List2 || l_separator || '"' || x.object_id || '"';
        l_separator := ',';
      END LOOP;
      owa_util.mime_header('text/html', false);
      owa_util.http_header_close;
      --htp.p('sendRPCDone(frameElement, "'|| qu ||'", new Array(' || l_List1 || '), new Array(' || l_List2 || '), new Array(""));');
      htp.p('sendRPCDone(frameElement, "' || qu || '", new Array(' || l_List1 || '), new Array(' || l_List2 || '), new Array(""));');
    END;
    /2) grant EXECUTE rights to APEX_PUBLIC_USER (the user APEX uses to connect to the database) on the procedure
    grant execute on incsearch to apex_public_user;3) upload the ac.js file as static file to your application
    4) put the following javascript code in the HTML Header of your APEX page:
    <script src="#WORKSPACE_IMAGES#ac.js" type="text/javascript"></script>
    <script language="JavaScript" type="text/javascript">
    function iac()
    InstallAC(document.wwv_flow,document.getElementById('P1_X'),"","!MATTHIASH.incsearch","&P1_OBJECT_TYPE.");
    </script>In my example, P1_X is a text field and P1_OBJECT_TYPE is a dropdown list with all user object types.
    Good luck,
    Matthias Hoys

  • About BC4j and java stored procedure

    Is it possible create a java stored procedure using BC4j and deploy to Oracle9iR2 VM?
    If it is possible, how about the performance compare to PL/SQL stored procedure?

    In 9.0.3.3 it will be possible again. The ability to deploy a BC4J-based, local-mode Java Stored Procedure was broken in 9.0.3 before this upcoming maintenance release.
    PL/SQL will almost surely be faster if you are talking about just doing basic DML type of operations, when compared to Java stored procedures.

  • Howto get information about Java Stored Procedures programmaticly

    Hi all,
    using the DatabaseMetaData object it is easily possible to get information about database objects like tables, columns or even plsql stored procedures.
    But is there a way to get information about Java Stored Procedures which are published in packages ? Is it possible here to use a DatabaseMetaData object or is there any other solution ?
    TIA,
    Chris

    What sort of information do you want to know about the Java stored procedures?
    Would the views USER_SOURCE or USER_OBJECTS contain the information you need?

  • Question about one stored procedure and a few entity objects

    There are few EOs in the project. At the same time there is a single stored procedure that has to be used for data modification.
    This procedure updates db tables that are mapped to these EOs. How do I implement doDML operation in this case?
    I have to call stored procedure from a single main EO, and disable data modification in the rest of EOs. Is it possible?
    If so, how do I pass parameters from other EOs, because in a doDML method i have a scope of this particular EO attributes, and do not have acces to the attributes of other EOs?
    Thanks!

    I am not sure with imovie since I use only Final Cut Pro. iDVD setting will let you expand the file for length. Naturaly the best quality pr performance will take less time of a file. In the case with iDVD 4 the best quality will only take 60 minutes of video already compressed. Best performance will take up to about 1 hour nd 49 minutes. You have to leave enough room for the menu to take up some space on the disc as well. In FCP we have to export as a quicktime file where with a 1 hour 30 min video can take about 20 minutes to export. the burning and compression time depends on the system you have. G5 faster, G4 like mine takes longer. on that same video idvd 4 will take about 3 hours to convert and burn the disc. When I use DVD Pro Studio that is way different and take a lot longer. I have had a typical 2 hour video take up to 14 hours to convert/export to a MPEG 2 format or DVD format. But the burning process take about an hour. It all depends on your equipment.
    Hope that helps.

  • Question about MySQL, JDBC, SQLJ, Stored procedure & callable statements

    Hi, there. I'm using j2sdk1.4.1_01 and MySQL ver 12.18 Distrib 4.0.12, and when I try to install a store procedure, it throws the following message:
    SQLException: Stored procedures not supported: {call sqlj.install_jar('blah...blah...MyProject-20031206.jar', 'routines_jar', 0)}
    Who's is not supporting store procedures here? Java or MySQL? What can I do?
    The book and sample code I'm using as a reference mention that "the sample code assumes that the DBMS already stores the built-in SQLJ procedure sqlj.install_jar, which loads a set of classes written in the Java programming language in an SQL system". Now my question is: the "SQLJ procedure sqlj.install_jar" is something extra that I need to install or it has nothing to do with the problem?
    Is it true that MySQL does not support stored procedures? Thank you in advance for any hint or suggestion.
    Regards,
    Hector.

    Who's is not supporting store procedures here? Java or
    MySQL?MySQL.
    What can I do?1. Don't use stored procedures.
    2. Use a database that supports stored procedures.
    3. Wait for the release of MySQL that does support stored procedures.

  • A Question about Delphi Call stored procedure??

    Hi! I use Delphi to develop a 3-tied application.and i write a stored procedure to insert data.If I use BDE to derectly to invoke this stored procedure ,it can insert data in proper. But in 3-tied Application, when I invoke the stored procedure though application server(middle-tied),Application Raise Error."ORA-06502:PL/SQL:numeric or value error:Character string buffer too small ora-06512:at "sfis1.insert_cpk_record" line 92,ora-06502:PL/SQL: numeric or value error:Character string buffer too small ora-06512 at line 1" .Please help me.It's urgent.

    It's impossible to say without seeing the source of the procedure, but on line 92, there is an assignment made to a string variable that is sized too small for the value.
    Something like:
    is
      v_variable varchar2(2);
    begin
      v_variable := 'ABC';
    end;Is it possible that the middle tier is passing in a parameter value that is longer than you expect? We could comment further if you can post the PL/SQL code.
    You might also throw in some debugging code to compare the parameter values between the BDE and middle tier calls.

  • 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

  • How can i run an OS command in a stored procedure?

    Hi, I'm creating a stored procedure in which I need to copy a file from one directory to another.
    I know that in Forms, this can be done with the "host" function, but it doesn't work in the stored procedure.
    I read something in a forum about using the DBMS_SCHEDULER, with a sentence like this:
    DBMS_SCHEDULER.CREATE_PROGRAM('OS_Command', 'EXECUTABLE', v_command, 0, TRUE );
    where v_command is a string containing the cp command I need to execute.
    Would this be correct? And would this sentence be enough for the command to be executed instantly?
    Thanks in advance,
    Jorge

    http://www.oracle.com/technetwork/database/enterprise-edition/calling-shell-commands-from-plsql-1-1-129519.pdf

Maybe you are looking for