Error creating stored procedure using Apex

Hello,
I have worked with Access, SQL Server, and Firebird before, but am new to Oracle. I am trying to create a stored procedure to return the count of multiple hash values in a table. I want to know the number of rows that contain hash values that are duplicates somewhere else in the table. So if my table has 10 rows containing hash values: a, b, a, b, c, d, e, a, b, a, my return value should be 7. Here is my create procedure statement:
CREATE OR REPLACE PROCEDURE CommonHashValuesCount (dupThreshold in number, totalCount out number)
IS
BEGIN
totalCount := 0;
FOR h IN
(SELECT DISTINCT xf.MD5_HASH, COUNT(xf.MD5_HASH) as "HashCount"
FROM XFILE xf
GROUP BY xf.MD5_HASH)
LOOP
IF h.HashCount > dupThreshold THEN
totalCount := totalCount + h.HashCount;
END IF;
END LOOP;
END;
I get the following error when I try and run it:
ERROR at line 12: PL/SQL: Statement ignored
1. CREATE OR REPLACE PROCEDURE CommonHashValuesCount (dupThreshold in number, totalCount out number)
2. IS
3. BEGIN
Can anyone tell me what is wrong with my create statement? Or if anyone knows how to accomplish what I want in a single sql statement, I'd love to hear it!
TIA,
Theresa

