Alter Store Procedure in Dynamic way..

Dear Folks,
I need your help on below query !
I’m using an one of the store procedure in my sales database.
But after some upgrade work, respective columns from destination table(NC_SAL) have been deleted & renamed..
& due to this,  I have to alter my all procedures those are depend on changed tables & restructure them in this way..
Here is the desired visual..
Can somebody help me to find out a dynamic way to alter all my procs those using table (NC_SAL)
Thanks,

Try the below code,
DECLARE @SP NVARCHAR(MAX)
DECLARE C CURSOR FOR SELECT OBJECT_DEFINITION(OBJECT_ID) Description FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%NC_SAL%'
OPEN C
FETCH NEXT FROM C INTO @SP
WHILE @@FETCH_STATUS=0
BEGIN
DECLARE @SQL NVARCHAR(MAX)
SET @SQL = REPLACE(@SP, '[TAXES]', '[LINEDESC]')
SET @SQL = REPLACE(@SQL, 'AS TAXES', 'AS [LINEDESC]')
SET @SQL = REPLACE(@SQL, 'CREATE PROCEDURE', 'ALTER PROCEDURE')
PRINT @SQL
EXEC(@SQL)
FETCH NEXT FROM C INTO @SP
END
CLOSE C
DEALLOCATE C
Regards, RSingh

