Stored Procedure Contents Getting Deleted Randomly

Has anyone had any experience with the contents of a stored procedure getting deleted?  The object is still visible in object explorer, but when you go to modify the contents it is empty.
I just started at a new place and trying to clean up and improve their environment.  It was brought to my attention that a certain report that was being ran should have returned some results, but instead
was just returning a blank report.  While researching the problem, I backtracked to the stored procedure on the server and discovered that the definition of that object was completely blank.  Had to go back to a restore to get the definition.
This is at least the second time this quarter, but a different procedure.  What could be causing this?
Thanks!
SQL Server 2005 Standard Edition
Windows Server 2003 R2 Service Pack 2

I don't think any known situation where SP is getting modified by emptying the contents. 
Can you troubleshoot and find when it was modified?
SELECT LAST_DDL_TIME, TIMESTAMP
FROM USER_OBJECTS
WHERE OBJECT_TYPE = 'PROCEDURE'
AND OBJECT_NAME = 'MY_PROC';
And try to see if you'll be able to find anything from the trace but the information is kept only in 5 files
DECLARE @filename VARCHAR(255)
SELECT @FileName = SUBSTRING(path, 0, LEN(path)-CHARINDEX('\', REVERSE(path))+1) + '\Log.trc'
FROM sys.traces
WHERE is_default = 1;
SELECT gt.HostName,
gt.ApplicationName,
gt.NTUserName,
gt.NTDomainName,
gt.LoginName,
gt.SPID,
gt.EventClass,
te.Name AS EventName,
gt.EventSubClass,
gt.TEXTData,
gt.StartTime,
gt.EndTime,
gt.ObjectName,
gt.DatabaseName,
gt.FileName,
gt.IsSystem
FROM [fn_trace_gettable](@filename, DEFAULT) gt
JOIN sys.trace_events te ON gt.EventClass = te.trace_event_id
WHERE EventClass in (164)
ORDER BY StartTime DESC;
--Prashanth

Similar Messages

  • Stored procedure for getting host name, host instance and status of that host is it running or stopped.

    Hello all,
    yesterday I got one task in that I have to stored procedure for getting host name, host instance and status of that host is it running or stopped.
    any body knows where exactly, In which table this details are there in BizTalk databases.
    thanks

    Status of the host instance is not stored in the SQL database for you to query the status using stored procedure. You have to either use Powershell or WMI to get the status.
    In SQL, following table contains the details about the host like Name, LoginName, IsDisables etc but status of the host instance is not stored in the database.
    SELECT * FROM BizTalkMgmtDb..adm_HostInstance
    Powershell to get the status:
    http://axonolympus.nl/?page_id=186&post_id=969&cat_id=6&lang=en
    WMI to get the status:
    https://msdn.microsoft.com/en-us/library/aa561820.aspx?f=255&MSPPError=-2147217396
    https://msdn.microsoft.com/en-us/library/aa578621.aspx
    Regards,
    M.R.Ashwin Prabhu
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • SCCM 2012 source content gets deleted

    I have been using SCCM 2012 for over a year now and have jsut noticed that all of the content in my original source folders has been deleted. I am trying to redistribute this missing content with no luck, mainly because it doesnt exist anymore.
    I have two questions.
    1. How do I change the cleanup of the source content folder
    2. How do I re-download software updates to redistribute once the source content gets deleted.
    Has anyone else had this problem?

    Perhaps it was this:
    http://blogs.technet.com/b/configmgrteam/archive/2012/04/12/software-update-content-cleanup-in-system-center-2012-configuration-manager.aspx
    Don't retire TechNet! -
    (Maybe there's still a chance for hope, over 11,760+ strong and growing)

  • Help me in calling stored procedure and getting results

    hi
    i have a SP like this
    CREATE OR REPLACE PACKAGE P1 AS
    TYPE g_con_ref_cursor is REF CURSOR ;
    TYPE g_con_error IS RECORD
      error_code NUMBER,
      error_desc varchar2(2000)
    PROCEDURE PROC_CURSOR
    (i_str_userid  IN VARCHAR2,
      o_cur_ref_cur OUT g_con_ref_cursor,
      o_rec_error   OUT g_con_error,
      o_num_status  OUT NUMBER);
    END;
    and i now i am trying to call this SP using my java program
    i am able to register the out put params for 2nd and 4 th variable
    my doubt is how i can register the output param for g_con_errorand how i can get result from this ????
    my java program is like this
    Connection connection = DatabaseHelper.prepareConnection();
    CallableStatement proc = connection.prepareCall("{ call P1.PROC_CURSOR(?, ?, ?, ?) }");
    proc.setString(1,"jn26557");
    proc.registerOutParameter(2,oracle.jdbc.driver.OracleTypes.CURSOR);
    proc.registerOutParameter(3,Types.STRUCT,); //HOW TO SET  THIS ?????
    proc.registerOutParameter(4,oracle.jdbc.driver.OracleTypes.NUMERIC);
    proc.execute();
    plz help me in this
    i have no idea how to do it
    any help would be appreciated
    Thanks in advance
    Jaya Prakash Nalajala

    You have the requirements to build the stored procedure, what have you got so far?
    Post your attempt and any errors or issues that you might be experiencing. Writing the whole procedure for you (without the table structure even) is going to be difficult.

  • Dynamically calling stored procedure and getting result set c++

    Hello,
    I am trying to write some c++ code that will dynamically bind values to a stored procedure and excute the procedure and get back a resultset. The problem I am running into is how to get back the resultset. Any help or example would be highly appreciated.

    int main(int argc, char* argv[])
    OCIError* pOciError;
    char* pConnectChar = "dbname";
    char* pUsernameChar = "scott";
    char* pPasswordChar = "tiger";
    int answer;
    OCIStmt* pOciStatement;
    char* sqlCharArray = "BEGIN :success := sp_ListEmp; END;";
    int id;
    char ename[40];
    OCIEnv* g_pOciEnvironment = NULL;
    OCIServer* g_pOciServer = NULL;
    OCISession* g_pOciSession = NULL;
    OCISvcCtx* g_pOciServiceContext = NULL;
    sb2* pIndicator=0;
    sb2* pIndicator2=0;
    sb2* pIndicator3=0;
    OCIDefine* pOciDefine;
    OCIDefine* pOciDefine2;
    OCIBind* pBind;
    OCIStmt* cursor;
    answer = OCIInitialize(OCI_THREADED, NULL, NULL, NULL, NULL);
    answer = OCIEnvInit(&g_pOciEnvironment, OCI_DEFAULT, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciSession, OCI_HTYPE_SESSION, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServer, OCI_HTYPE_SERVER, 0, NULL);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)&g_pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
    answer = OCIServerAttach(g_pOciServer, pOciError, (unsigned char *)pConnectChar, strlen(pConnectChar),
    OCI_DEFAULT);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pUsernameChar, strlen(pUsernameChar),
    OCI_ATTR_USERNAME, pOciError);
    answer = OCIAttrSet(g_pOciSession, OCI_HTYPE_SESSION, (unsigned char *)pPasswordChar, strlen(pPasswordChar),
    OCI_ATTR_PASSWORD, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciServer, 0, OCI_ATTR_SERVER, pOciError);
    answer = OCIAttrSet(g_pOciServiceContext, OCI_HTYPE_SVCCTX, g_pOciSession, 0, OCI_ATTR_SESSION, pOciError);
    answer = OCISessionBegin(g_pOciServiceContext, pOciError, g_pOciSession, OCI_CRED_RDBMS, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&pOciStatement), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray, strlen(sqlCharArray),
    OCI_NTV_SYNTAX, OCI_DEFAULT);
    answer = OCIHandleAlloc(g_pOciEnvironment, (void **)(&cursor), OCI_HTYPE_STMT, 0, NULL);
    answer = OCIBindByPos(pOciStatement,&pBind, pOciError, 1, &cursor, 0,SQLT_RSET,
    pIndicator2, 0,NULL, 0,0,OCI_DEFAULT);
    answer = OCIStmtExecute(g_pOciServiceContext, pOciStatement, pOciError, 1, 0, NULL, NULL,
    OCI_COMMIT_ON_SUCCESS);
    answer = OCIDefineByPos(cursor,&pOciDefine, pOciError,2,&id,sizeof(int),
    SQLT_INT,pIndicator, 0, 0,OCI_DEFAULT);
    answer = OCIDefineByPos(cursor,&pOciDefine2, pOciError,1,ename,40,
    SQLT_STR,pIndicator3, 0, 0,OCI_DEFAULT);
    if (answer == 0)
    while ((answer = OCIStmtFetch(cursor,pOciError, 1,OCI_FETCH_NEXT,OCI_DEFAULT)) == 0)
    printf("fetched id %d and name %s\n",id,ename);
    answer = OCIHandleFree(pOciError, OCI_HTYPE_ERROR);
    return 0;

  • How to describe a stored procedure contents?

    hi OTN team,
    1) i want to list all the procedures and functions in a schema
    2) i want to see/descrive total procedure, including declarative section, body every thing.
    Oracle 8i and win 2k environemnt.
    Thanks in advance

    I agree it's a bit of a bizarre oversight, given how many views there are, but Oracle does not provide a view of stored procedures. The closest we get is:
    SELECT object_name, object_type
    FROM   all_objects
    WHERE  owner = upper('&SCHEMA_NAME')
    AND    object_type IN ('PROCEDURE', 'FUNCTION', 'PACKAGE')
    /We can use the SQL*Plus DESC(RIBE) command to see just the signature of a stored procedure. To see everything we need to query the USER/ALL/DBA_SOURCE view.
    Cheers, APC

  • Stored Procedure to Get Admin Users and Other Users

    Hey,
    I am new to stored procedures in Oracle and would really appreciate the help! I have two tables:
    Users_
    ID USERNAME - PARENT_GROUP - IS_ADMIN
    1 jsmith - 1 - 0
    2 brogerson - 1 - 1
    3 jloren - 2 - 0
    Groups*
    ID - GROUPNAME
    1 - ITUsers
    2 - AcctUsers
    I would like to create a procedure that accepts a users username and returns every user in their group and the user id, or if the user is marked IS_ADMIN, I want the procedure to return all users in all groups.
    How would I do this? Ideally I would like to funnel the result into a DataGridView in C#.
    Thank you in advance,
    Jeffrey Kevin Pry
    Edited by: jeffrey.pry on May 10, 2010 10:42 AM
    Edited by: jeffrey.pry on May 10, 2010 10:43 AM

    Hi,
    jeffrey.pry wrote:
    ... How could I expand your view (without namespace) to include just the groupname into the list if they are a regular user, or all of the group names in the list if they are an admin?Sorry, I don't understand. I thought that was exactly what the code I posted did.
    Since I don't have versions of your tables, I'll use Scott's tables to illustrate.
    This view does what I think you want:
    CREATE OR REPLACE VIEW  p_users
    AS
    SELECT       u.ename, u.job, u.deptno
    ,       g.dname
    ,       pu.ename   AS p_ename
    FROM       scott.emp     pu
    JOIN       scott.dept     g     ON     pu.deptno     = g.deptno
                          OR     pu.job          = 'MANAGER'
    JOIN       scott.emp     u     ON     u.deptno     = g.deptno
    ;On the rows where p_ename is not the name of a MANAGER (SCOTT, for example), we see only the people who work in the same department (deptn=20, dname='RESEARCH') as p_ename:
    SELECT     *
    FROM     p_users
    WHERE     p_ename     = 'SCOTT'
    ENAME      JOB           DEPTNO DNAME          P_ENAME
    SMITH      CLERK             20 RESEARCH       SCOTT
    JONES      MANAGER           20 RESEARCH       SCOTT
    SCOTT      ANALYST           20 RESEARCH       SCOTT
    ADAMS      CLERK             20 RESEARCH       SCOTT
    FORD       ANALYST           20 RESEARCH       SCOTTBut on the rows where p_ename is a MANAGER (JONES for example) we see everybody, no matter what their department is:
    SELECT     *
    FROM     p_users
    WHERE     p_ename     = 'JONES'
    ENAME      JOB           DEPTNO DNAME          P_ENAME
    SMITH      CLERK             20 RESEARCH       JONES
    ALLEN      SALESMAN          30 SALES          JONES
    WARD       SALESMAN          30 SALES          JONES
    JONES      MANAGER           20 RESEARCH       JONES
    MARTIN     SALESMAN          30 SALES          JONES
    BLAKE      MANAGER           30 SALES          JONES
    CLARK      MANAGER           10 ACCOUNTING     JONES
    SCOTT      ANALYST           20 RESEARCH       JONES
    KING       PRESIDENT         10 ACCOUNTING     JONES
    TURNER     SALESMAN          30 SALES          JONES
    ADAMS      CLERK             20 RESEARCH       JONES
    JAMES      CLERK             30 SALES          JONES
    FORD       ANALYST           20 RESEARCH       JONES
    MILLER     CLERK             10 ACCOUNTING     JONESBy the way, table g is the view is needed only if you want the view to include columns found only in the groups table.
    Otherwise, we can do the self-join directly between two copies of the users table (or scott.emp, as in the example):
    CREATE OR REPLACE VIEW  p_users
    AS
    SELECT       u.ename, u.job, u.deptno
    ,       pu.ename   AS p_ename
    FROM       scott.emp     pu
    JOIN       scott.emp     u     ON     pu.deptno     = u.deptno
                          OR     pu.job          = 'MANAGER'
    ;I hope that answers your question.
    If not, post an example of what you'd like to do. For example
    "I like to have a view such that a query like this:
    SELECT ... FROM p_users WHERE ...
    would produce ...
    but if I change the WHERE clause to ...
    then it would produce ..."
    If you want examples using small versions of your own tables, post CREATE TABLE and INSERT statements so I can create tables like yours.

  • After I add a watermark to my pdf, most of the content gets deleted. How do I prevent this?

    When I tried adding watermarks for other pdfs it worked fine. Just for this particular pdf, it doesn't work properly.

    I tried adding watermarks to other pdfs and they worked fine but for this particular pdf, the watermarks erase all the content affer I add them.

  • Stored Procedure to delete a number of tables with a common name attribute

    Hi All,
    This is my first post so I hope I have posted to the required level with sufficient information. This is my first stored procedure (SP) and is for Oracle 10.
    I am trying to write a script to delete 11 tables and some rows from another 3 tables, all of which are named with a number that I would like to input at the point of creation of the SP. Below is the script I have written and edited. My original has been lost by crashing servers!
    When I run the script it gives me the following output:
    "Warning: execution complete with warning
    procedure ScenarioDelete compiled"
    The SP hasn't deleted any of the tables and I'm not sure if it's because my script is poor or because of something else. Any help is greatly appreciated!!
    -- table delete SP
    -- Run begin ScenarioDelete ('x'); with x as the ScenarioId
    create or replace procedure ScenarioDelete (ScenarioNo IN varchar2);
    countstable := 'C_' || ScenarioNo;
    changetable := 'CG_' || ScenarioNo;
    countsinfotable := 'CI_' || ScenarioNo;
    datatable1 := 'D_0_' || ScenarioNo;
    datatable2 := 'D_1_' || ScenarioNo;
    datatable3 := 'D_2_' || ScenarioNo;
    hietable1 := 'HI_0_' || ScenarioNo;
    hietable2 := 'HI_1_' || ScenarioNo;
    hietable3 := 'HI_2_' || ScenarioNo;
    hielinktable1 := 'HL_1_' || ScenarioNo;
    hielinktable2 := 'HL_2_' || ScenarioNo;
    AS
    execute immediate 'drop table ' || countstable;
    execute immediate 'drop table ' || changetable;
    execute immediate 'drop table ' || countsinfotable;
    execute immediate 'drop table ' || datatable1;
    execute immediate 'drop table ' || datatable2;
    execute immediate 'drop table ' || datatable3;
    execute immediate 'drop table ' || hietable1;
    execute immediate 'drop table ' || hietable2;
    execute immediate 'drop table ' || hietable3;
    execute immediate 'drop table ' || hielinktable1;
    execute immediate 'drop table ' || hielinktable2;
    execute immediate 'delete from USERACESS where SCENARIOID = ' || ScenarioNo;
    execute immediate 'delete from SCENARIO where SCENARIOID = ' || ScenarioNo;
    execute immediate 'delete from SCENARIOINFO where SCENARIOID = ' || ScenarioNo;
    -- or --
    execute immediate 'delete from USERACESS where SCENARIOID = '' || ScenarioNo || ''';
    execute immediate 'delete from SCENARIO where SCENARIOID = '' || ScenarioNo || ''';
    execute immediate 'delete from SCENARIOINFO where SCENARIOID = '' || ScenarioNo || ''';
    END;

    Hi,
    Welcome to the forum!
    When you compile a stored procedure, you get only the vaguest of error messages by default.
    Always say SHOW ERRORS immediately after compiling, to get more detailed error messages. (And, of course, post the complete error message, including line number, when you need help.)
    Remember to specify a datatype (and, in the case of VARCHAR2 variables, a maximum length) for all local variables you declare:
    create or replace procedure ScenarioDelete (ScenarioNo IN varchar2)     -- no semicolon here
    AS  -- AS or IS (it doesn't matter which) required here
        countstable  VARCHAR2 (50) := 'C_'  || ScenarioNo;
        changetable  VARCHAR2 (50) := 'CG_' || ScenarioNo;
    ...You're not actually wasting any space if you decalre the variable as 50 characters, but only use 3.
    It really helps if you format code, so that, for example,
    all the local variables are indented before the word BEGIN
    everything between BEGIN and its corresponding END is indented
    everything between IF and its corresponding END IF is indented,
    and so on.
    You're probably already doing that, but it doesn't show up on this site unless you type these 6 characters
    (small letters only, inside curly brackets) before and after the formatted text.
    That's what I did for the code fragement above.
    Edited by: Frank Kulash on Mar 23, 2009 12:04 PM
    Formatting stuff added.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Getting error code 1 when calling SSIS package from a stored procedure (SQL Server 2008 R2)

    Hello,
    I am trying to execute a SSIS package from SQL Server 2008 R2 stored procedure but getting error code 1 (as per my knowledge, error code description is as below:
    0 The package executed successfully.
    1 The package failed.
    3 The package was canceled by the user.
    4 The utility was unable to locate the requested package. The package could not be found.
    5 The utility was unable to load the requested package. The package could not be loaded.
    6 The utility encountered an internal error of syntactic or semantic errors in the command line.
    Details:
    I have a stored procedure named "Execute_SSIS_Package" (see below sp) which executes 'Import_EMS_Response' SSIS package (when I execute this package directly from SQL Server BID it works fine it means package itself is correct) and calling
    it from SQL as:- EXEC Execute_SSIS_Package 'Import_EMS_Response'.
    Here I receives error code 1.
    Can anyone help me to resolve this issue please?
    Thanks in advance!
    CREATE PROCEDURE [dbo].[Execute_SSIS_Package]
     @strPackage nvarchar(100)
    AS
    BEGIN
     -- SET NOCOUNT ON added to prevent extra result sets from
     -- interfering with SELECT statements.
     SET NOCOUNT ON;
     DECLARE @cmd VARCHAR(8000)
     DECLARE @Result int
     DECLARE @Environment VARCHAR(100)
        SELECT @Environment = Waarde
     FROM  Sys_Settings
     WHERE Optie = 'Omgeving'
     --print @Environment
     SET @strPackage = '"\W2250_NGSQLSERVER\BVT\' + @Environment + '\' + @strPackage + '"'
     SET @cmd = 'dtexec /SQL ' + @strPackage +  ' /SERVER "w2250\NGSQLSERVER"  /Decrypt "BVT_SSIS" /CHECKPOINTING OFF /REPORTING E'
     --print @cmd
     EXECUTE @Result = master..xp_cmdshell @cmd, NO_OUTPUT
     --print @Result
    END

    It has something to do with the security.
    E.g. cmdshell is not enabled or the caller has not rights over the package.
    There could be a syntax error, too.
    I suggest you make the package runnable off a SQL Agent job then trigger the job from the stored proc with
    sp_start_job <job name>
    Arthur
    MyBlog
    Twitter

  • Nested Try/Catch in a stored procedure going to outer

    I am using Service Broker to move data to a historical database and then delete it from the current table in a second stored procedure that gets the information passed to it; which I have working but what I am having trouble with is when there
    is an error in the second stored procedure rather than going to the catch in the second Stored procedure it goes back up to my first one.
    CREATE PROCEDURE [sp_PkgDelActivator_SB]
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    DECLARE @RecvReqDlgHandle UNIQUEIDENTIFIER;
    DECLARE @RecvReqMsg XML;
    DECLARE @RecvReqMsgName sysname;
    BEGIN TRY
    WHILE (1=1)
    BEGIN
    BEGIN TRAN
    --Get the top item on the queue.
    WAITFOR
    ( RECEIVE TOP(1)
    @RecvReqDlgHandle = conversation_handle,
    @RecvReqMsg = message_body,
    @RecvReqMsgName = message_type_name
    FROM DeleteReceiveQueue
    ), TIMEOUT 5000;
    IF (@@ROWCOUNT = 0)
    BEGIN
    ROLLBACK TRANSACTION;
    BREAK;
    END
    ELSE
    COMMIT TRAN
    EXEC sp_PkgDeleteHeap_SB
    @RecvReqDlgHandle = @RecvReqDlgHandle,
    @RecvReqMsg = @RecvReqMsg
    END
    END TRY
    BEGIN CATCH
    DECLARE @ERR_NR INT = ERROR_NUMBER(),
    @ERR_SVR_NR TINYINT = ERROR_SEVERITY(),
    @ERR_STT_NR TINYINT = ERROR_STATE(),
    @ERR_PRC_TE VARCHAR(50) = ERROR_PROCEDURE(),
    @ERR_LN_NR INT = ERROR_LINE(),
    @ERR_MSG_TE VARCHAR(1000) = ERROR_MESSAGE()
    IF @@TRANCOUNT > 0
    ROLLBACK TRAN
    INSERT INTO DB_ERR_LOG(
    ERR_NR,
    ERR_SVR_NR,
    ERR_STT_NR,
    ERR_PRC_TE,
    ERR_LN_NR,
    ERR_MSG_TE,
    LOG_DT)
    SELECT
    @ERR_NR,
    @ERR_SVR_NR,
    @ERR_STT_NR,
    @ERR_PRC_TE,
    @ERR_LN_NR,
    @ERR_MSG_TE,
    GETDATE()
    END CATCH
    END
    CREATE PROCEDURE [sp_PkgDeleteHeap_SB]
    @RecvReqDlgHandle UNIQUEIDENTIFIER,
    @RecvReqMsg XML
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    BEGIN TRY
    BEGIN TRANSACTION
    DECLARE @dtArrival date = 'gotten from somewhere else'
    IF @dtArrival BETWEEN '2014-07-01' AND '2014-09-30'
    BEGIN
    'Code to move and delete rows from a table'
    END
    ELSE IF @dtArrival BETWEEN '2015-01-01' AND '2015-03-31'
    BEGIN
    'Code to move and delete rows from a table'
    END
    ELSE IF @dtArrival BETWEEN '2015-04-01' AND '2015-06-30'
    BEGIN
    'Code to move and delete rows from a table'
    END
    END CONVERSATION @RecvReqDlgHandle WITH CLEANUP;
    END
    COMMIT TRAN
    END TRY
    BEGIN CATCH
    ROLLBACK TRAN
    DECLARE @ERR_NR INT = ERROR_NUMBER(),
    @ERR_SVR_NR TINYINT = ERROR_SEVERITY(),
    @ERR_STT_NR TINYINT = ERROR_STATE(),
    @ERR_PRC_TE VARCHAR(50) = ERROR_PROCEDURE(),
    @ERR_LN_NR INT = ERROR_LINE(),
    @ERR_MSG_TE VARCHAR(1000) = ERROR_MESSAGE()
    'Code to send the message back into the queue'
    INSERT INTO DB_ERR_LOG(
    ERR_NR,
    ERR_SVR_NR,
    ERR_STT_NR,
    ERR_PRC_TE,
    ERR_LN_NR,
    ERR_MSG_TE,
    LOG_DT)
    SELECT
    @ERR_NR,
    @ERR_SVR_NR,
    @ERR_STT_NR,
    @ERR_PRC_TE,
    @ERR_LN_NR,
    @ERR_MSG_TE,
    @END_TS
    END CATCH
    END
    Thanks for any help.
    Also if this is not the right area for this question I am sorry please tell me and I will try moving it to the right area.

    >>Please guide me how to create Stored Procedure and how to load datas into Flatfile table and from Flatfile Table to Parent and Child Table.
    Can you try loading the data using SSIS package ? If that's not an option , you could try OPENROWSET
    --from the linkUSE AdventureWorks2012;
    GO
    CREATE TABLE myTable(FileName nvarchar(60),
    FileType nvarchar(60), Document varbinary(max));
    GO
    INSERT INTO myTable(FileName, FileType, Document)
    SELECT 'Text1.txt' AS FileName,
    '.txt' AS FileType,
    * FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document;
    GO
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • Problem with JDBC results calling simple stored procedure in VC 7.0

    Hi all,
    I am building a simple VC model which calls a stored procedure on a JDBC database. I have created the system in the portal, defined the alias and user mapping, the connection test is fine and the VC "find data" lists my bespoke stored procedure.
    The stored procedure is :
    CREATE PROCEDURE dbo.dt_getBieUsers
    AS
    select * from dbo.emailuserlink
    GO
    When I test it using query analyser, it returns 3 records each with the two fields I expect - user and email address.
    I drag the model onto the workspace in VC and create an input form ( with just a submit button ). i drag the result port out to create a table. This has no fields in it.
    I build and deploy as flex and the app runs, I click the submit button and SUCCESS! I get 3 records in my table each with 2 fields. The data is all correct. The problem with this is the fields are determined at runtime it seems.
    I go back to the table and add 2 columns "email" and "address".
    i build and deploy and run the app. Again I get 3 records, but this time the contents of all of the rows is not data, but "email" and "address". The data has been replaced by the header texts in all of the rows.
    Can anyone help? Why isn't the data being put in my columns as I would expect?
    I tried to build and deploy the app as Web Dynpro rather than Flex to see if it was a bug in Flex. The application starts but when I click the submit button to run the JDBC stored procedure I get a 500 Internal Server Error
    com.sap.tc.wd4vc.intapi.info.exception.WD4VCRuntimeException: No configuration is defined for the entry JDBCFunction
        at com.sap.tc.wd4vc.xglengine.XGLEngine.createComponentInternal(XGLEngine.java:559)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstanceFromUsage(XGLEngine.java:362)
        at com.sap.tc.wd4vc.xglengine.XGLEngine.getCompInstance(XGLEngine.java:329)
        at com.sap.tc.wd4vc.xglengine.wdp.InternalXGLEngine.getCompInstance(InternalXGLEngine.java:167)
        at com.sap.tc.wd4vc.xglengine.XGLEngineInterface.getCompInstance(XGLEngineInterface.java:165)
    The JDBC connection I am using has a connection URL of jdbc:sap:sqlserver://localhost;DatabaseName=BIEUSERS
    and a driver class of com.sap.portals.jdbc.sqlserver.SQLServerDriver
    Can anyone solve my wierd problems?
    Cheers
    Richard

    Hi Richard,
    After you drag and drop the data service, right click on it and choose "Test data service". Then click on "Execute" and after you see the result on the right, click on "Add fields" button (inside the same window). Now you'll see that the fields are on the tabel. This is required only for JDBC data services, since this data (how the resultset is built) is not know in DT and it needs to be run firest - then analysed and only then you have to add the fields to the table).
    Regards,
    Natty

  • Accessing files from Java Stored Procedures

    I am trying to access a file from a Java Stored Procedure but get the exception: "no such file or directory". The path and filename as seen by the database JVM is "\\wgcaub01\a1500is\fabi\mmv\mmvtestdata.txt".
    I have granted permissions to open the file using:
    call dbms_java.grant_permission('MMV', 'java.io.FilePermission', '\\\\wgcaub01\\a1500is\\fabi\\mmv\\mmvtestdata.txt', 'read');
    a) When I run the program as a Java class using a main method it works so the problem has to do with the Oracle JVM not finding the file.
    b) The MMV user has permissions on the file after granting them using the above dbms_java.grant_permission command.
    Can you tell me what am I missing? Is this a database configuration issue? Is there a problem with using a UNC path?
    (I am using FileReader and BufferedReader.)

    Vincent,
    Not sure if this is the cause of your problem, but I had some Java code which read from/wrote to a file, and I needed to run the following (you can obviously change <<ALL FILES>> to something more restrictive):
    declare
    security_key number;
    begin
    dbms_java.grant_permission('DAN', 'java.io.FilePermission', '<<ALL FILES>>', 'read,write,execute,delete', security_key);
    dbms_java.grant_permission('DAN', 'java.lang.RuntimePermission', 'writeFileDescriptor', NULL, security_key);
    dbms_java.grant_permission('DAN', 'java.lang.RuntimePermission', 'readFileDescriptor', NULL, security_key);
    end;
    Note that the security_key won't be set if the grant didn't work.
    Hope this helps,
    -Dan
    http://www.compuware.com/products/numega/dbpartner/dbpordebug.htm
    Debug PL/SQL and Java in the Oracle Database

  • Adding Records Using Stored Procedure (or Cursor?)

    Also, I would like to have a second example of a stored procedure that will add random rows to a table (that is, create duplicates of information already in the table).
    For example,
    IF p_value1 = 'FIRST_VALUE' then
    add this record (incl. seq_no for key);
    ELSIF p_value2 = 'SECOND_VALUE' then
    add that record (incl. seq_no for key);
    and on and on.
    This procedure should also be able to handle random insertion up to several thousand rows. So, I know that I need to loop, say:
    while v_ctr < 1000
    or
    for 1...999
    Much thanks to anyone who can help.
    Many thanks to anyone who can help.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Colin Berrouard ([email protected]):
    You should look in a PL/SQl book,
    There are a lot of examples that can help you
    <HR></BLOCKQUOTE>
    I have already, but when trying to self-learn without not any familiarity with certain concepts and being at most a visual learner, I'm not getting this concept at this point...hence the reason why I asked.
    Thanks.

  • Writing a Stored Procedure

    Okay - I am new to PLSQL & stored procedures. This will be something that I shall be learning. I am not new to SQL, however.
    And so: as a sql command I am able to execute a command to get data from our production database and 'migrate' the data to a different database (using db links):
    let's say the table in production is table1. Let's say this table already exists in this DB as well.
    In the second db, I am executing the following:
    DROP table db2.table1;
    CREATE TABLE db2.table1 (table1_id, table1_code, table1_field3, table1_field4)
    AS
    SELECT "TABLE1_ID", "TABLE1_CODE", "TABLE1_FIELD3", "TABLE1_FIELD4"
    FROM table1@productionDB;
    The above command executes successfully. However, now I would like to create a stored procedure that I can create a job for - so as to execute the procedure weekly.
    I am also new to toad. However, see that toad provides the ability to create & schedule jobs.
    I decided to take the above SQL and 'write' a stored procedure:
    CREATE OR REPLACE PROCEDURE p_table1_to_db2 IS
    BEGIN
    DROP table db2.table1;
    CREATE TABLE db2.table1 (table1_id, table1_code, table1_field3, table1_field4)
    AS
    SELECT "TABLE1_ID", "TABLE1_CODE", "TABLE1_FIELD3", "TABLE1_FIELD4"
    FROM table1@productionDB;
    END p_table1_to_db2;
    When running the above stored procedure, I get errors (what seem to be syntactical errors).
    I.e.: Oracle Error PLS-00103 -- Encountered the symbol "DROP" when expecting something else... etc.
    Since I'm new to this, can someone please assist me in correctly 'formatting' the above stored procedure? What am I doing wrong?

    DROP is not a valid command for PL/SQL. Inside a procedure you must use PL/SQL. There is a way around this by using the EXECUTE IMMEDIATE command.
    I would however prefere NOT to drop the table. If you just need to copy the data then
    DELETE FROM db2.table1;
    INSERT INTO db2.table1  (table1_id, table1_code, table1_field3, table1_field4)
    SELECT "TABLE1_ID", "TABLE1_CODE", "TABLE1_FIELD3", "TABLE1_FIELD4"
    FROM table1@productionDB;should be enough.
    Instead of "DELETE FROM db2.table1;" "TRUNCATE db2.table1;" is possible and faster, but does commit everything before this statement.
    Message was edited by:
    Sven Weller

Maybe you are looking for

  • Interactive Report: how can I display carriage returns?

    Hello everybody. Here is my problem: I created a table containing a field COMMENT varchar2(4000) and using APEX 4.1 I built an interactive report on it. Users can fill the field COMMENT with sentences on different rows, ex: " this is the first line t

  • How can I add error/console log to a submitted form?

    I created a form that I distribute manually over a dedicated server.  The form is to be filled using Reader and it is then validated and submitted by email using a custom script.  I retreive some data collected during validation and have it pasted to

  • Photos for Mac - Important Library Management Question

    Hello, I wanted to make sure that Master files are not imported into the Library database file, as they are already organized in folder on my drive. So I unchecked "Copy items to the Photo Library". Now I did a test by importing 66 MB worth of 30 pho

  • Maximum count of messages, and average/Max size of the messages for a retry

    I like to know what will be the maximum count of messages, Average/Max size of the messages that a retry queue can handle andhow it's is handled in OSB/Admin console and also the CPU and other Infra Structure requirements to support this scenario

  • IDoc number based upon sales data.

    Hi Experts, How to get the IDoc number in case I have sales document number or any other data which is being send in IDoc, any way we can get the IDoc number? Also help me know the program to process the IDocs in background, I know the t.code bd87 is