Why not do it in a SQL statement so you can test it in the APEX SQL command window?
SELECT Sum(HashCount)
  FROM (SELECT DISTINCT xf.MD5_HASH
             , COUNT(xf.MD5_HASH) HashCount
          FROM XFILE xf
         GROUP BY xf.MD5_HASH
WHERE HashCount > <testvalue>
not tested
and then simply put that into your stored procedure/package:
SELECT Sum(HashCount)
  INTO totalCount
  FROM (SELECT DISTINCT xf.MD5_HASH
             , COUNT(xf.MD5_HASH) HashCount
          FROM XFILE xf
         GROUP BY xf.MD5_HASH
WHERE HashCount > dubThreshold
also not tested
C.

Similar Messages

  • Error creating Stored procedure

    Hello All,
    I am logged in as “system” user and trying to run the below script.
    create or replace procedure verify_job_not_running (my_job_name IN varchar2)
    AS
    my_job_count NUMBER;
    BEGIN
    select count(*) into my_job_count from dba_datapump_jobs where job_name = my_job_name;
    IF my_job_count > 0 THEN
    raise_application_error(-20010, 'data pump job already running');
    END IF;
    END verify_job_not_running;
    The above procedure is created with compilation errors. Please see the error message below.
    SQL> show errors;
    Errors for PROCEDURE VERIFY_JOB_NOT_RUNNING:
    LINE/COL ERROR
    5/3 PL/SQL: SQL Statement ignored
    5/42 PL/SQL: ORA-00942: table or view does not exist
    FYI - I am able to query “dba_datapump_jobs” table as “system”.
    Any help will be appreciated.
    Thank you,

    Hi,
    user504183 wrote:
    Hello All,
    I am logged in as “system” user and trying to run the below script.Very, very bad idea.
    Never create objects in Oracle-supplied schemas like SYSTEM, SYS, even HR.
    Create your own schema (you can call it my_system) for your own SYSTEM-like objects.
    create or replace procedure verify_job_not_running (my_job_name IN varchar2)
    AS
    my_job_count NUMBER;
    BEGIN
    select count(*) into my_job_count from dba_datapump_jobs where job_name = my_job_name;
    IF my_job_count > 0 THEN
    raise_application_error(-20010, 'data pump job already running');
    END IF;
    END verify_job_not_running;
    The above procedure is created with compilation errors. Please see the error message below.
    SQL> show errors;
    Errors for PROCEDURE VERIFY_JOB_NOT_RUNNING:
    LINE/COL ERROR
    5/3 PL/SQL: SQL Statement ignored
    5/42 PL/SQL: ORA-00942: table or view does not exist
    FYI - I am able to query “dba_datapump_jobs” table as “system”.Roles don't count in stored procedures. SYSTEM probably has privileges on dba_datapubp_jobs only because it has the role SELECT_CATALOG_ROLE.
    Log in as SYS and give the necessary privilges directly to the procedure owner (whcih, once again, should NOT be SYSTEM);
    GRANT SELECT ON dba_datapump_jobs TO my_system;

  • Creating Stored Procedures

    I'd like to learn how to create stored procedures in Oracle 10g. I'm proficient at this with MS SQL but I can't get to first base with Oracle.
    I am not using SQL *Plus and really I don't want to use it. I'd rather use a DB access program like Aqua Data Studio. When I attempt to create a procedure I get a "Compiled with errors" message. I don't know how to see the errors because I can't do a "Show Errors" message.
    Is there a way to create stored procedures using standard SQL and staying away from SQL *Plus?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    The two best free tools I know of are:
    http://sourceforge.net/projects/tora/
    and
    http://www.oracle.com/technology/products/database/sql_developer/
    TOra is more a database system tool, and SQL Developer is more of a development tool, but see if either of those will be to your liking ;)
    ~Jer

  • Creating and calling stored procedure using jdbc

    When I try to create and call a stored procedure using JDBC a very confusing error message about non-existence of the procedure just created is thrown. Using Informix database (IDS 10). Any pointers to point out what am doing wrong would be great!
    Thanks
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Scanner;
    public class CreateStoredProc {
    public static void main(String args[]){
    if (0 == args.length)
    return;
    try {
    Class.forName("com.informix.jdbc.IfxDriver");
    Connection conn = DriverManager.getConnection("jdbc:informix-sqli://10.76.244.120:30000/sampledb:INFORMIXSERVER=krisunda;user=root;password=cisco");
    String q = " create procedure runproc() "+
    " define i int; "+
    " let i = 0; "+
    " end procedure; "+
    " execute procedure runproc(); ";
    Statement stmt = conn.createStatement ();
    stmt.execute (q);
    } catch (Exception e) {
    e.printStackTrace();
    The stack trace:
    java.sql.SQLException: Routine (runproc) can not be resolved.
    at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
    at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2157)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2132)
    at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:378)
    at com.informix.jdbc.IfxStatement.a(IfxStatement.java:1299)
    at com.informix.jdbc.IfxStatement.executeImpl(IfxStatement.java:1269)
    at com.informix.jdbc.IfxStatement.c(IfxStatement.java:989)
    at com.informix.jdbc.IfxStatement.execute(IfxStatement.java:875)
    at CreateStoredProc.main(CreateStoredProc.java:37)
    Caused by: java.sql.SQLException
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:373)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3523)
    ... 10 more

    DriverManager.getConnection("jdbc:informix-sqli://10.76.244.120:30000/sampledb:INFORMIXSERVER=krisunda;user=root;password=cisco");check with ur sys admin wheather the particular user in the database has >execute privilage(rights) also.i mean execute the SP in the DB level.I guess that a root user will have the enough right.
    String q = " create procedure runproc() "+
    " define i int; "+<" let i = 0; "+
    " end procedure; "+
    " execute procedure runproc(); ";
    Statement stmt = conn.createStatement ();
    stmt.execute (q);Try to use the following code:
    String q = " create procedure runproc() "+
    " define i int; "+
    " let i = 0; "+
    " end procedure; "
    Statement stmt = conn.createStatement ();
    stmt.execute (q);
    q=" execute procedure runproc(); ";
    stmt.execute (q);
    Because maybe the driver failed to precompile your sql once, so that nothing happen.

  • Error while Executing stored procedure using ant

    Hi,
    I am trying to execute a stored procedure using ant ..
    My build.xml is like this...
    <project name="myproject" default="db.build">
    <target name="db.build">
    <sql driver="oracle.jdbc.driver.OracleDriver"
    url="jdbc:oracle:thin:@idm.orademo.com:1521:orcl"
    userid="test"
    password="oracle11g"
    print="yes"
    classpath="E:\\ojdbc14.jar"
    src="E:\\upg_9102BP07.sql" />
    <!--
    <classpath>
    <pathelement path=""\\>
    <\\classpath> -->
    </target>
    </project>
    I have my stored procedure in upg_9102BP07.sql as shown in above src..
    When im executing ant cmd I got the following exception
    E:\>ant -f test.xml
    Buildfile: test.xml
    db.build:
    *[sql] Executing resource: E:\upg_9102BP07.sql*
    *[sql] Failed to execute: declare cnt int*
    BUILD FAILED
    E:\test.xml:12: java.sql.SQLException: ORA-06550: line 1, column 15:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    *:= . ( @ % ; not null range default character*
    Total time: 44 seconds
    I have no clue.. But this sql ran successfully when did manually..
    Please help me in solving the issue...
    -- Marias

    Here is my script bit lengthy...
    Rem
    Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_ddl_AddcolumnToRCE_Oracle.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:24:19 devjain Exp $
    Rem
    Rem 9102_ddl_AddcolumnToRCE_Oracle.sql
    Rem
    Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    Rem
    Rem NAME
    Rem 9102_ddl_AddcolumnToRCE_Oracle.sql - <one-line expansion of the name>
    Rem
    Rem DESCRIPTION
    Rem Create a new column 'RCE_DELETE' in RCE table
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem blaksham 09/30/09 - Created
    Rem
    declare cnt int;
    Begin
         Select Count(1) into cnt From User_Tab_Columns Where TABLE_NAME='RCM' And COLUMN_NAME='RCM_DELETE';
         IF cnt=0 Then
         Begin
              Execute Immediate 'ALTER TABLE RCM ADD RCM_DELETE VARCHAR2(1)';
         End;
         Else
              DBMS_OUTPUT.PUT_LINE('Column already exists in the DB');
         End IF;
    End;
    Rem
    Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_dml_odf_source_name.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:44:45 devjain Exp $
    Rem
    Rem 9103_dml_odf_source_name.sql
    Rem
    Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    Rem
    Rem NAME
    Rem 9103_dml_odf_source_name.sql - <one-line expansion of the name>
    Rem
    Rem DESCRIPTION
    Rem <short description of component this file declares/defines>
    Rem
    Rem NOTES
    Rem <other useful comments, qualifications, etc.>
    Rem
    Rem MODIFIED (MM/DD/YY)
    Rem vpotukuc 09/17/09 - Bug8796435: Increase the size of odf_source-name
    Rem vpotukuc 09/17/09 - Created
    Rem
    SET ECHO ON
    SET FEEDBACK 1
    SET NUMWIDTH 10
    SET LINESIZE 80
    SET TRIMSPOOL ON
    SET TAB OFF
    SET PAGESIZE 100
    declare
    collen NUMBER := 0;
    begin
    select char_length into collen from user_tab_columns where table_name = 'ODF' and column_name = 'ODF_SOURCE_NAME';
    IF (collen < 400) then
    execute immediate 'alter table ODF modify ODF_SOURCE_NAME varchar2(400)';
    END IF;
    END;
    File name: 91_dml_update_reviewers_With_NoEmail_attestation.sql
    Purpose: Modify the email template to replace the 'Delegated By Last Name' with 'Reviewer Last Name' and 'Delegated By User Id' to 'Reviewer User Id'.
    Author: Babu Lakshamanaiah
    Description: Modify the email template 'Attestation Reviewers With No E-mail Addresses Defined'
    declare
    cnt int;
    begin
    Select Count(1) into cnt From emd Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
    IF cnt=0 Then
    Begin
    DBMS_OUTPUT.PUT_LINE('There is no record with emd_name Attestation Reviewers With No E-mail Addresses Defined ');
    End;
    Else
    update emd set emd_body='The following attestation reviewers do not have email addresses defined. Attestation requests have been generated for these reviewers and can be accessed by loging in to Oracle Identity Manager. However, notification emails were not sent.' ||chr(10) || chr(10) ||
    'Attestation process: <Attestation Definition.Process Name>' || chr(10) ||
    'Attestation Request ID: request <Attestation Request.Request Id>' || chr(10) ||
    'Request date: <Attestation Request.Request Creation Date>' || chr(10) || chr(10) ||
    'Reviewers Without E-mail Address: <reviewers> ' || chr(10) ||
    '<Attestation Task.Reviewer First Name> <Attestation Task.Reviewer Last Name> [<Attestation Task.Reviewer User Id>]' Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
    End IF;
    commit;
    end;
    Please help me out.....
    --Marias                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Java Stored Procedure using XSU on 9i Lite

    I have create Java Stored Procedure using XML SQL Utility to return results in XML format. I have tested the stored procedure on the development machine (with SDK and Webtogo)without any problem. When I tested it on the client machine (with only the lite database for Window download from the webtogo server as part of the setup), there's an error [POL-8035] no such attribute or method when I call the procedure through MSQL. However, after calling the stored procedure the 3rd times, it will return the results in XML. Once I logout after that, I will have to call the same SP 3 times (always 3 times) before I get the results.
    I'm running on Win2000, Oracle lite 5.0.1. with jdk 1.3.1 - same for the development machine.
    I'm using the same xsu12.jar file.
    What did I miss?

    Nothing?
    No one? No ideias?
    Regards,
    Flavio Matiello

  • How can i create stored procedures dynamically?

    I have tried to create a stored procedure building a string with the PL/SQL code needed to create the procedure. If i run the code using SQL+ works fine, but using the following code:
    Public Sub CreateStoredProcedure()
    Dim strSql As String
    strSql = "CREATE OR REPLACE PACKAGE OPSPRUEBAS AS " & vbCrLf
    strSql = strSql & vbTab & "PROCEDURE consulta (resultado OUT VARCHAR2); " & vbCrLf
    strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
    strSql = strSql & "/ " & vbCrLf
    strSql = strSql & ". " & vbCrLf
    strSql = strSql & "CREATE OR REPLACE PACKAGE BODY OPSPRUEBAS AS " & vbCrLf
    strSql = strSql & "PROCEDURE consulta (resultado OUT VARCHAR2) IS " & vbCrLf
    strSql = strSql & "oc_ref" & vbTab & vbTab & "REF Content_Ontology; " & vbCrLf
    strSql = strSql & "oc" & vbTab & vbTab & "Content_Ontology; " & vbCrLf
    strSql = strSql & "ori" & vbTab & vbTab & "role_def; " & vbCrLf
    strSql = strSql & "ori_ref" & vbTab & vbTab & "ref role_def; " & vbCrLf
    strSql = strSql & "conce" & vbTab & vbTab & "concept; " & vbCrLf
    strSql = strSql & "conce_ref" & vbTab & "REF concept; " & vbCrLf
    strSql = strSql & "b" & vbTab & vbTab & "boolean; " & vbCrLf
    strSql = strSql & "BEGIN " & vbCrLf
    strSql = strSql & "b:=false; " & vbCrLf
    strSql = strSql & "select REF(oi) into ori_ref from rol_table oi where oi.name='Playing'; " & vbCrLf
    strSql = strSql & "select deref(ori_ref) into ori from dual; " & vbCrLf
    strSql = strSql & "select REF(oi) into oc_ref from c_ontologies oi where oi.web_source_prop=websource('FilmContentOntology'); " & vbCrLf
    strSql = strSql & "select deref(oc_ref) into oc from dual; " & vbCrLf
    strSql = strSql & "if oc.if_has_co_class('Film')='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_class('theater')='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_relationship('is_scheduled')='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_attributes('Film', lista('is_scheduled', 'title', 'actor'))='TRUE' AND " & vbCrLf
    strSql = strSql & "oc.if_has_co_attributes('theater', lista('theatername', 'address', 'email'))='TRUE' " & vbCrLf
    strSql = strSql & "then resultado:='FilmContentOntology'; " & vbCrLf
    strSql = strSql & "else resultado:='No Existe'; " & vbCrLf
    strSql = strSql & "end if; " & vbCrLf
    strSql = strSql & "END consulta; " & vbCrLf
    strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
    strSql = strSql & "/ " & vbCrLf
    strSql = strSql & ". " & vbCrLf
    strSql = strSql & "COMMIT;" & vbCrLf
    TextBox2.Text = strSql
    'Dim myConnectionString As String = "User Id=system;Password=daniel;Data Source=websogo;"
    'Dim oraConn As Oracle.DataAccess.Client.OracleConnection = New Oracle.DataAccess.Client.OracleConnection(myConnectionString)
    Dim myCmd As New System.Data.OleDb.OleDbCommand()
    Dim MyConnection As New System.Data.OleDb.OleDbConnection()
    MyConnection.ConnectionString = "Provider=MSDAORA;Data Source=websogo;password=daniel;User ID=system"
    MyConnection.Open()
    'oraConn.Open()
    myCmd.Connection = MyConnection
    myCmd.CommandType = CommandType.Text
    myCmd.CommandText = strSql
    myCmd.ExecuteNonQuery()
    'Dim e As Oracle.DataAccess.Client.OracleException
    'Try
    ' myCmd.ExecuteNonQuery()
    'Catch e
    ' Dim error1 As Oracle.DataAccess.Client.OracleError
    ' error1 = e.Errors.Item(0)
    ' Textbox3.Text = error1.Source & " " & error1.Message
    'End Try
    MyConnection.Close()
    End Sub
    I've tried using Microsoft ODP, OLEDB and Oracle's ODP.NET
    Also tried to catch any error but there are no errors!
    Has anybody achived a successful dynamically stored procedure creation using .net?
    thanks in advance
    Dan

    I'm trying to create Stored Procedures via .NET and able to do so but when I look in Oracle Enterprise Manager Console, the Stored Procedures are marked as INVALID... If I edit the Stored Procedure (i.e. delete a space or something minor) and SAVE then it compiles fine.....
    Any ideas ????
    will be using this against 9i & 10g db

  • Calling Stored Procedure using J2EE (CMP/BMP)

    Hi guys,
    Can anyone please help me of how to call a stored procedure using a bean in J2EE? I am using Sybase as a database. I am not sure of how to call a stored procedure that is stored in the database server.
    I have one more problem that I am getting in my application. I have 6 entity beans for 6 tables (3 temporary which are deleted and created as and when deployed and 3 permanent which are not deleted when deployed). When I access and manipulate data in temporary tables, everything works fine. But when I try to insert records in the 3 permanent tables, i get an error saying...
    ejbexception.transactionrolledbackerror - Client's transaction rolledback
    Your suggestions would be very valuable.
    Thanks in advance,
    ashish

    Actually, I was getting the RolledBack exception before I was using stored procedure. The bean was supposed to make a few transactions in the tables within the Sybase database. Since it gave me rolledback error, I decided to write a stored proc. in the database and to call that procedure using the bean.
    Now, I am not sure of how to call that procedure using the bean. Also, the syntax of calling that procedure using CallableStatement. I believe, I would have to use Bean Managed Persistence (BMP) if I want to use CallableStatement. I am fooling around with it right now and would let you know if I am getting any exceptions or errors. Meanwhile, any help on the syntax of calling the stored proc. would be highly appreciated.
    Thanks in advance
    Ashish

  • PLS-00306:NET to call Oracle stored procedure,Use Array parameters

    Development Environment:Windows 2003 SP2+Oracle 10g
    . NET to call Oracle stored procedure, use an array of types of parameters
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    OR
    CREATE OR REPLACE type string_array is table of nvarchar2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    ODP.NET(Oracle 10g)
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[2] { "11", "222" };
    cmd.ArrayBindCount=2;
    OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p1.Value = str;
    p1.ArrayBindSize=new int[2]{2,3};
    p1.ArrayBindStatus = new OracleParameterStatus[2]{
    OracleParameterStatus.Success,
    OracleParameterStatus.Success
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
    p2.Direction = ParameterDirection.Output;
    P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p2.Value=0;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored

    Hi,
    See the answer in [this thread|http://forums.oracle.com/forums/thread.jspa?threadID=909564&tstart=0]
    Hope it helps,
    Greg

  • Compile Stored Procedure using JDBC ?

    I am using JDBC thin driver and able to create stored procedure without any problem.
    But if the stored procedure is invalid, it
    won't throw SQLException during creation.
    Is there any way that I can compile the
    stored procedure and catch the semantic exception during creation ?
    Please help, thanks.
    null

    The only thing that springs to mind is the user_errors view. If the procedure fails to compile, then there will be rows in this view indicating the error ..... so maybe you could use
    select count(*) from user_errors
    and check from Java that 0 is returned.

  • . NET to call Oracle stored procedure, use an array of types of parameters

    . NET to call Oracle stored procedure, use an array of types of parameters
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    Use System.Data.OracleClient
    C# Code:
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[] { "11", "22" };
    OracleParameter p1 = new OracleParameter("i_test", OracleType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.Value = str;
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleType.Int32);
    p2.Direction = ParameterDirection.Output;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored
    Edited by: user10133982 on Jun 4, 2009 7:13 AM

    . NET to call Oracle stored procedure, use an array of types of parameters
    The use of ODP.net(Oracle 10g), the error is still the same
    Step1:(In the Oracle database define an array of types)
    CREATE OR REPLACE TYPE STRING_VARRAY AS VARRAY (1000) OF NVARCHAR2(255)
    Step2:
    CREATE OR REPLACE PROCEDURE Test
    (i_test in string_varray,o_result out int)
    IS
    BEGIN
    o_result:=i_test.count;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    o_result:=0;
    END arraytest;
    Step3:
    ODP.NET(Oracle 10g)
    OracleConnection conn = new OracleConnection("User Id=test;Password=test;Data Source=test");
    OracleCommand cmd = new OracleCommand("Test", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    string[] str = new string[2] { "11", "222" };
    cmd.ArrayBindCount=2;
    OracleParameter p1 = new OracleParameter("i_test", OracleDbType.NVarChar);
    p1.Direction = ParameterDirection.Input;
    p1.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p1.Value = str;
    p1.ArrayBindSize=new int[2]{2,3};
    p1.ArrayBindStatus = new OracleParameterStatus[2]{
    OracleParameterStatus.Success,
    OracleParameterStatus.Success
    cmd.Parameters.Add(p1);
    OracleParameter p2 = new OracleParameter("o_result", OracleDbType.Int32);
    p2.Direction = ParameterDirection.Output;
    P2.CollectionType = OracleCollectionType.PLSQLAssociativeArray;
    p2.Value=0;
    cmd.Parameters.Add(p2);
    int i = 0;
    try
    conn.Open();
    cmd.ExecuteNonQuery();
    i =(int) p2.Value;
    catch (Exception ex)
    finally
    conn.Close();
    Error:
    Execution Failed:ORA-06550:Line 1,Column 7:
    PLS-00306:Test parameters when calling the number or types of errors
    ORA-06550:Line 1,Column 7:
    PL/SQL:Statement ignored
    Edited by: user10133982 on Jun 5, 2009 7:48 AM

  • Retrieving PL/SQL Table Type returned by stored procedure using Java.

    Hi All,
    I am facing an issue in a Stored Procedure (SP) which returns Table Type, the PL/SQL complex type.
    Below mentioned is how my stored procedure looks like.
    CREATE OR REPLACE package sp_test_pkg as
    TYPE v_value_table_type is table of SW_VALID_CODE.swValue%Type
    index by binary_integer;
    v_swRMAStatus v_value_table_type;
    procedure sp_test
    (locale      in int,
              name      in SW_CODE.swName%Type,
              v_value_table out v_value_table_type,
    batch_size in int,
    out_batch_size in out int,
    status out int);
    end sp_test_lcode_code_pkg;
    My java program to access this stored procedure is as given below:
    import java.sql.*;
    import oracle.jdbc.driver.*;
    public class OracleTest {       
         public static void main(String args[]) {
         Connection con = null;
    OracleCallableStatement cstmt = null;
    String url = "url";
         String userName = "username";     
         String password = "password";
    try
              DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());     
              con = DriverManager.getConnection(url, userName, password);
         cstmt = (OracleCallableStatement)con.prepareCall("begin " +
              "sp_test_pkg.sp_test_pkg(?,?,?,?,?,?); end;");
              cstmt.setInt(1, 1);
         cstmt.setString(2, "Test");
              cstmt.registerOutParameter(3, OracleTypes.ARRAY);
              cstmt.setInt(4, 10);
              cstmt.setInt(5, 1);
              cstmt.registerOutParameter(5, Types.INTEGER);
              cstmt.registerOutParameter(6, Types.INTEGER);
              cstmt.execute();
    } catch(Exception ex) {
    ex.printStackTrace(System.err);
    } finally {
    if(cstmt != null) try{cstmt.close();}catch(Exception _ex){}
    if(con != null) try{con.close();}catch(Exception _ex){}
    When i execute this java program, i get the following error:
    java.sql.SQLException: Parameter Type Conflict: sqlType=2003
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:187)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:229)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterBytes(OracleCallableStatement.java:245)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:389)
         at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:452)
         at OracleTest.main(OracleTest.java:49)
    I am not sure where i am going wrong. I have never worked on such complex types before. I want to retrieve the complex table type returned by the stored procedure using my java source code.
    Can anyone please help me out in resolving this issue?. This is very urgent.

    JDBC does not recognise types declared in PL/SQL. This is documented in the Dev Guide. [Find out more|http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraarr.htm#1057625].
    The only work around would be to build a wrapper which calls your existing PL/SQL procedures and returns a SQL type instead. Obviously not knowing your precise scenario I have no idea how much work this entails for you. It may be worth building a code generator.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Creating Stored Procedure in Java

    Hi All,
    I would like to ask how to create a stored procedure in Java.
    My project now is to create a program that will open a DB2 SQL File (Creating Table and Stored Procedure) and then Execute it.
    Executing the CREATE TABLE command is not that difficult since I can break the execution down by statement (divide by ";" in the SQL file).
    The logic I applied here are:
    1. Open the SQL file and store the contents into a String object.
    2. Call the executeUpdate(string_sql_fileContent) method of Statement Object.
    Example: SQL File contect to be executed.
    ===========================================================
    CREATE TABLE MDMTEST.sample
    (firstname CHARACTER(40),
    middlename CHARACTER(40),
    lastname CHARACTER(40),
    idNo SMALLINT NOT NULL
    DATA CAPTURE NONE;
    #SYNC 10;
    ALTER TABLE MDMTEST.sample
    LOCKSIZE ROW
    APPEND OFF
    NOT VOLATILE;
    #SYNC 20;
    ALTER TABLE MDMTEST.sample
    ADD PRIMARY KEY
    (idNo
    #SYNC 30;
    RUNSTATS ON TABLE MDMTEST.sample
    AND INDEXES ALL
    SHRLEVEL REFERENCE;
    ===========================================================
    I can divide this by ";" and execute them by statement.
    But my problem is when creating Stored Procedure... Since in stored procedure there are so many stub-statements...
    Example: Content of SQL File for creating stored procedure.
    ===========================================================
    CREATE PROCEDURE MDMTEST.DROP_ALL_OBJECTS ( )
    SPECIFIC MDMTEST.SQL051109115453000
    LANGUAGE SQL
    NOT DETERMINISTIC
    CALLED ON NULL INPUT
    MODIFIES SQL DATA
    INHERIT SPECIAL REGISTERS
    BEGIN
         Delete Statement;
         Insert Statement;
         Update Statement;
    END;
    ===========================================================
    Take note there are three statements inside the CREATE..BEGIN.. and END.. (namely Delete, Insert, and Update Statements).
    How can I execute the command for creating the procedure in Java? I believe that creating stored procedures in other databases are almost the same...
    So... anyboby who have tried creating stored procedure in Java?
    Please help me in this... I wanna pass the subject hehe..

    I have used these files as a sample:
    Java Program:
    import java.io.*;
    import java.sql.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import my.db.components.*;
    public class ProcedureUploader {
         private MyDBConnection dbConn=new MyDBConnection();
         private Statement statement;
    public ProcedureUploader() {
         try{
              dbConn.connectDB ("206.206.206.206","12345","DEV","mdmtest","mdmtest");     
              this.statement=dbConn.getStatement ();               
         }catch(SQLException sqle){
              sqle.printStackTrace();
         public String getContents(String fileName) throws IOException{
              File inputFile = new File(fileName);
    FileReader in = new FileReader(inputFile);
    int c; String contents="";
    while ((c = in.read()) != -1) contents+=(char) c;
    in.close();
    return contents;
    public void executeSQLCommand(String file) throws IOException{         
         String command="";
         try{
              command=getContents(file);          
                   statement.executeUpdate(command);
              System.out.println("Command Execution Successful.");     
         }catch(Exception ex){
              System.out.println("There is a problem executing the command. Please check the SQL file and re-execute again.");
              ex.printStackTrace();
    public static void main(String args[]) throws IOException{
         ProcedureUploader uploader=new ProcedureUploader();
         uploader.executeSQLCommand("C:\\I2\\Development\\ProcedureUploader\\sample.sql");
    SQL File:
    CREATE PROCEDURE MDMTEST.sampleProc ( )
    SPECIFIC MDMTEST.sampleProc
    LANGUAGE SQL
    NOT DETERMINISTIC
    CALLED ON NULL INPUT
    MODIFIES SQL DATA
    INHERIT SPECIAL REGISTERS
    delete from SAMPLE;
    commit;
    select * from SAMPLE;;
    #SYNC 10;
    ===========================================================
    The problem is that ... there will be an error:
    ===========================================================
    There is a problem executing the command. Please check the SQL file and re-execute again.
    com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: delete from SAMPLE;;PECIAL REGISTERS
    ;<psm_repeat>
    at com.ibm.db2.jcc.c.fg.e(fg.java:1596)
    at com.ibm.db2.jcc.c.fg.b(fg.java:1160)
    at com.ibm.db2.jcc.b.gb.h(gb.java:217)
    at com.ibm.db2.jcc.b.gb.b(gb.java:46)
    at com.ibm.db2.jcc.b.w.b(w.java:40)
    at com.ibm.db2.jcc.b.vb.f(vb.java:118)
    at com.ibm.db2.jcc.c.fg.m(fg.java:1155)
    at com.ibm.db2.jcc.c.fg.a(fg.java:1865)
    at com.ibm.db2.jcc.c.fg.c(fg.java:517)
    at com.ibm.db2.jcc.c.fg.executeUpdate(fg.java:501)
    at ProcedureUploader.executeSQLCommand(ProcedureUploader.java:44)
    at ProcedureUploader.main(ProcedureUploader.java:54)
    ===========================================================
    But still the procedure will be created but until the first ";" only... OR.. creates a stored procedure having the following lines only.
    ===========================================================
    CREATE PROCEDURE MDMTEST.sampleProc ( )
    SPECIFIC MDMTEST.sampleProc
    LANGUAGE SQL
    NOT DETERMINISTIC
    CALLED ON NULL INPUT
    MODIFIES SQL DATA
    INHERIT SPECIAL REGISTERS
    delete from SAMPLE;
    ===========================================================

  • Unable to get the data from ms sql stored procedures using crystal report 10

    Dear,
    I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
    Please help me.
    Best Regards
    Pankaj
    [email protected]

    Dear,
    I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
    Please help me.
    Best Regards
    Pankaj
    [email protected]

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

Maybe you are looking for

  • Problem in multiple acct. assignment

    Dear cons     While creating a pur. Req. (T-code- me51n) with  Multiple acct.assignment (p). The system gives an error message that Multi acct. assgt. not allowed for ind. cust. req. or engineer-to-order Message no. 06268 Diagnosis Multiple account a

  • Why won't my Samsung Stratosphere Charge??

    I've had a Samsung Stratosphere since late July of 2012. For the most part it hasn't given me any problems. However for the past 3 days the phone has had problems charging. Last night it finally died while I was sleeping, I tried to charge it again,

  • Find user rights related to schema

    hi every body i am stucked in a problem. i have an oracle 9i database release2 on windows server 2003. there is schema IINVENTORY and there is 96 tables in this schema. there are many roles creted in this database. how i can find which roles are crea

  • Not able to connect to Active Directory through Topology manager of ODI

    Hi, We are trying to connect to Active Directory though ODI Topology manager. The details given are : +1. Using LDAP(JNDI) driver:+ username : CN=Administrator JDBC Driver name : com.sun.jndi.ldap.LdapCtxFactory JDBC URL : ldap://ten.mydomain.com:636

  • Downloading OWAS - too big

    Is there a way to downoad the OWAS in smaller pieces like the Server. 181 MB is one big download. I checked the Oracle ftp server. In the OAS directory they have 12 smallers tar's labelled a-l but the total size addes up to ~140 MB which seems to sma