Similar Messages

  • Call store procedure from pre-mapping

    Hi,
    I am currently working on OWB client version 10.2.0.4.36.My requirement is to call store procdure from pre-mapping tranformation.How to achieve this & how to pass parameters to the store procedure?
    Please let me know.
    Thanks,
    Siva

    Thanks for the quick reply.I am doing the same way as suggested.But am getting warning,when I validate it and is expecting to synchronize it.What warning you got exactly and i think you have not deployed the procedure.
    The reason for this procedure is to select max value from one of the table and then drop & recreate the sequence with max value + 1.
    Inside the procedure,am doing this all dynamically.which means am passing Columnname,tablename & sequencename to this procedure.
    Do you think is this good approach or any other advisable approach?Can you explain you requirement then only we can suggest the better way .
    Cheers
    Nawneet

  • How to find what values were passed onto a store procedure at the last run

    my web application is calling a store procedure but not returning the desired results in the ASP.net page
    when i execute the store procedure in sql server by providing the same values i get the desired result
    is there any way i could tell what values were passed onto the store procedure when it was called by the web page
    i am using sql server 2012 express 

    To add to the Profiler suggestion, you can also capture this information using Extended Events.  Below is a script example to capture RPC and batch completed events.  This can be done from the SSMS Object Explorer as well:
    --create ExtendedEvent session
    CREATE EVENT SESSION [ParameterTrace] ON SERVER
    ADD EVENT sqlserver.rpc_completed(
    ACTION(sqlserver.sql_text)),
    ADD EVENT sqlserver.sql_batch_completed(
    ACTION(sqlserver.sql_text))
    ADD TARGET package0.event_file(SET filename=N'C:\Temp\ParameterTrace.xel')
    WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF)
    GO
    --start session
    ALTER EVENT SESSION [ParameterTrace] ON SERVER
    STATE = START;
    GO
    --stop session
    ALTER EVENT SESSION [ParameterTrace] ON SERVER
    STATE = STOP;
    --query trace data
    SELECT CAST(event_data AS XML) AS event_data
    FROM sys.fn_xe_file_target_read_file(N'C:\temp\ParameterTrace*', default, default, default);
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • HOW TO EXECUTE A STORE PROCEDURE THAT RETURN MULTIPLE ROWS FROM A QUERY

    I NEED TO CREATE AND USE A STORE PROCEDURE THAT IS GOING TO DO A SELECT STATEMENT AN THE RESULT OF THE SELECT STATEMENT IS RETURN IN SOME WAY TO THE REQUESTER.
    THIS CALL IS MADE BY AN EXTERNAL LANGUAGE, NOT PL/SQL OR FORMS APPLICATION. USING FOR EXAMPLE ODBC AND VISUAL BASIC. WHAT I NEED TO DO IS ADD A DATA ACCESS LAYER TO MY APPLICATION AND I ALREADY HAVE IT DONE FOR MS SQL SERVER, BUT I NEED THE SAME FUNCTIONALITY ACCESSING AN ORACLE DATABASE.
    FLOW:
    1. VB CREATE A ODBC CONNECTION TO A ORACLE DATABASE
    2. VB EXECUTE A STORE PROCEDURE
    3. THE STORE PROCEDURE RETURNS TO THE VB APPLICATION THE RESULT OF THE QUERY THAT IS INSIDE OF THE STORE PROCEDURE.(I.E. THE STORE PROCEDURE IS A BASIC SELECT, NOTHING COMPLEX)
    4. VB DISPLAY THE RESULT IN A GRID
    FOR SURE I CAN DO THE SELECT DIRECTLY TO ORACLE, BUT FOR PERFORMANCE REASONS AND SCALABILITY, I'LL LIKE IT TO DO IT USING A STORE PROCUDURES
    IS THIS POSIBLE?, HOW?
    THANKS

    Certainly, it's possible. First, define a stored procedure that includes an OUT parameter which is a REF CURSOR. Then, call the stored procedure via ODBC omitting the OUT parameter from the list of parameters. IT will automatically be returned as a result set. Syntax for both is below...
    CREATE PROCEDURE foo (inParam in varchar2, resultSet OUT REF CURSOR )
    In ODBC:
    {call foo( 'someData' )}
    Justin

  • UNABLE TO EXECUTE THE CMDSQL SCRIPT IN A STORE PROCEDURE.

    I am trying to call a .sql file from sql cmd mode.
    The requirement is to pass the .sql file as parameter value to the cmd script which I have able to achieve,here is the code which is working fine .
    declare @x sysname
    set @x = 'C:\Users\testuser\Desktop\testing.sql'
    :OUT $(TEMP)\GetServerName1.sql
    PRINT ':SETVAR FilePath'+ ' ' + @x
    GO
    :OUT stdout
    :r $(TEMP)\GetServerName1.sql
    GO
    :r $(FilePath)
    But when I try to wrap this code in store procedure it is giving the message fatal error but when I run it without wrapping it in store proc it is doing its job with no error . When I looked into the store proc I found the code as
    ALTER proc [dbo].[testing]
    as
    declare @x sysname
    set @x = 'C:\Users\testuser\Desktop\testing.sql'
    PRINT ':SETVAR FilePath'+ ' ' + @x
    It seems like the sqlcmd code disappears automatically. I have no clue why it is happening. 
    Can anyone help in letting me knw how to wrap the above code in store proc.
    Thanks Saurav 

    It is important to keep in mind that you have two entities in play here. One client and one server. The lines that start with a colon never sent to SQL Server, nor are the lines which reads "go". They are intercepted client-side. For instance :r
    instructs SSMS to read a local file and out: redirects the output. And "go" breaks up the code in batches.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Front-End Service Starup Error: Store procedure to GET progress vector failed.

    Hi,
    We have a two front end servers in our Lync deployment and I'm getting an interesting error message on one of the servers when the "Lync Server Front-End Service" is starting up. All the services on that server will eventually start but I'm pretty
    sure it's affecting users in some way.
    Here is the error message in the Event Viewer:
    Log Name:      Lync Server
    Source:        LS User Services
    Date:          2013-09-17 8:00:32 AM
    Event ID:      32194
    Task Category: (1006)
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      BGC-VAN-LYNC2.domain.ca
    Description:
    Store procedure to GET progress vector failed.
    Execution Error: 0x00000000(ERROR_SUCCESS).
    Native Error: 8144.
    Error Details: [# [Microsoft][SQL Server Native Client 11.0][SQL Server]Procedure or function SyncReplicationGetProgressVector has too many arguments specified. #].
    Cause: This may indicate a problem with connectivity to local database or some unknown product issue.
    Resolution:
    Ensure that connectivity to local database is proper. If the error persists, please contact product support with server traces.
    Event Xml:
    <Event xmlns=>
      <System>
        <Provider Name="LS User Services" />
        <EventID Qualifiers="50158">32194</EventID>
        <Level>2</Level>
        <Task>1006</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2013-09-17T15:00:32.000000000Z" />
        <EventRecordID>16971</EventRecordID>
        <Channel>Lync Server</Channel>
        <Computer>BGC-VAN-LYNC2.domain.ca</Computer>
        <Security />
      </System>
      <EventData>
        <Data>0x00000000(ERROR_SUCCESS)</Data>
        <Data>8144</Data>
        <Data>[# [Microsoft][SQL Server Native Client 11.0][SQL Server]Procedure or function SyncReplicationGetProgressVector has too many arguments specified. #]</Data>
      </EventData>
    </Event>
    The error happens 15 times every minute, following with this event:
    Name:      Lync Server
    Source:        LS User Services
    Date:          2013-09-17 8:23:46 AM
    Event ID:      32189
    Task Category: (1006)
    Level:         Information
    Keywords:      Classic
    User:          N/A
    Description:
    The following Fabric service for routing groups have been closed:
    {F515134C-71B7-52FD-B0C3-6A9DB39CF750}
    {8A5D6B36-2A01-53DB-BC4E-3286C05E0836}
    {B35AAFC9-F6BF-5FFE-8C31-4AA5C36B2065}
    {69223418-78DC-5066-81A8-78E05914EC7B}
    {80414C96-1137-5DDC-8387-C3EA7A54B078}
    {641E6ABD-B862-55A1-B1B1-C83BC92D2F85}
    {1EA68EA4-77F7-5CFC-B781-0093CBC18403}
    {2FDE333D-FF7F-5D6A-B85B-93ADC1EAC12A}
    {A43BBA3A-8963-51C4-BD7A-19E1EC3DDFDB}
    {D3F4532F-61C8-5072-9B3B-3E2CCF15442F}
    {4449243E-5E96-56AC-AB6B-C5E785543542}
    {58B30261-65B6-5F6A-BC50-60F85782D052}
    {DB4B76B0-2510-5BF8-A7B1-8B37BD3AA7B9}
    {917CC217-966B-56AC-A912-97BA64BA13EB}
    Anyone knows what this is about and how to resolve this?
    Thanks,
    VH.

    Hi,
    Please try to reset registrar state:
    http://tsoorad.blogspot.in/2013/04/lync-2013-ee-pool-wont-start.html
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make
    sure that you completely understand the risk before retrieving any suggestions from the above link.
    Kent Huang
    TechNet Community Support

  • Select all values from Rule in Store Procedure

    Hi
    I have a rule like this
    CREATE RULE [dbo].[Rle_Currency_Lst]
    AS
    @List IN
    ('PKR','USD')
    GO
    Now i want to make simple "Currency List" report for which i need to select values from above rule in Store Procedure which i will use in SSRS to fill my report.
    Please help
    Zubair Afridi | Please mark as answered or vote helpful if this post help resolved your issue. Thanks!

    One way to get the values.
    declare @definition nvarchar(max);
    select @definition = m.definition
    from sys.objects o
    inner join sys.sql_modules m on o.object_id = m.object_id
    where schema_name(o.schema_id) = 'dbo' and o.name = 'Rle_Currency_Lst';
    set @definition = SUBSTRING(@definition, CHARINDEX('''', @definition), LEN(@definition));
    set @definition = LEFT(@definition, CHARINDEX(')', @definition) - 1);
    declare @myXML AS XML;
    set @myXML = N'<H><r>' + REPLACE(SUBSTRING(@definition, CHARINDEX('''', @definition), LEN(@definition)), ',', '</r><r>') + '</r></H>'
    declare @result table(myvalues nvarchar(100));
    insert @result(myvalues)
    SELECT Vals.id.value('.', 'NVARCHAR(100)') AS val
    FROM @myXML.nodes('/H/r') AS Vals(id)
    update @result set myvalues = REPLACE(myvalues, '''', '');
    select * from @result;
    Note that rules is a deprecated feature and will be removed in a future version of SQL Server.  The replacement for rules is CHECK CONSTRAINTS.  You may well want to consider a plan to migrate your current rules to check constraints.
    Tom

  • How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000

    Post Author: ltkin
    CA Forum: WebIntelligence Reporting
    Hi,
    How to build a report in web Intelligence using Store procedure under Microsoft SQL Server 2000 ?
    Regards,

    Hi ltkin,
    Unfortunately, it is not possible in Xir2 to create Webi reports from stored procedures.
    Webi reports can only be created from Universe. So in Business Objects XIR3 we can create a special universe that enables Web Intelligence user's to access stored procedures residing in the database. This is the only way that Web Intelligence user's can access stored procedures.
    Please let me know if the above information helps.
    Regards,
    Pavan

  • How to get a recordset in vb to access a oracle store procedure.

    I have a store procedure(sproc) that needs to be called from a VB Application. I was being told that I would have to create a PL/SQL table in my store procedure for the VB Developer to access information from my store procedure. This is beacasue he wants it as a record set. Is that the way to get info for a VB front end. My sproc is a very basic one
    My sproc looks like
    create or replace PROCEDURE SP_TBLINFO
    (ID out TBLINFO.id%type,
    ACCOUNT_NUMBER out TBLINFO.account_number%type)
    AS
    CURSOR TBLINFO_CURSOR IS
    SELECT * FROM TBLINFO;
    V_TBLINFO_CURSOR TBLINFO_CURSOR%ROWTYPE;
    BEGIN
    OPEN TBLINFO_CURSOR ;
    Loop
    FETCH TBLINFO_CURSOR INTO V_TBLINFO_CURSOR;
    EXIT WHEN TBLINFO_CURSOR %NOTFOUND;
    ID := V_TBLINFO_CURSOR.id;
    ACCOUNT_NUMBER:= V_TBLINFO_CURSOR.account_number;
    END LOOP;
    CLOSE TBLINFO_CURSOR ;
    END SP_TBLINFO;
    Thanks.

    Use a REF_CURSOR, something like the following:
    create or replace package SP_TBLINFO as
    CURSOR TBLINFO_CURSOR IS SELECT * FROM TBLINFO;
    create type TBLINFO_CURSOR_TYPE is TBLINFO_CURSOR%ROWTYPE;
    procedure PROC_TBLINFO(Info out TBLINFO_CURSOR_TYPE);
    end;
    create or replace package body SP_TBLINFO as
    PROCEDURE PROC_TBLINFO
    (Info out TBLINFO_CURSOR_TYPE)
    AS
    BEGIN
    OPEN ACCOUNT_NUMBER as SELECT * FROM TBLINFO ;
    END SP_TBLINFO;
    END;
    Then bind it in OO4O as ORATYPE_CURSOR.

  • Error message when issuing a COMMIT in a store procedure

    Hello experts,
    Please help.
    I have a problem where i cannot specify a COMMIT in a store
    procedure. I have the following error message:
    =================================================================
    00034, 00000, "cannot %s in current PL/SQL session"
    // *Cause:  An attempt was made to issue a commit or rollback
    from a PL/SQL
    // object (procedure, function, package) in a session
    which has this
    // disabled (by 'alter session disable commit in
    procedure')
    // *Action: enable commits from PL/SQL in this session, or don't
    attempt
    // to use commit or rollback in PL/SQL when they are
    disabled
    // in the current session.
    =================================================================
    Thanks very much for a reply
    Kind regards
    Yogeeraj

    The solution is to issue the statement
    alter session enable commit in procedure;
    However, I'd think carefully about doing this. Procedures are
    often called as part of a wider transaction. If the procedure
    issues a commit ALL the preceding work is also commited. If
    there is something subsequent in the transaction that fails and
    issues a rollback, it will onlt rollback the work done after the
    procedure. This may lead to your database being in an
    inconsistent state.
    rgds, APC

  • How to send an e-mail from a store procedure

    Hi,
    I need to find a way to send an e-mail from an store procedure every time a table is fetched.
    Is there a way to accomplish this task?. The e-mail should only display the rows in the table (no more than 5 rows) on a daily basis.
    Any help or example any of you can provide, it's greatly appreciated.
    Thanks
    Ed

    With Oracle 10g you can use UTL_MAIL to send mails.
    For earlier versions see the sample code on OTN
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    Use DBMS_JOB to schedule the sending of the mail

  • How to load and define Java Store Procedures using Consolidator Manager??

    Hi,
    I am trying to create a store procedure with a very easy example and I can not succeed. i am a bit new with OLite and I will appreciate any help from your side. I am quite lost now regarding of using java with OLite and it is becoming quite urgent for me. Thanks a lot in advanced.
    Those are the steps that I follow:
    - Creating the java class
    I create the java file MYUPPER.java with next code :
    public class MYUPPER {
    public static String doUpper( String p_text )
    return p_text.toUpperCase();
    I compile it and I create the jar file:
    C:\>javac MYUPPER.java
    C:\>jar cf MYUPPER.jar MYUPPER.class
    - This is an abstract of my java code using the API:
    ( m_cm is ConsolidatorManager)
    // Create the java resource
    m_cm.createStoredProc( "MYUPPER.jar", "MYUPPER", "doUpper", "doUpper");
    // Add it to the publication
    m_cm.addJavaResource( "PMTS", "MYUPPER" );
    - After running that code I do not receive any exception and checking into the repository looks ok:
    a) From the Mobile Server I can see the Java Ressource MYUPPER for that publication
    b) I can see the entries in C$Resouces and in C$Pub_Objects as well
    *** ON THE CLIENT:
    Then I go to the client device a Windows XP labtop where I did install the jre 5.0 and I added the bin path to the system variable PATH.
    - I get a POL-8000 error when synchronizing (could not start the Java Visrtual Machine)
    - Anyway, I can see the MYUPPER.class file deployed in the same directory than the databases are.
    - I have also tried next from msql:
    c:\>msql system/manager@jdbc:polite:tomeu_conscli
    Oracle Lite MSQL Version 10.3.0.2.0
    Copyright (c) 1997, 2008, Oracle. All rights reserved.
    Connected to: Oracle Lite ORDBMS
    Database Name: CONSCLI (Read Write)
    Database Version: 10.3.0.2.0
    Auto Commit: off
    Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)
    SQL> select * from c$resources;
    PUB_NAME | DB_NAME | RESOURCE_NAME | RESOURCE_TYPE | RESOURCE_DATA
    PMTS | pmts | MYUPPER | JAVA CLASS | -¦¦¥ 1
    1 row(s) returned
    SQL>
    SQL> exit
    Disconnected from CONSCLI
    c:\>msql system/*****@jdbc:polite:tomeu_pmts
    Oracle Lite MSQL Version 10.3.0.2.0
    Copyright (c) 1997, 2008, Oracle. All rights reserved.
    Connected to: Oracle Lite ORDBMS
    Database Name: PMTS (Read Write)
    Database Version: 10.3.0.2.0
    Auto Commit: off
    Driver Name: oracle.lite.poljdbc.POLJDBCDriver (OLite 4.0)
    SQL> select doUpper('fhjdjf') from dual;
    [POL-8035] no such attribute or method
    SQL> create table sp (id number(1) primary key );
    Table created
    SQL> alter table sp attach java source "MYUPPER" in '.';
    [POL-8028] error in calling a Java method
    SQL> commit;
    Commit complete
    SQL> select sp.doUpper('fhjdjf') from dual;
    [POL-8035] no such attribute or method
    Lost... :(
    Tomeu

    sorry to bother, similar like above, i tried many times on my computer to load a simple image in java application.. here's my code:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.*;
    import javax.swing.*;
    public class View extends JFrame {
         private URL imageURL;
         private File file;
         private Image sourceImage;
         private String name, title, message;
         private int width, height;
        public static void main(String[] args) {
            System.out.println( "Hello Eros!!!" );
            View img = new View();
        public View() {
             name = "D:/shared/inputpic.gif";
             file = new File( name );
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            try {
                imageURL = new URL("http://www.google.com.my/images/logo_sm.gif" );
            } catch (MalformedURLException e) {
            if ( file == null ) {
                sourceImage = Toolkit.getDefaultToolkit().getImage( name );
                System.out.println( file );
            } else {
                sourceImage = toolkit.getImage( imageURL );
                System.out.println( file );
            width = sourceImage.getWidth( this );
            height = sourceImage.getHeight( this );
            System.out.println( "Pixel = " + width + "x" + height );
            if ( width * height == 1 ) {
                title = "Greetings";  // Shown in title bar of dialog box.
                if ( file == null ) {
                    message = "Unable to load the file " + name;
                } else {
                    message = "Unable to load the link " + imageURL;
                JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE);
    }could anyone test this n give my the reason i couldnt even load the image

  • Decrypt the encrypted store procedure through the T-SQL programming in SQL Server 2005

    HI ,
    I have a encrypted store procedure in my production server .Right now I do not have the script now I want do some modification.
    Please any one can help me to decrypt the store procedure it will be a great help for me.
    For any suggestion thanks
     in advance.
    " Education is the beginning of transformation. Dedicate yourself to daily learning via Blogs/Forums/books and coaching "
    Click here to read my blog

    I have modified Jon's post so it also supports functions correctly, jon's version gave a syntax error on functions because the dummy func sql was invalid
    1. Connect using "admin:server\instance"  instead of "server\instance" (enable dac if you havent already, its an sp_reconfigure command)
    2. create the below proc
    3. exec SqlDecryptor 'dbo', 'function_or_stored_proc_name'
    ALTER -- CREATE
    proc SqlDecryptor (@objschemaname nvarchar(255), @objname nvarchar(255))
    AS
    DECLARE @objid INT,@objtype NVARCHAR(50),@objtypicalstm NVARCHAR(4000),@objencrypted BIT
    SELECT TOP 1 @objid=o,@objname = n,@objtype = t,@objtypicalstm=s,@objencrypted = (SELECT ([encrypted]) FROM syscomments WHERE [id] = x.o and colid = 1)
    FROM
    SELECT object_id o, name n,
    CASE WHEN [type] = 'P' THEN N'PROCEDURE'
    WHEN [type] = 'V' THEN 'VIEW'
    WHEN [type] IN ('FN','TF','IF') THEN N'FUNCTION'
    ELSE [type]
    END t,
    CASE WHEN [type] = 'P' THEN N'WITH ENCRYPTION AS'
    WHEN [type] = 'V' THEN N'WITH ENCRYPTION AS SELECT 123 ABC'
    WHEN [type] IN ('FN','TF','IF') THEN N' () RETURNS INT WITH ENCRYPTION AS BEGIN RETURN 1 END'
    ELSE [type]
    END s
    FROM sys.all_objects WHERE [type] NOT IN ('S','U','PK','F','D','SQ','IT','X','PC','FS','AF')
    AND name = @objname AND (SCHEMA_NAME([schema_id]) = COALESCE(@objschemaname,'dbo'))
    --UNION ALL SELECT object_id,name,'TRIGGER',N'ON ALL SERVER WITH ENCRYPTION FOR DDL_LOGIN_EVENTS AS SELECT 1' FROM sys.server_triggers WHERE name = @objname
    --UNION ALL SELECT object_id,name,'TRIGGER',N'ON DATABASE WITH ENCRYPTION FOR CREATE_TABLE AS SELECT 1' FROM sys.triggers WHERE name = @objname
    ) x
    --SELECT @objid,@objname,@objtype,@objtypicalstm,@objencrypted
    SET NOCOUNT ON
    IF @objencrypted <> 0
    BEGIN
    IF EXISTS
    SELECT * FROM sys.dm_exec_connections ec JOIN sys.endpoints e
    on (ec.[endpoint_id]=e.[endpoint_id])
    WHERE e.[name]='Dedicated Admin Connection'
    AND ec.[session_id] = @@SPID
    BEGIN
    DECLARE @ChunkNumber INT,@ChunkPiece NVARCHAR(MAX),@CompareChunksAtPosition INT,@DummyChunk NVARCHAR(MAX),@DummyObject VARBINARY(MAX),@EncryptedChunk NVARCHAR(MAX),@EncryptedObject VARBINARY(MAX),@p INT,@p1 NVARCHAR(MAX),@p2 NVARCHAR(MAX),@QueryForDummyObject NVARCHAR(MAX),@ReplacementText NVARCHAR(4000)
    SELECT @EncryptedObject = [imageval] FROM [sys].[sysobjvalues] WHERE [objid] = @objid AND [valclass] = 1
    BEGIN TRANSACTION
    SET @p = 1
    SET @p1= N'ALTER'+SPACE(1)+@objtype+SPACE(1)+ISNULL((@objschemaname+'.'),'')+@objname +SPACE(1)+@objtypicalstm;
    SET @p1=@p1+REPLICATE('-',4000-LEN(@p1))
    SET @p2 = REPLICATE('-',8000)
    SET @QueryForDummyObject = N'EXEC(@p1'
    WHILE @p <=CEILING(DATALENGTH(@EncryptedObject) / 8000.0)
    BEGIN
    SET @QueryForDummyObject=@QueryForDummyObject+N'+@f'
    SET @p =@p +1
    END
    SET @QueryForDummyObject=@QueryForDummyObject+')'
    EXEC sp_executesql @QueryForDummyObject,N'@p1 NVARCHAR(4000),@f VARCHAR(8000)',@p1=@p1,@f=@p2
    SET @DummyObject=(SELECT [imageval] FROM [sys].[sysobjvalues] WHERE [objid] = @objid and [valclass] = 1)
    ROLLBACK TRANSACTION
    SET @ChunkNumber=1
    WHILE @ChunkNumber<=CEILING(DATALENGTH(@EncryptedObject) / 8000.0)
    BEGIN
    SELECT @EncryptedChunk = SUBSTRING(@EncryptedObject, (@ChunkNumber - 1) * 8000 + 1, 8000)
    SELECT @DummyChunk = SUBSTRING(@DummyObject, (@ChunkNumber - 1) * 8000 + 1, 8000)
    IF @ChunkNumber=1
    BEGIN
    SET @ReplacementText=N'CREATE'+SPACE(1)+@objtype+SPACE(1)+ISNULL((@objschemaname+'.'),'')+@objname +SPACE(1)+@objtypicalstm+REPLICATE('-',4000)
    END
    ELSE
    BEGIN
    SET @ReplacementText=REPLICATE('-', 4000)
    END
    SET @ChunkPiece = REPLICATE(N'A', (DATALENGTH(@EncryptedChunk) / 2))
    SET @CompareChunksAtPosition=1
    WHILE @CompareChunksAtPosition<=DATALENGTH(@EncryptedChunk)/2
    BEGIN
    SET @ChunkPiece = STUFF(@ChunkPiece, @CompareChunksAtPosition, 1, NCHAR(UNICODE(SUBSTRING(@EncryptedChunk, @CompareChunksAtPosition, 1)) ^ (UNICODE(SUBSTRING(@ReplacementText, @CompareChunksAtPosition, 1)) ^ UNICODE(SUBSTRING(@DummyChunk, @CompareChunksAtPosition, 1)))))
    SET @CompareChunksAtPosition=@CompareChunksAtPosition+1
    END
    PRINT @ChunkPiece
    SET @ChunkNumber=@ChunkNumber+1
    END
    END
    ELSE
    BEGIN
    PRINT 'Use a DAC Connection'
    END
    END
    ELSE
    BEGIN
    PRINT 'Object not encrypted or not found'
    END
    SET QUOTED_IDENTIFIER OFF
    GO

  • Help: How to open wrapped store procedure on oracle database

    Dear Gurus,
    how to open the wrapped store procedure on oracle database?
    anyone can help me...?
    reply me soon
    take care

    Any other way so that I can see the flow of data that written on wrapped store procedure?You need to see the source code which has keeped outside of database. Read a wrapped code is not common for humans...
    reply me asap If you want an asap answer, raise a SR for oracle support, not through a forum which is based on volunteers.
    Nicolas.

  • Execute Unix Mail Command from Store Procedure

    Hi Colleagues!
    I designed a store procedure that Monitoring some Critical tables in my Oracle 8.0.6.1.0 Database But I need to send some Emails from the Store Procedures to Information System Staff when the amount of rows increase too much. I read about UTL_SMTP but my database version is too old to run this package. Also I have the option of Maildemo8i that execute MS Oulook from a Client System But I looking to Send it from my Database(OS HPUX). So please take a look of this issue and I will appreciate any help.
    Your Friend.
    Emmanuel Carrillo Trejos.
    LNB, Republic of Panama(Central America).
    P.D. You can email to: [email protected]

    Do you mean that you want to execute mail or mailx unix commands to send mails.If i am right then probably you are looking for a way to execute operating system commands from your procedure.
    You can refer this link if you want to do that. You need java support in your Oracle database and i believe that Oracle 8 does have jvm running in the instance.
    http://asktom.oracle.com/pls/ask/f?p=4950:8:5079825575573830264::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:952229840241
    Thank you!

Maybe you are looking for

  • Disgusted with HP Elite m9280a constant/random freezes, lock ups, BSOD, black screen

    constant/random freezes, lock ups, BSOD, black screen. I have been trying to trouble shoot this PC for almost a day now. weird problems like when 3 sticks of memory is present it wil not boot but it will boot on 1 and on 2 sticks will have hangs? dis

  • Remove Bridge Favorite that no longer exist?

    In CS2 Bridge, How do I remove a "favorite" from the favorite menu if the favorite folder does no longer exist. The "remove from favorite menu" command does not show up when a non existent folder is selected. I have all these folders that were delete

  • My computer crashed and I am trying to import an existing book

    my hard drive crashed and i have everything saved, but now i want to import an existing book that i have done into a new install of lightoom.

  • Messages are in "To Be Deleivered ". State

    Dear Experts, We are getting the following error in RWB ,Adapter monitoring which made All the messages are in "TO BE DELIVERED" status. Please suggest any ideas to resolve the same which can be rewarded accordingly... Adapter Engine, message: Fatal

  • My Zen Nano is dead! Help me!

    Hello there! I've got one Zen Nano for almost 0 months and it never gave me any trouble. It was working perfectly till yesterday. Today, when I tried to turn it on, it turned the backlight on, displayed the Zen Nano logo and right after it, it shut d