Create procedure to clear in doubt transcations.

Hi All,
I am trying to write a procedure and shedule it to run every 10 minutes to clear out in doubt transcations. following is the anonymous block, but not able to convert this into procedure, this has been taken from sir tom kyte site.
declare
   cursor_name     pls_integer default dbms_sql.open_cursor;
   ignore          pls_integer;
   procedure execute_immediate( p_sql in varchar2 )
   is
   BEGIN
      dbms_sql.parse(cursor_name, p_sql, dbms_sql.native);
      ignore := dbms_sql.execute(cursor_name);
      dbms_sql.close_cursor(cursor_name);
   END;
begin
   for x in ( select local_tran_id from from dba_2pc_pending where state like 'prepa%'; )
   loop
      dbms_output.put_line( 'My variable is ' || x.local_tran_id );
      -- execute_immediate( 'rollback force ''' || x.local_tran_id || '''' );
      dbms_transaction.purge_lost_db_entry(x.local_tran_id);
   end loop;
end;
/

1  CREATE OR REPLACE PROCEDURE FOOBAR
  2  AS
  3     cursor_name     pls_integer default dbms_sql.open_cursor;
  4     ignore          pls_integer;
  5     procedure execute_immediate( p_sql in varchar2 )
  6     is
  7     BEGIN
  8        dbms_sql.parse(cursor_name, p_sql, dbms_sql.native);
  9        ignore := dbms_sql.execute(cursor_name);
10        dbms_sql.close_cursor(cursor_name);
11     END;
12  begin
13     for x in ( select local_tran_id from sys.dba_2pc_pending where state like 'prepa%' )
14     loop
15        dbms_output.put_line( 'My variable is ' || x.local_tran_id );
16        -- execute_immediate( 'rollback force ''' || x.local_tran_id || '''' );
17        dbms_transaction.purge_lost_db_entry(x.local_tran_id);
18     end loop;
19* end;
11:15:06 SQL> /
Procedure created.
11:15:09 SQL>

Similar Messages

  • With create procedure, How to clear Shared pool

    Hi, I have a sql script file it contains
    more than 300,000 line code, I use this file
    to create procedure in the Oracle.
    When I execute this sql script file, I receive a error message " out of cursor". I know when I create procedure, the procedure's code is stores in the shared pool. So when the code is stores out of shared pool's size, I receive that error.
    But how can I clear shared pool? With commit statement, it won't be use.
    Thanks a lot.

    you may try:
    alter system flush shared_pool;
    null

  • Could u pls clear my doubts?

    Hai abapers
    I m new to ABAP objects....pls clear my doubts.
    1.what is an event? how is it useful in application development?
    2.Is it mandatory to give the same name for both object reference variable and object?
    Advance thanks
    regards,
    Selva

    Hi Selvakumar,
    1.what is an event? how is it useful in application development?
       An u201Ceventu201D is the occurrence of a special condition during the execution of an ABAP program. This occurrence must be of sufficient importance for the ABAP program to take a special action.
    Refer the below link for events.
    [http://help.sap.com/saphelp_nw04/helpdata/en/71/a8a77955bc11d194aa0000e8353423/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/71/a8a77955bc11d194aa0000e8353423/frameset.htm]
    2.Is it mandatory to give the same name for both object reference variable and object?
    Yes. The reference variable oref must be declared as an object reference variable. Instance components of an object created using CREATE OBJECT can only be accessed using object reference variables.
    [http://help.sap.com/saphelp_nw04/helpdata/en/71/a8a77955bc11d194aa0000e8353423/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/71/a8a77955bc11d194aa0000e8353423/frameset.htm]
    Regards,
    Boobalan Suburaj

  • Clear the Doubt : ABAP Activity or Basis Activity

    Hi All,
    I have one requirement, if i excute a report am getting report output, from here if i clickes its enters the VD02 transaction, from there user can enter customer change option. Using vd02 user can change the customer details.
    But in customer details i need only display format, for that basis person currently having a ZROLE.
    I want to know how to include selected fields under this role?* This is a Basis activity or ABAP Activity.*
    Basis team told that its a abap activity, create a z field group and give to us, we will add this zfield group into that particullar ZROLE.
    Is its correct?
    Pls anyone having idea pls clear this doubt.

    Hi,
    I believe your BASIS Team is right. They can only restrict upto the Txn Code Level from the BASIS Security feature.
    Post this thread in BASIS Forum also so as to get the feel from BASIS Experts.

  • Why thr r 2 options Is/As while creating procedure or function

    why there are 2 options avialable IS/AS while creating procedure or function ?
    Like
    create or replace procedure test (p_nbr NUMBER) AS
    create or replace procedure test (p_nbr NUMBER) IS
    tried both the options observed same result..
    Is thr any differnce between IS and AS ?

    SShubhangi wrote:
    why there are 2 options avialable IS/AS while creating procedure or function ?
    Like
    create or replace procedure test (p_nbr NUMBER) AS
    create or replace procedure test (p_nbr NUMBER) IS
    tried both the options observed same result..
    Is thr any differnce between IS and AS ?Technically... there is no difference.
    In terms of the English language, it would depend what you're describing...
    [ do some action ] AS follows...
    [ this object ] IS defined like this...
    So in programming language terms you could say that:
    create or replace procedure test (p_nbr NUMBER) AS...reads more naturally than
    create or replace procedure test (p_nbr NUMBER) IS...because it is an "action" of creating or replacing something.
    whereas, for example, a procedure in a package...
    procedure test (p_nbr NUMBER) IS...is more clear than
    procedure test (p_nbr NUMBER) AS...because this is stating what the procedure IS, rather than an action of creating it. (the package itself would be "create package ... AS")
    As far as Oracle is concerned though, it doesn't care, they are both interchangable. For me personally, I like to use the one that makes it clearly readable.

  • How to create procedure having delete statement with between function?

    I am very new in SQL Development, I want to create a procedure having two date variable start and end and these two variable i want to use in procedure body to delete data from a specific table between two date duration.
    Please guide
    Thanks,

    create procedure some_proc (start_date date, end_date date)
    as
    begin
         delete from your_table
                   where your_date_column between start_date and end_date;
    end some_proc;
    /

  • Create procedure is generating too many archive logs

    Hi
    The following procedure was run on one of our databases and it hung since there were too many archive logs being generated.
    What would be the answer? The db must remain in archivelog mode.
    I understand the nologging concept, but as I know this applies to creating tables, views, indexes and tablespaces. This script is creating procedure.
    CREATE OR REPLACE PROCEDURE APPS.Dfc_Payroll_Dw_Prc(Errbuf OUT VARCHAR2, Retcode OUT NUMBER
    ,P_GRE NUMBER
    ,P_SDATE VARCHAR2
    ,P_EDATE VARCHAR2
    ,P_ssn VARCHAR2
    ) IS
    CURSOR MainCsr IS
    SELECT DISTINCT
    PPF.NATIONAL_IDENTIFIER SSN
    ,ppf.full_name FULL_NAME
    ,ppa.effective_date Pay_date
    ,ppa.DATE_EARNED period_end
    ,pet.ELEMENT_NAME
    ,SUM(TO_NUMBER(prv.result_value)) VALOR
    ,PET.ELEMENT_INFORMATION_CATEGORY
    ,PET.CLASSIFICATION_ID
    ,PET.ELEMENT_INFORMATION1
    ,pet.ELEMENT_TYPE_ID
    ,paa.tax_unit_id
    ,PAf.ASSIGNMENT_ID ASSG_ID
    ,paf.ORGANIZATION_ID
    FROM
    pay_element_classifications pec
    , pay_element_types_f pet
    , pay_input_values_f piv
    , pay_run_result_values prv
    , pay_run_results prr
    , pay_assignment_actions paa
    , pay_payroll_actions ppa
    , APPS.pay_all_payrolls_f pap
    ,Per_Assignments_f paf
    ,per_people_f ppf
    WHERE
    ppa.effective_date BETWEEN TO_DATE(p_sdate) AND TO_DATE(p_edate)
    AND ppa.payroll_id = pap.payroll_id
    AND paa.tax_unit_id = NVL(p_GRE, paa.tax_unit_id)
    AND ppa.payroll_action_id = paa.payroll_action_id
    AND paa.action_status = 'C'
    AND ppa.action_type IN ('Q', 'R', 'V', 'B', 'I')
    AND ppa.action_status = 'C'
    --AND PEC.CLASSIFICATION_NAME IN ('Earnings','Alien/Expat Earnings','Supplemental Earnings','Imputed Earnings','Non-payroll Payments')
    AND paa.assignment_action_id = prr.assignment_action_id
    AND prr.run_result_id = prv.run_result_id
    AND prv.input_value_id = piv.input_value_id
    AND piv.name = 'Pay Value'
    AND piv.element_type_id = pet.element_type_id
    AND pet.element_type_id = prr.element_type_id
    AND pet.classification_id = pec.classification_id
    AND pec.non_payments_flag = 'N'
    AND prv.result_value <> '0'
    --AND( PET.ELEMENT_INFORMATION_CATEGORY LIKE '%EARNINGS'
    -- OR PET.element_type_id IN (1425, 1428, 1438, 1441, 1444, 1443) )
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN PET.EFFECTIVE_START_DATE AND PET.EFFECTIVE_END_DATE
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN PIV.EFFECTIVE_START_DATE AND PIV.EFFECTIVE_END_DATE --dcc
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN Pap.EFFECTIVE_START_DATE AND Pap.EFFECTIVE_END_DATE --dcc
    AND paf.ASSIGNMENT_ID = paa.ASSIGNMENT_ID
    AND ppf.NATIONAL_IDENTIFIER = NVL(p_ssn, ppf.NATIONAL_IDENTIFIER)
    ------------------------------------------------------------------TO get emp.
    AND ppf.person_id = paf.person_id
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN ppf.EFFECTIVE_START_DATE AND ppf.EFFECTIVE_END_DATE
    ------------------------------------------------------------------TO get emp. ASSIGNMENT
    --AND paf.assignment_status_type_id NOT IN (7,3)
    AND NVL(PPA.DATE_EARNED, PPA.EFFECTIVE_DATE) BETWEEN paf.effective_start_date AND paf.effective_end_date
    GROUP BY PPF.NATIONAL_IDENTIFIER
    ,ppf.full_name
    ,ppa.effective_date
    ,ppa.DATE_EARNED
    ,pet.ELEMENT_NAME
    ,PET.ELEMENT_INFORMATION_CATEGORY
    ,PET.CLASSIFICATION_ID
    ,PET.ELEMENT_INFORMATION1
    ,pet.ELEMENT_TYPE_ID
    ,paa.tax_unit_id
    ,PAF.ASSIGNMENT_ID
    ,paf.ORGANIZATION_ID
    BEGIN
    DELETE cust.DFC_PAYROLL_DW
    WHERE PAY_DATE BETWEEN TO_DATE(p_sdate) AND TO_DATE(p_edate)
    AND tax_unit_id = NVL(p_GRE, tax_unit_id)
    AND ssn = NVL(p_ssn, ssn)
    COMMIT;
    FOR V_REC IN MainCsr LOOP
    INSERT INTO cust.DFC_PAYROLL_DW(SSN, FULL_NAME, PAY_DATE, PERIOD_END, ELEMENT_NAME, ELEMENT_INFORMATION_CATEGORY, CLASSIFICATION_ID, ELEMENT_INFORMATION1, VALOR, TAX_UNIT_ID, ASSG_ID,ELEMENT_TYPE_ID,ORGANIZATION_ID)
    VALUES(V_REC.SSN,V_REC.FULL_NAME,v_rec.PAY_DATE,V_REC.PERIOD_END,V_REC.ELEMENT_NAME,V_REC.ELEMENT_INFORMATION_CATEGORY, V_REC.CLASSIFICATION_ID, V_REC.ELEMENT_INFORMATION1, V_REC.VALOR,V_REC.TAX_UNIT_ID,V_REC.ASSG_ID, v_rec.ELEMENT_TYPE_ID, v_rec.ORGANIZATION_ID);
    COMMIT;
    END LOOP;
    END ;
    So, how could I assist our developer with this, so that she can run it again without it generating a ton of logs ? ?
    Thanks
    Oracle 9.2.0.5
    AIX 5.2

    The amount of redo generated is a direct function of how much data is changing. If you insert 'x' number of rows, you are going to generate 'y' mbytes of redo. If your procedure is destined to insert 1000 rows, then it is destined to create a certain amount of redo. Period.
    I would question the <i>performance</i> of the procedure shown ... using a cursor loop with a commit after every row is going to be a slug on performance but that doesn't change the fact 'x' inserts will always generate 'y' redo.

  • How to use the default database service name on creating procedure for data

    how to use the default database service name on creating procedure for datagaurd client failover ??? all oracle doc says create a new service as below and enable at DB startup. but our client is using/wanted database default service to connect from application on the datagaurd environment (rac to non rac setup).please help.
    Db name is = prod.
    exec DBMS_SERVICE.CREATE_SERVICE (service_name => 'prod',network_name =>'prod',failover_method => 'BASIC',failover_type => 'SELECT',failover_retries => 180,failover_delay => 1);
    says already the service available.
    CREATE OR REPLACE TRIGGER manage_dgservice after startup on database DECLARE role
    VARCHAR(30);BEGIN SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
    IF role = 'NO' THEN DBMS_SERVICE.START_SERVICE('prod');
    END IF;
    END;
    says trigger created, but during a swithover still the service is listeneing on listener.
    tns entry.
    prod =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (LOAD_BALANCE = YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod2)(PORT = 1521)) ---> primary db entry
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = proddr)(PORT = 1521)) --> DR DB entry
    (CONNECT_DATA =
    (SERVICE_NAME = prod)
    thanks in advance.
    Edited by: 854393 on Dec 29, 2012 11:52 AM

    Hello;
    So in the example below replace "ernie" with the alias you want the client to use.
    I can show you how I do it :
    First an entry need to be added to the client tnsnames.ora that uses a SERVICE_NAME instead of a SID.
    ernie =
    (DESCRIPTION =
        (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = Primary.host)(PORT = 1521))
           (ADDRESS = (PROTOCOL = TCP)(HOST = Standby.host)(PORT = 1521))
           (CONNECT_DATA =
           (SERVICE_NAME = ernie)
    )Next the service 'ernie' needs to be created manually on the primary database.
    BEGIN
       DBMS_SERVICE.CREATE_SERVICE('ernie','ernie');
    END;
    /After creating the service needs to be manually started.
    BEGIN
       DBMS_SERVICE.START_SERVICE('ernie');
    END;
    /Several of the default parameters can now be set for 'ernie'.
    BEGIN
       DBMS_SERVICE.MODIFY_SERVICE
       ('ernie',
       FAILOVER_METHOD => 'BASIC',
       FAILOVER_TYPE => 'SELECT',
       FAILOVER_RETRIES => 200,
       FAILOVER_DELAY => 1);
    END;
    /Finally a database STARTUP trigger should be created to ensures that this service is only offered if the database is primary.
    CREATE TRIGGER CHECK_ERNIE_START AFTER STARTUP ON DATABASE
    DECLARE
    V_ROLE VARCHAR(30);
    BEGIN
    SELECT DATABASE_ROLE INTO V_ROLE FROM V$DATABASE;
    IF V_ROLE = 'PRIMARY' THEN
    DBMS_SERVICE.START_SERVICE('ernie');
    ELSE
    DBMS_SERVICE.STOP_SERVICE('ernie');
    END IF;
    END;
    /lsnrctl status - should show the new service.
    When I do this the Database will still register with the listener. I don't give that to the clients. That one will still be available but nobody knows about it. Meanwhile "ernie" moves with the database role.
    So in my example the default just hangs out in the background.
    Best Regards
    mseberg
    Edited by: mseberg on Dec 29, 2012 3:51 PM

  • Compilation error while creating procedure

    Hi,
    I am getting compilation error while creating procedure
    CREATE OR REPLACE My_CHANGEDATE IS
    error_string VARCHAR2(400) := NULL;
    BEGIN
    Create table set_temp as select * from set;
    CURSOR c1 is
         SELECT a.SETNUM, b.CHANGEDATE from
         set a, setsp_t2 b
         where a.setnum = b.setnum
         and trunc(a.changedate) < trunc(b.CHANGEDATE);
    BEGIN
         FOR rec IN c1 LOOP
              UPDATE set SET changedate = rec.changedate
              WHERE setnum = rec.setnum;
              Insert into set_temp select * from set where setnum = rec.setnum;
              END LOOP;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              NULL;
         WHEN OTHERS THEN
                   error_string := 'My_CHANGEDATE - '||SUBSTR(SQLERRM,1,350);
    DBMS_OUTPUT.PUT_LINE(error_string);
                   RAISE;
    END My_CHANGEDATE;

    I have taken your code and cleaned it up to be more readable. Please see the comments in the code.
    CREATE OR REPLACE My_CHANGEDATE
    IS
            error_string VARCHAR2(400) := NULL;
    BEGIN
            /* The only way to issue DDL in a procedure is to either user
             * DBMS_SQL or EXECUTE IMMEDIATE. Creating objects is generally
             * not needed or recommended in frequently run code.
            Create table set_temp as select * from set;    
            /* The cursor declarations need to go in the declaration section of the
             * procedure (between IS .. BEGIN).
            CURSOR c1 is                                   
            SELECT a.SETNUM, b.CHANGEDATE from
            set a, setsp_t2 b
            where a.setnum = b.setnum
            and trunc(a.changedate) < trunc(b.CHANGEDATE);
            BEGIN   /* Where is the END that goes with this begin? */
            /* Single record processing is generally not recommended. It is considered a "slow-by-slow" method. */
            FOR rec IN c1 LOOP
                    UPDATE set SET changedate = rec.changedate
                    WHERE setnum = rec.setnum;
                    Insert into set_temp select * from set where setnum = rec.setnum;
            END LOOP;
    EXCEPTION
            WHEN NO_DATA_FOUND THEN
                    NULL;
            WHEN OTHERS THEN
                    error_string := 'My_CHANGEDATE - '||SUBSTR(SQLERRM,1,350);
                    DBMS_OUTPUT.PUT_LINE(error_string);
                    RAISE;
    END My_CHANGEDATE;My general recommendations are as follows:
    1. Remove the CREATE TABLE from the procedure altogether.
    2. Don't use reserved words for object names (e.g. SET)
    3. Remove the record by record processing and consolidate it to a single UDPATE statement as follows (note untested):
    UPDATE  set s
    SET     changedate = (
                            SELECT  CHANGEDATE
                            FROM    SET A
                            ,       SETSO_T2 B
                            WHERE   A.SETNUM = B.SETNUM
                            AND     S.SETNUM = A.SETNUM
                            AND     TRUNC(A.CHANGEDATE) < TRUNC(B.CHANGEDATE)
    WHERE EXISTS(
                    SELECT  NULL
                    FROM    SET A
                    WHERE   A.SETNUM = S.SETNUM
                    )HTH!

  • "Run Script" (F5) Flacky Behavior with CREATE PROCEDURE and PACKAGE

    When I have the following create statement in a SQL Worksheet and run the script using "Run Script" (F5), I get the "PROCEDURE bogus Compiled." message. Why does it not tell me that there was a compile error? The procedure is marked with a little red "X" in the connections pane.
    CREATE OR REPLACE PROCEDURE bogus IS
    BEGIN
      x := 1;
    END;
    /Also, when I have the following command in a SQL Worksheet and run the script using "Run Script" (F5), I get the "PROCEDURE bogus Compiled." message. The difference is that I removed the slash after the CREATE PROCEDURE command. I can go into that procedure in the database via the Connections pane, click on the compile button, and the procedure compiles with no errors. Why does it not compile in a script when missing the slash?
    CREATE OR REPLACE PROCEDURE bogus IS
    BEGIN
      NULL;
    END;I noticed the same flaky behavior with CREATE PACKAGE BODY as well. This is in version 1.0.0.14.67 on Windows XP. Has this been fixed in the latest version?
    Mike

    I found a number of earlier posts on this (going back to at least v804), but I cannot find a thread with a response from the SQL Developer team - see:
    Package compilation error
    Succesful compilation message and Compiling Invalid Objects
    Creating a stored procedure from a file does not show compilation errors
    Re: Syntax Error Feedback
    I assume that it is just a bug with SQL Developer that it does not check for compilation errors when determining the status message to display (ie "PROCEDURE bogus Compiled"). At least now we get the little red cross on the navigator to tell us it is invalid :)

  • Creating procedures in forms

    I ahve to create 4 proceduers and call them in WHEN BUTTON PRESSED trigger.
    How can i create procedures at form level.
    I can create them in the database by sqlplus but then the procedures would be server specific.

    I can create them in the database by sqlplus but then
    the procedures would be server specific.Why would that be a problem ?

  • Security problem? (ORA-00942 error when creating procedure)

    First, in SQL*Plus connect as system user:
    SQL&gt;connect system/oracle
    Then, create table proctest for user scott and insert records:
    SQL&gt;create table scott.proctest ( name varchar2(10)) ;
    SQL&gt;insert into scott.proctest values ( 'bigboy' ) ;
    SQL&gt;select * from scott.proctest ;
    NAME
    bigboy
    Then, create procedure testproc for user system using table scott.proctest:
    SQL&gt;CREATE OR REPLACE PROCEDURE testproc AS
    2 v_name VARCHAR2(10) ;
    3 BEGIN
    4 SELECT Name INTO v_name FROM scott.proctest WHERE rownum &lt; 2 ;
    5 DBMS_OUTPUT.PUT_LINE( 'Name: ' || v_name ) ;
    6 END ;
    7 /
    Then, errs report:
    SQL&gt;show err;
    LINE/COL ERROR
    4/2 PL/SQL: SQL
    4/2 PL/SQL: SQL Statement ignored
    4/37 PL/SQL: ORA-00942: Table or view does not exist
    Then, explicitly grant select privilege on proctest to system:
    SQL&gt;grant select on scott.proctest to system ;
    And at this time compile the above precedure again, there's no errors.
    I have got some instruction that if a procedure wants to use some table,
    the owner of this procedure has to have corresponding privileges to use this table and
    these privileges have to be granted directly to the user. It doesn't work if
    the privileges are granted i.e. through roles.
    And in the example above the user has select on scott.proctest privilege but
    this privilege is granted through DBA role. So it doesn't work if
    I do not explicitly grant select privilege to system.
    My question is:
    Why does Oracle define this rule? Is it a kind of security consideration?

    Since stored procedures rely on privileges that are granted directly to the user, Oracle only needs to re-validate stored procedures when direct grants to the schema owner change. In general, the rate at which the privileges assigned to roles are changed is much higher than the rate at which privileges assigned to a particular user are changed, so this cuts down on on the cost of revalidating procedures.
    More importantly, Oracle roles can be assigned to users, but a user can also have non-default roles and password-protected roles. If Oracle allowed privileges through roles to affect the privileges of a stored procedure, handling these sorts of cases would be quite difficult and would result in far more confusion than in today's implementation.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • "GRANT CREATE PROCEDURE TO " not working

     
     Hi Team,
                  I am using SQL Server 2012 Developer Edition.Recently got request to grant permission to  "Create Stored Procedure" to a developer.When I execute this query "GRANT CREATE PROCEDURE TO [DEVELOPER];"
    It is not working again when the developer try to create a stored procedure Following error is displayed.I give the developer dbowner,ddladmin privileges also to test but the same below error is display.Can anybody guide me regarding this as it is high priority
    Msg 262, Level 14, State 18, Procedure test, Line 1
    CREATE PROCEDURE permission denied in database 'BASHA'.
     

                  Following are the output for both the select queries.
    1) BASHA  DATABASE 0CONNECT GRANT    
    2) db_ddladmin
    Membership in db_ddladmin should be sufficient. Below is a script that
    demonstrates two ways to grant a user rights to create procedures. You can
    use this script for your troubleshooting.
    Also, please post the output from "SELECT @@version".
    CREATE USER nisse WITHOUT LOGIN
    EXEC sp_addrolemember db_ddladmin, nisse
    go
    CREATE USER kajsa WITHOUT LOGIN
    GRANT CREATE PROCEDURE TO kajsa
    GRANT ALTER ON SCHEMA::dbo TO kajsa
    go
    EXECUTE AS USER = 'nisse'
    SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
    go
    CREATE PROCEDURE bludder AS PRINT 1
    go
    REVERT
    go
    EXECUTE AS USER = 'kajsa'
    SELECT * FROM fn_my_permissions (NULL, 'DATABASE');
    go
    CREATE PROCEDURE blidder AS PRINT 1
    go
    REVERT
    go
    SELECT p.name, db_name(), dp.class_desc, dp.major_id, dp.permission_name,
    dp.state_desc
    FROM sys.database_permissions dp
    JOIN sys.database_principals p ON p.principal_id = dp.grantee_principal_id
    WHERE p.name IN ('nisse', 'kajsa')
    SELECT m.name, r.name
    FROM sys.database_principals m
    JOIN sys.database_role_members rm ON m.principal_id =
    rm.member_principal_id
    JOIN sys.database_principals r ON r.principal_id = rm.role_principal_id
    WHERE m.name IN ('nisse', 'kajsa')
    go
    DROP USER nisse
    DROP USER kajsa
    DROP PROCEDURE bludder, blidder
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How Create procedure or function with ADO ?

    Hello,
    How Create procedure or function with ADO?It's my question.
    Thanks.
    Henri

    This message if post by Taiwan-ChangHaw-Oracle-Stored-Procedure-For-Business-Rule-Club
    public bool ConnectDatabase()
    try
    { string strConnectionString =
    "Provider=OraOLEDB.Oracle" +";"+
         "Data Source=" + ConnectionParams.Datasource +";"+
    "User Id =" + ConnectionParams.Username +";"+
    "Password =" + ConnectionParams.Password;
         m_conn=new ADODB.Connection();
         m_conn.ConnectionString=strConnectionString;
         m_conn.Open("","","",0); //i_"YYAOl Open the connection
    catch(Exception e)
    {     System.Windows.Forms.MessageBox.Show(e.Message);
         return false;
    return true; //YYAOl_B>3I9&connected successfully
    public void InsertDescription(string p_product,string p_language,string p_tname,string p_tdescription)
    { string sql="{Call inserttranslateddescription(?,?,?,?,?)}";
    try
    { ADODB._Command cmd=new ADODB.Command();//Create a command object
    cmd.ActiveConnection=m_conn; //Set its active connection to open connection
    ADODB.Properties properties=cmd.Properties;//Get the command properties into ADODB Properties object
    IEnumerator ienum=properties.GetEnumerator();//Get an enumerator on above properties
    ADODB.Property singleprop;
    while(ienum.MoveNext()) //iterate through the enumerator
         {singleprop=(ADODB.Property)ienum.Current;//Get the current property from enumerator
         string propname= singleprop.Name; //Get the name of current property
         if(propname.Equals("NDatatype")) //if the property is 'NDatatype' set its value to true
         singleprop.Value=true;
    cmd.CommandType=ADODB.CommandTypeEnum.adCmdText;
    int pid=Int32.Parse(p_product);
    ADODB._Parameter langid     =cmd.CreateParameter("langid",          ADODB.DataTypeEnum.adChar,ADODB.ParameterDirectionEnum.adParamInput, 100,p_language);
    ADODB._Parameter productid =cmd.CreateParameter("productid",     ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamInput, 100,pid);
    ADODB._Parameter tname =cmd.CreateParameter("tname",          ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tname);
    ADODB._Parameter tdescription=cmd.CreateParameter("tdescription",ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tdescription);
    ADODB._Parameter check          =cmd.CreateParameter("check",          ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamOutput,100,0);
    cmd.Parameters.Append(langid);
    cmd.Parameters.Append(productid);
    cmd.Parameters.Append(tname);
    cmd.Parameters.Append(tdescription);
    cmd.Parameters.Append(check);
    cmd.CommandText=sql;
    //Execute the command to insert product details in database
    object recs;
    object param=p_language;
    cmd.Execute(out recs,ref param,1);
    ienum.Reset();
    while(ienum.MoveNext()) //iterate through enumerator
    { singleprop=(ADODB.Property)ienum.Current;//Get the current property in to Property object
    string propname= singleprop.Name; //Get the name of current property
    if(propname.Equals("NDatatype")) //if it is 'NDatatype' set its value to true
    singleprop.Value=false;
    IEnumerator iprop=cmd.Parameters.GetEnumerator();//Get the enumerator for command parameters
    while(iprop.MoveNext()) //loop through enumerator
    { //Get the current parameter in enumerator
    ADODB._Parameter checkval=(ADODB._Parameter)iprop.Current;
    if(checkval.Name.Equals("check")) //if the parameter is 'check'
    if(checkval.Value.ToString().Equals("0")) //If check's value is zero data was inserted
    System.Windows.Forms.MessageBox.Show("Product details Inserted successfully");
    else
    System.Windows.Forms.MessageBox.Show("Product Details Updated");//else data was updated
    catch(Exception e)
    System.Windows.Forms.MessageBox.Show(e.Message);//Display any error message
    }

  • Plz clear the doubt regarding  Currrent indicator value in   cluster RT

    Hi Gurus,
    Current Indicator in RT table have the values as A and P. So as payroll is run in the month Feb and retro run  for Jan also. There are two result in RT with the Current Indicator A(Feb) and P(Jan retro)  OR  both have the same indicator as A and P for the previous Payroll RUN...
    Please  clear this ..
    Regards
    LAKHAN

    HI Srinivasarao,
    Thanks for the reply.
    I am still a little bit confused ..AS there in T-code  PC_PAYRESULT (for cluster data display)  :
    Payroll is run for  Feb.2008
    SEQNR     FPPER     FPBEG            FPEND             INPER       IPEND                  SRTZA
    61       200710     20080101     20080131     200710     20080131          P
    62       200710     20080101     20080131     200711     20080229          A
    63       200711     20080201     20080229     200711     20080229          A
    The Last Two row show the  payroll results for the  Feb.2008 wih the  A indicator.
    Is this corrrect 
    OR  the below  rows are correct(AS i have understand from your reply)
    62       200710     20080101     20080131     200711     20080229          P
    63       200711     20080201     20080229     200711     20080229          A
    Please clear my  doubt
    Regards
    lakhan

Maybe you are looking for