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?

Tags: Database

Similar Questions

  • Stored procedure error

    Hello

    I am Oracle 10 G and is the next version.

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for 32-bit Windows: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production


    I wrote a small stored procedure, but it is throwing error.

    I'm trying to compile the stored procedure on the side using the advanced search tool.

    Create procedure SCEMANAME.testtest as
    Start
    Insert SCHEMANAME. TEST values (10);
    commit;
    end;

    The error that I do face is the following.

    37000 (900) [oracle] [ODBC] [Ora] ORA-00900: invalid SQL statement

    Any help would be appreciated...

    The problem may lie in your advanced search tool. What happens if you try it in SQL * more?

    BTW, you don't need to specify the schema in the INSERT statement. The procedure is already in this scheme.

  • 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

  • compilation of stored procedure

    The procedure can be stored below.

    I need to declare varchar2 with a number such as varchar2 (30)
    How can I do and how to compile the stored procedure to display the output.

    number variable t1
    date variable t2

    test exec ('345', 'test', 'ECE','' 2008-09-10: t1: t2);

    I am facing problems




    Create or REPLACE procedure (eno vARCHAR2
    ename VARCHAR2
    dept VARCHAR2
    Join_date DATE
    sno ON NUMBER
    End_date DATE
    )
    IS

    BEGIN

    SELECT SNO, end_date IN sno, end_date of EMPLOYEE

    WHERE EMPLOYEE_NO = eno;



    EXCEPTION

    WHEN NO_DATA_FOUND THEN
    SNO: = NULL;
    End_date: = NULL;

    WHILE OTHERS THEN
    SNO: = NULL;
    End_date: = NULL;

    END;
    /

    Your case,

    satyaki>
    satyaki>ed
    Wrote file afiedt.buf
    
      1  cREATE OR REPLACE PROCEDURE Sample (carrier_code vARCHAR2
      2  ,vessel_name VARCHAR2
      3  ,voyage_no  VARCHAR2
      4  ,port_code  VARCHAR2
      5  ,eta_date   DATE
      6  ,tmp_rotation OUT NUMBER
      7  ,tmp_eta_date OUT DATE
      8  )
      9  IS
     10  BEGIN
     11  SELECT ROTN,ETA_DATE INTO
     12  tmp_rotation,tmp_eta_date
     13  FROM Sample1
     14  WHERE LINE_CODE = carrier_code
     15  AND VESS_NAME = vessel_name
     16  AND VOYAGE_NO = voyage_no
     17  AND PORT_CODE = port_code
     18  AND SAIL_DATE IS NULL
     19  AND VOYAGE_TYPE = 0;
     20  EXCEPTION
     21  WHEN NO_DATA_FOUND THEN
     22  tmp_rotation := NULL;
     23  tmp_eta_date := NULL;
     24  WHEN OTHERS THEN
     25  tmp_rotation := NULL;
     26  tmp_eta_date := NULL;
     27* END;
     28  /
    
    Procedure created.
    
    Elapsed: 00:00:02.33
    satyaki>
    satyaki>
    
    satyaki>
    satyaki>declare
      2  t1 number(10);
      3  t2 date;
      4  begin
      5  Sample('MSK','DUBAI','5645','J',null,t1,t2);
      6  dbms_output.put_line('SNO: '||t1||' - '||' END_DATE: '||t2);
      7  exception
      8  when others then
      9  dbms_output.put_line(sqlerrm);
     10  end;
     11  /
    SNO:  -  END_DATE:
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:01.04
    satyaki>
    satyaki>
    satyaki>
    satyaki>SELECT ROTN,ETA_DATE
      2  FROM Sample1
      3  WHERE LINE_CODE = 'MSK'
      4  AND VESS_NAME = 'DUBAI'
      5  AND VOYAGE_NO = '5645'
      6  AND PORT_CODE = 'J'
      7  AND SAIL_DATE IS NULL
      8  AND VOYAGE_TYPE = 0;
    
          ROTN ETA_DATE
    ---------- ---------
        623930 23-APR-08
    
    Elapsed: 00:00:00.16
    satyaki>
    

    And now to change your query to->

    satyaki>
    satyaki>cREATE OR REPLACE PROCEDURE Sample (carrier_code vARCHAR2
      2  ,vessel_name VARCHAR2
      3  ,voyage_no  VARCHAR2
      4  ,port_code  VARCHAR2
      5  ,eta_date   DATE
      6  ,tmp_rotation OUT NUMBER
      7  ,tmp_eta_date OUT DATE
      8  )
      9  IS
     10
     11  cursor c1
     12  is
     13    SELECT ROTN,ETA_DATE
     14    FROM Sample1
     15    WHERE LINE_CODE = carrier_code
     16    AND VESS_NAME = vessel_name
     17    AND VOYAGE_NO = voyage_no
     18    AND PORT_CODE = port_code
     19    AND SAIL_DATE IS NULL
     20    AND VOYAGE_TYPE = 0;
     21
     22    r1 c1%rowtype;
     23
     24  BEGIN
     25
     26  for r1 in c1
     27  loop
     28    tmp_rotation := r1.ROTN;
     29    tmp_eta_date := r1.ETA_DATE;
     30  end loop;
     31
     32  EXCEPTION
     33  WHEN NO_DATA_FOUND THEN
     34  tmp_rotation := NULL;
     35  tmp_eta_date := NULL;
     36  WHEN OTHERS THEN
     37  tmp_rotation := NULL;
     38  tmp_eta_date := NULL;
     39  dbms_output.put_line(sqlerrm);
     40  END;
     41  /
    
    Procedure created.
    
    Elapsed: 00:00:01.96
    satyaki>
    satyaki>
    satyaki>declare
      2  t1 number(10);
      3  t2 date;
      4  begin
      5  Sample('MSK','DUBAI','5645','J',null,t1,t2);
      6  dbms_output.put_line('SNO: '||t1||' - '||' END_DATE: '||t2);
      7  exception
      8  when others then
      9  dbms_output.put_line(sqlerrm);
     10  end;
     11  /
    SNO: 623930 -  END_DATE: 23-APR-08
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.17
    satyaki>
    satyaki>
    satyaki>SELECT ROTN,ETA_DATE
      2  FROM Sample1
      3  WHERE LINE_CODE = 'MSK'
      4  AND VESS_NAME = 'DUBAI'
      5  AND VOYAGE_NO = '5645'
      6  AND PORT_CODE = 'J'
      7  AND SAIL_DATE IS NULL
      8  AND VOYAGE_TYPE = 0;
    
          ROTN ETA_DATE
    ---------- ---------
        623930 23-APR-08
    
    Elapsed: 00:00:00.06
    satyaki>
    

    Hope this will help.

    Kind regards.

    LOULOU.

  • 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.

  • 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

  • Create a form based on a stored procedure error

    Hi all

    I am creating a form based on a stored procedure (CASH_MOVE). The stored procedure is inside a package (APEX_API).

    The package is not in the default schema of database application APEX (MO_APEX) analysis, but the workspace (USD) has access to this database scheme (MO_401)

    and the corresponding APEX analysis (MO_APEX/APEX_PUBLIC_USER) schema user has the EXECUTE privilege on the database to the other schema (APEX_API) package.

    So what happens during the wizard, at STEP 1, he sees the other schema, and I choose the package procedure.

    When I press next, it fails with the error 'user XXX has no privileges on the schema MO_401. ". "


    However, the user XXX is the developer of the APEX, which has no schema in the database. I tried also giving execute rights on APEX_PUBLIC_USER also without success.

    No idea why this happen?

    I use: Application Express 4.2.4.00.08

    Database version: 11.2.0.3.0

    TIA.

    Dionisis

    Ms. wrote:

    I am creating a form based on a stored procedure (CASH_MOVE). The stored procedure is inside a package (APEX_API).

    The package is not in the base schema of data analysis of the demand of the APEX (MO_APEX), but the workspace (MO_APEX) has access to this database scheme (MO_401)

    and the corresponding APEX analysis (MO_APEX/APEX_PUBLIC_USER) schema user has the EXECUTE privilege on the database to the other schema (APEX_API) package.

    So what happens during the wizard, at STEP 1, he sees the other schema, and I choose the package procedure.

    When I press next, it fails with the error 'user XXX has no privileges on the schema NNN. '.


    However, the user XXX is the developer of the APEX, which has no schema in the database. I tried also giving execute rights on APEX_PUBLIC_USER also without success.

    No idea why this happen?

    The developer APEX XXX there schema restrictions in the account privileges Schemes Accessible setting in Home > Administration > users > edit user?

  • 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();
          }
        }
    
  • 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.

  • 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

  • error when you try to compile this stored procedure

    I get this error message

    Testing_sp PROCEDURE compiled
    WARNING: the execution is completed with warning

    can I do this...

    See the err;

    and:

    17/23 PL/SQL: ORA-00932: inconsistent data types: expected NUMBER obtained -
    16/1 PL/SQL: statement ignored

    I can't understand why.
    I checked all the columns at TEST_TMP_TBL
    they are all varchar2





    CREATE OR REPLACE PROCEDURE testing_sp
    AS

    XML CLOB.
    xml2 VARCHAR2 (150);

    BEGIN


    SELECT ' <? XML version = "1.0" encoding ="' | utl_i18n.map_charset (value) | "" ? > '
    IN xml2
    OF nls_database_parameters
    Setting WHERE = 'NLS_CHARACTERSET ";


    SELECT
    XMLElement ("APPLICATION",
    XMLAttributes ('TEST', "Name")
    , XMLElement ("TESTPAGE",
    XMLAgg)
    XMLElement ("PROJ",
    XMLAttributes (NVL("ORDERS",' ') AS ORDERS,
    NVL("SUB_PART",' ') AS SUB_PART,
    NVL("SUB_SUB",' ') AS SUB_SUB,
    NVL("DESC",' ') AS DESC,
    NVL("ADD",' ') AS ADD,
    NVL("NUMB",' ') YOU NUMB
    ),

    XMLForest)
    NVL("ORDERS",' ') STOPPED,
    NVL("SUB_PART",' ') AS SUB_PART,
    NVL("SUB_SUB",' ') AS SUB_SUB,
    NVL("DESC",' ') AS DESC,
    NVL("ADD",' ') AS ADD,
    NVL("NUMB",' ') YOU NUMB
    )
    )
    )
    )
    )
    in xml
    OF TEST_TMP_TBL;



    DBMS_XSLPROCESSOR.clob2file (xml2: xml, 'dir', 'testing.xml');



    EXCEPTION
    while others then
    Rollback;

    end;



    Let me know if you have an idea, I would almost give my first born of an answer to this (not really sure)

    SQL > DECLARE
    2 v_xml CLOB.
    3 - v_xml XMLTYPE.
    4 BEGIN
    5 SELECT XMLELEMENT ("Emp") IN v_xml FROM DUAL;
    6 DBMS_OUTPUT. Put_line (v_xml);
    7 END;
    8
    9.
    SELECT XMLELEMENT ("Emp") IN the v_xml FROM DUAL;
    *
    ERROR on line 5:
    ORA-06550: line 5, column 21:
    PL/SQL: ORA-00932: inconsistent data types: expected NUMBER obtained -
    ORA-06550: line 5, column 2:
    PL/SQL: SQL statement ignored

    now change the variable for XMLTYPE data type;
    SQL > DECLARE
    2 - v_xml CLOB.
    3 v_xml XMLTYPE.
    4 BEGIN
    5 SELECT XMLELEMENT ("Emp") IN v_xml FROM DUAL;
    6 DBMS_OUTPUT. Put_line (v_xml);
    7 END;
    8
    9.

    PL/SQL procedure successfully completed.

  • Creating a table using a stored procedure, error

    MY querry is as follows:

    create or replace
    PROCEDURE New_Account_Activations)
    MYDATE_DD OUT VARCHAR2,
    MYDATE_MM OUT VARCHAR2,
    MYDATE_YYYY OUT VARCHAR2,
    MYDATE OUT VARCHAR2,
    VAR1 OUT VARCHAR2,
    VAR2 OUT VARCHAR2,
    VAR3 OUT VARCHAR2,
    TABLE_NAME OUT VARCHAR2) IS

    BEGIN
    SELECT TO_CHAR (SYSDATE-2, 'YYYY') INTO MYDATE_YYYY FROM DUAL;
    SELECT TO_CHAR (SYSDATE-2, "MM") INTO MYDATE_MM FROM DUAL;
    SELECT TO_CHAR (SYSDATE-2, 'DD') INTO MYDATE_DD FROM DUAL;
    MYDATE: = MYDATE_YYYY | MYDATE_MM | MYDATE_DD | '000000.000Z';
    -TABLE_NAME: = "NEWACCOUNTACTI_TEST";
    VAR1: = 'B ';.
    VAR2: = 'A ';
    VAR3: = 'Y ';
    Table_name: = "NewAccountActi" | '_' || MYDATE_YYYY | '_'|| MYDATE_MM | '_'|| MYDATE_DD;
    run immediately "CREATE TABLE tbl_name AS SELECT * FROM NEWACCOUNTACTI_TEST WHERE 1 = 0';"

    END;

    ERRORS

    ORA-01031: insufficient privileges

    ORA-06512: at "JACK. NEW_ACCOUNT_ACTIVATIONS', line 21

    ORA-06512: at the level of line 12

    Process is complete.

    WRONG FORUM!

    This forum is for Sql Developer issues only. Please mark the thread ANSWERED and repost it in SQL and PL/SQL forum.

    https://forums.Oracle.com/community/Developer/English/oracle_database/sql_and_pl_sql

    As says the Exception, your user JACK does NOT CREATE TABLE privileges granted DIRECTLY to them (not through a role) on the NEWACCOUNTACTI_TEST table. Grant privileges directly to the user.

    If that does not meet your question repost your question in the forum; do NOT here.

  • 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.

  • 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

  • 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