Called Java overloaded with stored procedures

I have two stored procedures with the same name and the same number of parameters. They are overworked because the two procedures differ in the data type of their parameters. In addition, there are 2 2 parameters and the other has 3 in and 1 OUT parameter.

But Java has problem describing as Java is unable to distinguish that they are two different procedures. How Java should treat calling them? I don't want to change their name.

Thank you

user5406804 wrote:
Is not in Java, no way to achieve
nom_de_variable-online value

What you are referring is named notation, a way to specify an argument name with its value instead of associating the argument which the variable position value in the call. Given that the appeal should be processed through SQL and just be text to Java try to use named notation in the appeal of Java like you did in Oracle directly and see if it works. If it does not try to use the wrapper procedure I described.

Tags: Database

Similar Questions

  • Call a PL/SQL stored procedure - data type mismatch

    I call a PL/SQL stored procedure from within a procedure of ODI using the specified technique page Cezar and Julien (http://odiexperts.com/how-to-use-plsql-procedures-and-functions-in-odi) and I get the error "Wrong number or argument types»

    I tested each of the types of parameters, in that I'm passing and it is the text that is causing the problem. I tried to use 'Text' and 'Alphanumeric' for the data type of the variable of the ODI and so many VARCHAR2 and VARCHAR for the PL/SQL parameter type and I can't make it work.

    Is there a trick for passing a string in the ODI PL/SQl?

    Hello

    Ensure

    1. to declare/refresh of the variable before call to PL/SQL.

    2. If the variable is of "alphanumeric" ODI calling must be attached to apostrophes and prefix with the code project as ' #MYPROJECT. ODI_Var'

    3. as parameters you have u who must pass both during the call (IN, OUT, etc.).

    Thank you
    Guru

  • Problem with stored procedure

    I use 10g, I have a 'PACK_SP' package with stored procedures, one of them is the following:
    PROCEDURE USP_ROWLARGESIZE(tablename VARCHAR2, cur_Types OUT CLOB,  v_namePrimaryKey OUT CLOB, cur_Result OUT CLOB) IS
    v_sql_str VARCHAR2(1000);
    v_ctx VARCHAR2(100);
    v_rowlength pls_integer;
    qryCtx DBMS_XMLGEN.ctxHandle;
    BEGIN
    
    -- Begin error stmt
    
    SELECT SYS.COL$.NAME INTO v_namePrimaryKey 
    FROM SYS.COL$ INNER JOIN SYS.OBJ$ ON SYS.COL$.OBJ# = SYS.OBJ$.OBJ# 
                  INNER JOIN SYS.CCOL$ ON SYS.COL$.OBJ# = SYS.CCOL$.OBJ# 
                  INNER JOIN SYS.CDEF$ ON SYS.CCOL$.CON# = SYS.CDEF$.CON# 
    WHERE SYS.OBJ$.NAME = tablename AND SYS.CDEF$.TYPE# = 2 AND SYS.COL$.COL# = SYS.CCOL$.COL#;
    
    -- End error stmt 
    
    (...)
    
    END USP_ROWLARGESIZE;
    As you can see, I have marked the statement with the error according to the OEM error message. The error text is: "Error Text = PL/SQL: ORA-00942: table or view does not exist. My goal is to store in the output parameter 'v_namePrimaryKey' the primary key column of a tablename. This query only works in more SQL query editor. Could someone help me?

    Thank you very much in advance!

    Published by: user9112176 on February 10, 2010 18:30

    Published by: user9112176 on February 10, 2010 18:31

    Published by: user9112176 on February 10, 2010 18:32

    Published by: user9112176 on February 10, 2010 18:33

    Published by: user9112176 on February 10, 2010 19:22

    System objects are accessible in SQL because they are visible through roles (DBA or SELECT_CATALOG_ROLE for example).

    However, the roles are disabled in PLSQL. You must have explicit privileges.
    That said, I would strongly advice you against writing code that references the SYS objects directly. You should use the USER_ or ALL_ % (or, if you really really must) the DBA_ % views.

    Hemant K Collette
    http://hemantoracledba.blogspot.com

  • Problem with stored procedure and validation

    I have the following stored procedure:

    create or replace PROCEDURE SOME_PROC)

    /*

    Some settings

    */

    ) AS

    NUMBER of errors

    BEGIN

    errors: = FN_CHECK_BUSINESS_RULE_1 (/ * some args * /);

    if(Errors > 0) then

    raise_application_error (ERR_CONSTANTS. SOME_ERROR_NUMBER, ERR_CONSTANTS. SOME_ERROR_MESSAGE);

    end if;

    INSERT INTO une_table (/ * columns * /) VALUES (/ * values * /);

    END SOME_PROC;

    Because the business rule 1 is placed inside the stored procedure I can't check it out without calling the stored procedure.

    I need to call the stored procedure 10 times with a different set of parameters and validation of the changes only after all calls to the stored procedure

    are successful. I want to show the user all the errors that occurred during the stored procedure calls. If for a first example of stored procedure call

    succeeds and a second failure no data has to be stored in a database.

    How to prevent the stored procedure for insert lines until I call the method commit of ApplicationModule?

    Thanks in advance.

    No, other users only see the lines until you commit. The search term is the transaction isolation level. Tom Kite write a paper on this here ask Tom: on transaction isolation levels. This article gives some samples, according to theory, and you should read it.

    Timo

  • call a pl/sql stored procedure from a report link

    Hi all:

    I have a report with a link in a column, which you take to another page and passes the values to this page, but also need to link, run a stored procedure before you go to the other page.

    In the Forum, I found a case similar to this one, but none of the examples is clear to me that I'm doing this. It seems that the target of the link must be URL, and also I have to call the stored procedure with a javascript function.

    My questions are:
    -Is the best way to do what I need?
    -How should be the syntax of the link that takes me to another page and run the "procedure".
    -How and where I put the "javascript" function to execute the "stored procedure".


    BDD: Oracle 11 g
    Apex 4.1 version


    Best regards

    Gerard

    Hello

    Change the link to call an apex.submit procedure. (javascript).

    Edit:

    I created a basic example.

    Region 1 (just so that you can see the value ready):

    Select: P27_HIDDEN item_Value
    of the double

    Region 2:

    rownum SELECT id, dbms_random.string ('U', 12) sss
    of the double
    connect by level<=>

    element attributes for ID:

    Target: URL
    URL: javascript:apex.submit ({request: 'NAVIGATE', value: {'P27_HIDDEN': #ID #}});

    (P27_HIDDEN is just a hidden item I created)

    http://Apex.Oracle.com/pls/Apex/f?p=54920:27

    Edit2:

    In your case, then you can only have a page based on conditions request = expression1, expression1: NAVIGATE... then a branch of the page to go to the desired page, also with the same conditions

    Edit3:

    I'm not sure what examples you're talking about, that you provide no link; but you mention calling the stored procedure of javascript, so would probably involve some AJAX, but is not necessary IMO.

  • Insert table with stored procedure

    Hello

    is it possible to use bind insert table in odp.net that calls a stored procedure, or who loses the point of contact of the table?

    I need to do at once two insertions in a parent table and the child table (get the primary key generated by a sequence in the first table.). Don't know if this can be done without storing seq.next_val somehow?

    Edit: I will extend the question and ask if the table bind sql text can be a block anonymous plsql

    Edited by: KarlTrumstedt 16-jun-2010 02:49

    You can do both. You can table insert a stored procedure and an anonymous block.

    Here's how (these are based on the ArrayBind example provided with the installation of ODP.net/ODT.

    Installation program:

    create table zdept (deptno number, deptname varchar2(50), loc varchar2(50));
    
    CREATE OR REPLACE PROCEDURE ZZZ (p_deptno in number, p_deptname in varchar2, p_loc in varchar2) AS
    begin
        insert into zdept values(p_deptno , p_deptname || ' ' || p_deptname, p_loc );
    end zzz;
    
     /**
     drop table zdept ;
     drop procedure ZZZ ;
     **/
    

    table and link it to the stored procedure call:

       static void Main(string[] args)
        {
          // Connect
          string connectStr = "User Id=;Password=;Data Source=";
    
          // Setup the Tables for sample
          Setup(connectStr);
    
          // Initialize array of data
          int[]    myArrayDeptNo   = new int[3]{1, 2, 3};
          String[] myArrayDeptName = {"Dev", "QA", "Facility"};
          String[] myArrayDeptLoc  = {"New York", "Maryland", "Texas"};
    
          OracleConnection connection = new OracleConnection(connectStr);
          OracleCommand    command    = new OracleCommand (
            "zzz", connection);
          command.CommandType = CommandType.StoredProcedure;
    
          // Set the Array Size to 3. This applied to all the parameter in
          // associated with this command
          command.ArrayBindCount = 3;
          command.BindByName = true;
          // deptno parameter
          OracleParameter deptNoParam = new OracleParameter("p_deptno",OracleDbType.Int32);
          deptNoParam.Direction       = ParameterDirection.Input;
          deptNoParam.Value           = myArrayDeptNo;
          command.Parameters.Add(deptNoParam);
    
          // deptname parameter
          OracleParameter deptNameParam = new OracleParameter("p_deptname", OracleDbType.Varchar2);
          deptNameParam.Direction       = ParameterDirection.Input;
          deptNameParam.Value           = myArrayDeptName;
          command.Parameters.Add(deptNameParam);
    
          // loc parameter
          OracleParameter deptLocParam = new OracleParameter("p_loc", OracleDbType.Varchar2);
          deptLocParam.Direction       = ParameterDirection.Input;
          deptLocParam.Value           = myArrayDeptLoc;
          command.Parameters.Add(deptLocParam);
    
          try
          {
            connection.Open();
            command.ExecuteNonQuery ();
            Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
          }
          catch (Exception e)
          {
            Console.WriteLine("Execution Failed:" + e.Message);
          }
          finally
          {
            // connection, command used server side resource, dispose them
            // asap to conserve resource
            connection.Close();
            command.Dispose();
            connection.Dispose();
          }
        }
    

    "anonymous plsql block.
    Well Yes

        static void Main(string[] args)
        {
          // Connect
          string connectStr = "User Id=;Password=;Data Source=";
    
          // Setup the Tables for sample
          Setup(connectStr);
    
          // Initialize array of data
          int[]    myArrayDeptNo   = new int[3]{1, 2, 3};
          String[] myArrayDeptName = {"Dev", "QA", "Facility"};
          String[] myArrayDeptLoc  = {"New York", "Maryland", "Texas"};
    
          OracleConnection connection = new OracleConnection(connectStr);
          OracleCommand    command    = new OracleCommand (
            "declare dnumber number; dname varchar2(50) ; begin dnumber := :deptno;dname := :deptname;insert into zdept values (:deptno, :deptname, :loc); update zdept set deptname=dname || :loc where deptno = :deptno; end;", connection);
    
          // Set the Array Size to 3. This applied to all the parameter in
          // associated with this command
          command.ArrayBindCount = 3;
          command.BindByName = true;
          // deptno parameter
          OracleParameter deptNoParam = new OracleParameter("deptno",OracleDbType.Int32);
          deptNoParam.Direction       = ParameterDirection.Input;
          deptNoParam.Value           = myArrayDeptNo;
          command.Parameters.Add(deptNoParam);
    
          // deptname parameter
          OracleParameter deptNameParam = new OracleParameter("deptname", OracleDbType.Varchar2);
          deptNameParam.Direction       = ParameterDirection.Input;
          deptNameParam.Value           = myArrayDeptName;
          command.Parameters.Add(deptNameParam);
    
          // loc parameter
          OracleParameter deptLocParam = new OracleParameter("loc", OracleDbType.Varchar2);
          deptLocParam.Direction       = ParameterDirection.Input;
          deptLocParam.Value           = myArrayDeptLoc;
          command.Parameters.Add(deptLocParam);
    
          try
          {
            connection.Open();
            command.ExecuteNonQuery();
            Console.WriteLine("{0} Rows Inserted", command.ArrayBindCount);
          }
          catch (Exception e)
          {
            Console.WriteLine("Execution Failed:" + e.Message);
          }
          finally
          {
            // connection, command used server side resource, dispose them
            // asap to conserve resource
            connection.Close();
            command.Dispose();
            connection.Dispose();
          }
        }
    
  • Call a PL/SQL stored procedure

    Hello

    I created a stored procedure p1 that calls another stored procedure PLSQLScheduler(). This PLSQLScheduler() is invoking a Web service and it works very well.

    create or replace procedure p1 as
    Start
    call PLSQLScheduler();
    end;

    Now, I created a job, that must call my webservice for all hours. From now on, I gave to every 2 minutes.

    Start
    () dbms_scheduler.create_job
    job_name = > Test_Job',.
    job_type = > 'PLSQL_BLOCK ',.
    job_action = > ' start p1(); end;',
    repeat_interval = > ' FREQ = MINUTELY; RANGE = 2',
    enabled = > TRUE,
    auto_drop = > FALSE,
    Comments = > 'Test job');
    end;

    When the Planner call p1() for every 2 minutes, it is defeat and I get the error below.

    ORA-06550: line ORA-06550: line 1, column 476:
    PLS-00905: ORABPEL object. P1 is not valid
    ORA-06550: line 1, column 476:
    PL/SQL: Statement ignored
    *, column :*

    But when I try to call my Web service using call PLSQLScheduler(); It is on the basis of my webservice. The same that I gave in a stored procedure. But it does not work. Can anyone help.

    Thank you.

    Little things that I notice, although they might not have something to do with the question.

    1)

    create or replace procedure p1 as
    begin
    call PLSQLScheduler();
    end;
    

    I would have written that:

    create or replace procedure p1 as
    begin
      PLSQLScheduler;
    end;
    

    (2) similar with your pl/sql block which is on demand:

    'begin p1; end;'
    

    Are you sure that there is only one p1 in your database? If the Scheduler is picking up a different p1 (which is not valid) than you think?

  • Error PLS-00306 with stored procedure

    I am trying to create a simple package and store the procedure to remove the date of treatment for Crystal Reports can read all data. I used an example on the web site for Crystal report as reference in SAP: link: [http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1084c536-711e-2b10-e48a-924a60745253;jsessionid= (J2EE3417200) ID0966300750DB00193623365600119940End]

    I ran the following and receive PLS-00306: wrong number or type of argument on the stored procedure. I am also pulling data with a databaselink to another data base given that our third-party vendor will not connect directly to the main database.

    I am new to PL/SQL, so I don't know what else to solve problems. Thank you for taking the time to review this.

    -1. Create a temporary table
    CREATE TEMPORARY TABLE global test_temp
    (processdate DATE NOT NULL);

    -2.Create package w / require REF CURSOR for Crystal reports
    CREATE or REPLACE PACKAGE test_package
    IN the TYPE processdate_TYPE IS REF CURSOR
    RETURN test_temp % ROWTYPE;
    END test_package;
    /

    -3. Stored procedure
    CREATE OR REPLACE PROCEDURE test_Procedure
    (processdate_cursor IN OUT test_Package.processdate_TYPE,
    processdate_parameter IN test_temp.processdate%TYPE)
    AS
    processdate DATE;
    BEGIN
    OPEN FOR Processdate_cursor
    SELECT processdate
    OF processlog@WEATEST
    WHERE processname = "F_ExecuteScheduleProcess" and processtype = ';
    END test_Procedure;
    /

    You say that you do not understand where there is a wrong number or type?

    This error occurs because there is an incorrect number of parameters passed. Your procedure
    Test_SP expects 3 parameters as defined by you as follows
    (p_ID in number,
    p_firstname OUT varchar2,
    p_lastname OUT varchar2)

    But when you run, you're not not p_id, has not managed to p_firstname, has failed to p_lastname. So there are number of parameters and that's what suggests the error.

    To run your test_sp
    Declare
    sFirstName Test_Table.FirstName%Type;
    sLastName Test_Table.Lastname%Type;
    Nest Test_Table.ID%Type: = 1;
    Begin
    Test_SP(1,sFirstName,sLastName);
    End;

    I hope this helps.

  • How to extract data from the APEX report with stored procedure?

    Hi all

    I am doing a report at the APEX. the user selects two dates and click on the GO button - I have a stored procedure linked to this region of outcome for the stored procedure is called.

    my stored procedure does the following-

    using dates specified (IN) I do question and put data in a table (this painting was created only for this report).

    I want to show all the data that I entered in the table on my APEX report the same procedure call. can I use Ref cursor return? How to do this?

    Currently, I use another button in the APEX that basically retrieves all the data from table. Basically, the user clicks a button to generate the report and then another button for the report. which is not desirable at all :(


    I m using APEX 3.1.2.00.02 and Oracle 10 database.

    pls let me know if you need more clarification of the problem. Thanks in advance.

    Kind regards

    Probashi

    Published by: porobashi on May 19, 2009 14:53

    APEX to base a report out of a function that returns the sql code... Your current code goes against a Ref cursor returns the values...

    See this thread regarding taking a ref cursor and wrapping it in a function to channel out as a 'table' (use a cast to cast tabular function vale)...

    (VERY COOL STUFF HERE!)

    Re: Tyring to dynamically create the SQL statement for a calendar of SQL

    Thank you

    Tony Miller
    Webster, TX

  • Compile with stored procedure errors

    Hi guys, I just start SQL so forgive me if I ask stupid questions real. That's the problem I have right now, as I said in my title.

    It's my procedure.sql

    CREATE OR REPLACE PROCEDURE check IS

    no_of_duplicates NUMBER: = 0;

    BEGIN

    SELECT COUNT (*) IN no_of_duplicates

    THE EMPLOYEE

    WHERE E # =.

    (select E # PILOT)

    WHERE THERE ARE

    (SELECT E # MECHANIC)

    WHERE DRIVER. L # = MECHANIC. L#));

    IF no_of_duplicates: = 0 THEN dbms_output.put_line ('OK');

    ON THE OTHER

    SELECT E #, NAME OF THE EMPLOYEE

    WHERE E # =.

    (SELECT E # PILOT)

    WHERE THERE ARE

    (SELECT E # MECHANIC)

    WHERE DRIVER. L # = MECHANIC. L#));

    END IF;

    END check;

    /

    While trying to create the procedure, it gives me compilation errors. I took with this for hours and can't seem to find anything wrong with it. Can someone point me in the right direction? Thank you!

    Hello

    Once again, your postal code.  The error occurs when you call the procedure, but you have not posted the code that calls the procedure and causes the error.

    When I do this in SQL * more:

    SET SERVEROUTPUT ON ENCAPSULATED FORMAT
    EXEC check;

    The procedure that you have posted works perfectly (i.e., displayed the e # is, exactly as it was designed to do).

    Display the e # and the name consists of BULK COLLECT both the e # name in separate collections, like this:

    CREATE OR REPLACE PROCEDURE check IS
    TYPE e #_table IS the TABLE OF THE employee.e#%TYPE;
    e # e _list #_table;

    TYPE name_table IS TABLE OF THE employee.name%TYPE;
    name_list name_table;
    BEGIN
    SELECT e #, name
    E LOOSE COLLECTION #_list, name_list
    The EMPLOYEE
    WHERE e # (IN)
    SELECT d.e #.
    DRIVER d
    JOIN m mechanic ON d.e # m.e = #.
    );
    E IF #_list. COUNT = 0
    THEN
    dbms_output.put_line ('OK, there without duplicate of illict");
    ELSE - that is to say, e #_list. COUNTY <> 0
    dbms_output.put_line (' the following employees are drivers and mechanics :');)
    J IN 1.e #_list. COUNTY LOOP - I displays parentheses sometimes hard on the OTN site
    dbms_output.put (TO_CHAR (e #_list (j)))
    '999999999999'
    )
    );
    dbms_output.put (' ');
    dbms_output.put_line (name_list (j));
    END LOOP;
    END IF;
    END check;
    /
    DISPLAY ERRORS

    This is the result I get when I run the procedure above with your sample data:

    The following employees are drivers and mechanics:

    1 John Smith

    You will notice I did several other changes in your code, sometimes because they are much more practical and sometimes just to show you different ways to do the same thing, that you may or may not want to use in this problem.

    For example, you were doing the same query (with only very slight differences) 2 times: once to get the no_of_duplicates and then a second time to get the actual data.  I don't know if it's the most effective way to do what you need.  Say that there are 1000 rows in the result.  You get all the 1000 once just to get the total number (that you do not need, if all you worry at this point is if there is), then to get the data.  When you make a COLLECTION in BULK, you get automatically the COUNTY anyway, so why not not COLLECTING in BULK, and then use this count to see what to do next.  If the NUMBER is greater than 0, then you already have the data, and you do not need to fetch it again.  In addition, repeating (essentially) the same code is a maintenance problem.  If you need to make a change, you must make the same change to several places.  At best, it's a pain; but it is the exactly the kind of mistake that is easy to miss in trials, and you could have the code that runs for weeks in Production before you notice that it sometimes gives false results.

    Another example: e # is a NUMBER.  If it is possible to convert numbers in VARCHAR2s and save these VARCHAR2s in a VARCHAR2 collection, would be unwise more just to store them in a collection of NUMBER?

  • Call the stored procedure to odi

    Hi all

    Posible calls a pl/sql stored procedure of odi?

    In ODI, create a procedure in your project, here, you can call a stored procedure name.

    This can then be slid into a package as a package step.

    geeo

  • setting report parameters fails for the report that runs the stored procedure in QMR FDM 2.1.1

    Hello

    Can someone help us please on this issue we have; If a solution is already available somewhere on the forum please link me to it.

    Please see our situation;

    The script below was part of the customization of a colleague to a script of Oracle FDM ("AftFileImport").

    There are no screenshots at this stage that came back to us with a temporary workaround.

    More detailed description:

    We built a custom report of FDM ("FSBValidationErrorsforAllLocations") that accepts two parameters (CatKey, period) and which calls a procedure stored in SQL Server with the same two parameters. FDM SQL statement of the report is:

    RUN FSBValidationErrorsforAllLocations ' ~ time ~', ~ Cat Key ~

    It works through the User Interface.

    When you try to put the two settings by customizing the event Oracle 'AftFileImport'script, the report fails. Below the part of the code in the 'AftFileImport', where we tried to fill values:

    • objReport.mParametersClear
    • objReport.mParametersAddNew "CatKey", RES. PstrCat
    • objReport.mParametersAddNew 'Period', RES. PstrPer

    We must understand why the way above to the definition of the parameters does not work with stored procedures, as seems to be the only documented way Oracle of setting parameters.

    Please let me know if that's enough.


    Thank you in advance.

    Hello

    which is the error when you run the script?

    • objReport.mParametersAddNew "Cat Key", RES. PstrCat

    Try again with the white space as it is how you named your parameter in the report definition, didn t you?

    Also try to use the built like the following examples:

    objRP.mParametersClear
    objRP.mParametersAddNew 'Period', CDate (dtePeriod)
    objRP.mParametersAddNew 'Loc', CLng (lngLocation)
    objRP.mParametersAddNew 'CatKey", CLng (lngCatKey)
    objRP.mParametersAddNew "TargAcct", CStr (strAutoMapAcct)

    Concerning

  • How to call the OFA PL/SQL procedure.

    Hello

    I'll call the pl/sql stored procedure of the OAF page (AM). the procedure is content parameter 3 IN 1 OUT parameter. all the parameters of character type is integer.


    I put the output parameter and it's returning the value, but I don't have how to configure the setting IN because the settings IN, I need to convert the INT data type number in java.

    Please help me.


    int in_parm1 = 0;
    Number in_param;
    Request_id number;
    request_id = new Number (0);
    getDBTransaction () .commit ();
    TXN OADBTransaction = getOADBTransaction();
    int l_user_id = txn.getUserId ();
    int l_resp_id = txn.getResponsibilityId ();
    int l_resp_appl_id = txn.getResponsibilityApplicationId ();
    Number of ln_user_id = new Number (l_user_id);
    Number of ln_resp_id = new Number (l_resp_id);
    Number of ln_resp_appl_id = new Number (l_resp_appl_id);
    CallableStatement cs = txn.createCallableStatement ("start oaf_request(:1,:2,:3,:4); end; ", 1) ;
    Try
    {
    System.out.println ("run ahead");
    cs.registerOutParameter (3, Types.VARCHAR, 0, 100);
    cs.registerOutParameter(1,in_param);
    cs.registerOutParameter(4,Types.NUMERIC);
    DSI Execute();
    in_parm1 = cs.getInt (4);
    request_id = new Number (in_parm1);
    System.out.println ("Request ID" + in_parm1);
    System.out.println ("run after");
    DSI Close();
    System.out.println ("result");
    }
    catch (System.Exception e)
    {

    throw OAException.wrapperException (e);

    }

    I would tell you to go through the "appeal of PL/SQL procedures and functions" Section in the User Guide.
    Example and the details are there reference.

    Thank you

  • MySQL stored procedure syntax errors

    I have a request online, I want to use transactions either commit all updates of db or anything. The code I created is as follows, not only am I getting an error of syntax on lines 5 and 16, but frankly I do not know that the code is really going to do what I want. Please let me know if you see syntax errors and explain them.

    CREATE PROCEDURE increase_maint_priority
        (maint_item INT, new_priority INT, cur_priority INT, center_id INT)
     
    BEGIN
        START TRANSACTION; -- line 5 syntax error
        -- start updates
        UPDATE maintitem SET priority = (priority+1) 
            WHERE priority > cur_priority
            AND priority <= new_priority
            AND centerID = center_id;
            
        UPDATE maintitem SET priority = new_priority
            WHERE id = maint_item;
        
        COMMIT;
    END; -- line 16 syntax error
    

    Thank you in advance for helping a newb to stored procedures.

    If you want to help me to know if this code will actually work for what I want, that the following describes the situation.

    Main idea: business location apply for maintenance at their Center. Applications can be added anywhere in the list of priority (1 = highest priority). They can also change the priority of an application at any time.

    Previously I was using php to control a loop of update mysql queries (ouch, I know now, 2 sql statements could do the trick) and we live lately priorities in double, and other problems which seem to be very likely related to the update of the priorities of several elements.

    Ex: moving priority 6 to priority 1 requires 1 update query because the current priority of the 6th point, but a second query (or loop of several others since I am very new to the drafting 2 years ago sql statements) to update the other priorities.

    Thus, the desire for transaction method.

    Once again, thanks in advance for any help on this matter.

    PS - I use MySQL workbench to write this and it's where to find errors.

    I do not use MySQL and its syntax is slightly different from the other DBMS stored procedures. In all cases, once you eliminate the warning, you also add a handler to ensure that updates roll back in case of error:

    http://khanrahim.WordPress.com/2010/05/16/transaction-with-stored-procedure-in-MySQL-serve r.

  • Stored procedure to add a record do not add record

    I have never successfully added a record via a stored procedure, but I managed with adding records through behaviors using recordsets with stored procedures and server, so I know that connections work. I have the data to MS SQL Server and ColdFusion web page. When I enter data and click 'Submit', it does absolutely nothing. When I check the SQL table, no record has been added. Any help would be greatly appreciated. Here are my stored procedure:


    Replace:



    Null value

    With:

    I provide each form with a value variable by default so that a value will always exist for each variable.

    Use the null attribute, if the value is 'yes', WHAT NULL value will be passed to the parameter of the stored procedure, if the content of the attribute value will be used

    http://livedocs.Adobe.com/ColdFusion/8/htmldocs/help.HTML?content=Tags_p-q_14.html#1102102

Maybe you are looking for

  • HP 50 g: Bug in LASTARG after MOD and other orders of CASES

    I mind not to check if this has been reported before, because it is a bug, and duplicate bug reports should be published until HP fixed them in a new ROM for HP 50g. I use the command MOD (in RPN mode in any case), example: 10 ENTER 7 MOD gives the c

  • Registration code

    BDP-S570 Is it possible to recover the registration code of the blu - ray? After seting upward for Netflix initially and very easily... customer wants to Pandora and others, but he repeats to me is a recorded legacy custom we implemented these progra

  • How can I lock apps

    I want to block some applications such as facebook, etc.

  • Zoom in the photo and the line at the same time?

    So, I accomplished the ability to zoom in/out of an image on the front panel, with user input. And I discovered separately how to programmatically create a line in the block diagram with draw several Lines.vi, and it appears on the front panel to run

  • Background image size

    There was a time when I saw a picture and transferred to 'set as background' it filled the entire screen. now it is not. Can I fix this?