How to Create a Stored Procedure in Oracle

I try to create a very simple Stored Procedure from Oracle SQL Developer, got the following error. Can someone give me some help on this? I am new on this. Thanks.
Error(4,1): PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: := ( ; not null range default character The symbol ";" was substituted for "BEGIN" to continue.
create or replace PROCEDURE Test
AS ACCESSTYP_ID ACCESSTYP.ACCESSTYPCD%TYPE
BEGIN
     SELECT ACCESSTYPCD
     INTO ACCESSTYP_ID
     FROM ACCESSTYP
     WHERE ACCESSTYPCD = 'WWW';
END;

I found out I forgot to put ";" after the declare.
How do I test it call this stored procedure from
Oracle SQL Developer.
create or replace PROCEDURE Test_VL
AS ACCESSTYP_ID
ACCESSTYP.ACCESSTYPCD%TYPE;
     SELECT ACCESSTYPCD
     INTO ACCESSTYP_ID
     FROM ACCESSTYP
     WHERE ACCESSTYPCD = 'WWW';
END;in your SQL Developer window just enclosed your procedure with a Begin ... End.
  Begin
    Test_VL;
  End;

Similar Messages

  • How to create java stored procedure from oracle(Dastageer)

    how to create java stored procedure from oracle-please help me to create the procedure.

    Hi,
    This forum is exclusively for discussions related to Sun Java Studio Creator. Please post your question in the appropriate forum.
    Thanks,
    RK.

  • How to use a stored procedure in oracle reports

    How to use a stored procedure in oracle reports

    Dear,
    In report triggers you can write your procedure/functions or call it like
    function AfterPForm return boolean is
    begin
    myprocedure(:mydate);
    return (TRUE);
    end;
    Thanks
    Jamil

  • How to create a stored procedure and use it in Crystal reports

    Hi All,
    Can anyone explain me how to create a stored procedure and use that stored procedure in Crystal reports. As I have few doubts in this process, It would be great if you can explain me with a small stored proc example.
    Thanks in advance.

    If you are using MSSQL SERVER then try creating a stored procedure like this
    create proc Name
    select * from Table
    by executing this in sql query analyzer will create a stored procedure that returns all the data from Table
    here is the syntax to create SP
    Syntax
    CREATE PROC [ EDURE ] procedure_name [ ; number ]
        [ { @parameter data_type }
            [ VARYING ] [ = default ] [ OUTPUT ]
        ] [ ,...n ]
    [ WITH
        { RECOMPILE | ENCRYPTION | RECOMPILE , ENCRYPTION } ]
    [ FOR REPLICATION ]
    AS sql_statement [ ...n ]
    Now Create new report and create new connection to your database and select stored procedure and add it to the report that shows all the columns and you can place the required fields in the report and refresh the report.
    Regards,
    Raghavendra
    Edited by: Raghavendra Gadhamsetty on Jun 11, 2009 1:45 AM

  • How to Create a Stored Procedure

    Hi,
    how can we create a new stored procedure using a text editor and the saving it as a file. Please assume that i am just a beginner with oracle.

    You can create the stored procedure in a text editor, then run the saved file via SQL*Plus. If you have saved the file you can use the @ symbol to have Oracle run the script.
    c:\> sqlplus <<user name>>/<<password>>@<<TNS alias>>
    SQL> @<<path to file>>will start SQL*Plus and run the script you just created.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to create a stored procedure that accepts an array of args from Java?

    I am to be creating a stored procedure that accepts an array of arguments from Java. How to create this? thanks
    Sam

    Not a PL/SQL question really, but a Java one. The client call is done via ThinJDBC/OCI to PL/SQL, This call must be valid and match the parameters and data types of the PL/SQL procedure.
    E.g. Let's say I define the following array (collection) structure in Oracle:
    SQL> create or replace type TStrings as table of varchar2(4000);
    Then I use this as dynamic array input for a PL/SQL proc:
    create or replace procedure foo( string_array IN TStrings )...
    The client making the call to PL/SQL needs to ensure that it passes a proper TStrings array structure.. The Oracle Call Interface (OCI) supports this on the client side - allowing the client to construct an OCI variable that can be passed as a TStrings data type to SQL. Unsure just what JDBC supports in this regard.
    An alternative method, and a bit of a dirty hack, is to construct the array dynamically - but as this does not use bind variables, it is not a great idea.
    E.g. the client does the call as follows: begin
      foo( TStrings( 'Tom', 'Dick', 'Harry' ) );
    end;Where the TStrings constructor is created by the client by stringing together variables to create a dynamic SQL statement. A bind var call would look like this instead (and scale much better on the Oracle server side):begin
      foo( :MYSTRINGS );
    end;I'm pretty sure these concepts are covered in the Oracle Java Developer manuals...

  • How to create a stored procedure that contains all 3 AFTER Triggers Update/Insert/Delete ?

    Hi guys, I'm trying to create a Stored procedure that will automatically add all 3 After triggers when executed on any given database, can someone please explain and give an example on how do I go about doing this ? I'd also like it to raise any errors
    that may come across, thanks in advance.

    Lets start with the question why do you need the triggers at all. Since SQL Server 2005 we can use an OUTPUT clause.
    This code can be re-written in SQL Server 2005 using the OUTPUT clause like below:
    create table itest ( i int identity not null primary key, j int not null unique )
    create table #new ( i int not null, j int not null)
    insert into itest (j)
    output inserted.i, inserted.j into #new
    select o.object_id from sys.objects as o
    select * from #new
    drop table #new, itest;
    go
    Now from this example, you can see the integration of OUTPUT clause with existing DML syntax.
    Another common scenario is auditing of data in a table using triggers. In this case, the trigger uses information from the inserted and updated tables to add rows into the audit tables. The example below shows code that uses OUTPUT clause in UPDATE and DELETE
    statements to insert rows into an audit table.
    create table t ( i int not null );
    create table t_audit ( old_i int not null, new_i int null );
    insert into t (i) values( 1 );
    insert into t (i) values( 2 );
    update t
       set i  = i + 1
    output deleted.i, inserted.i into t_audit
     where i = 1;
    delete from t
    output deleted.i, NULL into t_audit
     where i = 2;
    select * from t;
    select * from t_audit;
    drop table t, t_audit;
    go
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to create a stored procedure in a dynamic schema

    Hi,
    I want to create a stored procedure in a dynamic shcema (schema name will be known at run time). Can any one guide me on this.
    I tried using define var1=schema1; and then in create or replace procedure &var1.porcName( ) but it is not working
    Thanks

    SQL> alter session set current_schema=<my schema>;
    Now create the stored procedure. It will be created in the session's current schema.

  • How to create minimal stored procedure?

    What is the preferred way of creating stored procedures? Can I use SQL Developer or SQLPlus?
    I'm running version 11.2.0.1.0.
    Here is my attempt in SQLDeveloper:
    CREATE OR REPLACE PROCEDURE hello ()
    BEGIN
    dbms_output.put_line('Hello, World!');
    END;
    SET SERVEROUTPUT ON;
    SELECT hello() from DUAL;
    When I hit F5 it says
    Warning: execution completed with warning
    PROCEDURE hello Compiled.
    When I select the last line and hit F9 I get a dialog box that says:
    An error was encountered performing the requested operation:
    ORA-00904: "HELLO" invalid identifier
    00904.0000 - "%s: invalid identifier"
    *Cause:
    *Action:
    Vendor code 904 Error at line:8 column 7
    I tried using SQL plus but since I'm having trouble just logging in, I already posted my query in the SQLPlus forum.
    Thanks,
    siegfried

    user8816970 wrote:
    What is the preferred way of creating stored procedures? Can I use SQL Developer or SQLPlus? Yes.
    A "minimal" procedure would be:
    create or replace procedure TestProc as
    begin
      null;
    end;Also get the whole pascalcase, camelcase and lowercase correct. Do not code in uppercase - it not only looks stupid, it contravenes programming standards that existed since the 70's and are still applicable and used today. From Microsoft's .Net to Java and /C/C++ and Pascal/Delphi and Visual Basic and most other languages. It is just plain silly to code in uppercase. Cobol standards do not apply today and were intended for punch cards - which is why I find this whole code-reserve-words-in-uppercase approach used in PL/SQL, flawed and idiotic.
    When I select the last line and hit F9 I get a dialog box that says:
    An error was encountered performing the requested operation:That is because PL/SQL procedures need to be executed via an anonymous PL./SQL block. You need use (enter) the following code block on the client side to be send to Oracle for parsing and execution:
    begin
      Hello;
    end;Some clients, like SQL*Plus, supports a client EXEC command. This takes the parameter supplied to the EXEC command and wrap that into an anonymous block like above.
    You can only execute PL/SQL functions via the SQL language. Quite important that you do not confuse languages at this level. Some clients (like SQL*Plus) have their own client commands like EXEC and HOST and SPOOL. These client commands are not PL/SQL or SQL.
    PL/SQL and SQL are also two different languages. PL/SQL combines Programming Language with SQL in a very integrated and transparent way. However. PL is executed by the PL engine and SQL is executed by the SQL engine.
    Lastly, make sure you understand what DBMS_OUTPUT does. It does not write anything to the client's display device. It is server code running in a server process. It cannot hack across the network to do stuff on the client - like reading a file or displaying something.
    The put_line() procedure of DBMS_OUTPUT writes text data into a static PL/SQL variable. The more you write into it, the more expensive server memory is consumed by that server process. When the server process has completed the client call (SQL statement or PL/SQL call), the client can then interrogate this buffer variable, read it, display the contents itself, and clear the buffer variable.
    It's important to understand what client-server is and how it applies to what you are doing using Oracle as a server.

  • How to migrate MySQL stored procedure to Oracle

    Hi All,
    I migrated mysql 5.1.42-enterprise-gpl-advanced DB to oracle using sqldeveloper 3.1.07 tool.
    DB objects migrated successfully except Stored Procedures.
    I verified .sql and Out files.. Capture process not captured stored procedures SQL.
    Could you please suggest, where I can verify exact error or how to fix this issue.
    Thanks in advance.

    Hi,
      The SQL*Developer version you are using is an old one and you should use the latest version available from this link -
    Oracle SQL Developer
    However, even the v4 version does not support the migration of MySQL stored procedures as shown in this link -
    http://www.oracle.com/technetwork/developer-tools/sql-developer/supportedmigplatforms-086703.html
    You will have to manually convert the MySQL stored procedures to an Oracle format, as even the 'Scratch Editor' under 'Tools - Migration' - does not have an option for MySQL conversion.
    The documentation has details of the difference between MySQL and Oracle stored procedures -
    Oracle® SQL Developer Supplementary Information for MySQL Migrations
    in the chapter Triggers and Stored Procedures
    Regards,
    Mike

  • How to call MSSQL stored procedure from oracle database

    MSSQL and Oracle databases are linked thru ODBC link using Oracle HSODBC.
    I can query MSSQL table or view from Oracle Database using standard notation for acessing remote objects schema.object@dblink_name...
    Can anybody give me syntax for calling MSSQL stored procedure thru ODBC database link?
    I tried syntax exec schema.stored_procedure@dblink_name but it doesn't work...i'm getting schema.stored_procedure must be declared error...
    Tnx,in advance!
    Dejan Botica

    Oracle database 10gR2.
    MSSQL2000 database.
    For example query:
    select * from dbo.Tbl_Test@kron@dw_jamnica; works fine...
    ...while for example exec dbo.Test@kron@dw_jamnica;
    reports error:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'DBO.TEST@KRON@DW_JAMNICA' must be declared
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Table Tbl_Test and procedure Test exists in MSSQL instance.
    Regards,
    Dejan

  • Stored procedure in Oracle 8.1.7.0

    HI,
    my oracle version is 8.1.7.0
    I've created this stored procedure:
    CREATE OR REPLACE procedure CREATE_TAB1
    IS
    SVUOTA VARCHAR2(64);
    PRAGMA AUTONOMOUS_TRANSACTION;
    err_num number;
    err_msg varchar2(100);
    BEGIN
    SVUOTA := 'TRUNCATE TABLE TAB1 REUSE STORAGE';
    EXECUTE IMMEDIATE SVUOTA;
    INSERT INTO TAB1
    SELECT "COD_IMM","PIANO","COD_RITMI","TOTAL_AREA","MAX_AREA"
    FROM (SELECT a.*,
    MAX(total_area) OVER (PARTITION BY cod_imm, piano) max_area
    FROM REP_02_TEST1 a
    where a.COD_RITMI not in ('04'))
    WHERE max_area = total_area;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    err_msg:= SUBSTR(SQLERRM, 1, 100);
    err_num:= SQLCODE;
    INSERT INTO tab_error (proc_name, err_code, err_msg, err_date)
    VALUES ('CREATE_TAB1', err_num, err_msg, sysdate);
    COMMIT;
    END CREATE_TAB1;
    but when I compile I get this error
    PROCEDURE AFM.CREATE_TAB1
    On line: 14
    PLS-00103: Encountered the symbol "(" when expecting one of the following:
    , from
    the procedure stop on line:
    MAX(total_area) OVER (PARTITION BY cod_imm, piano) max_area
    I think that oracle version 8.1.7.0 not allow the code "OVER (PARTITION BY"
    I tried also with:
    EXECUTE IMMEDIATE 'INSERT INTO TAB1
    SELECT "COD_IMM","PIANO","COD_RITMI","TOTAL_AREA","MAX_AREA"
    FROM (SELECT a.*,
    MAX(total_area) OVER (PARTITION BY cod_imm, piano) max_area
    FROM REP_02_TEST1 a
    where a.COD_RITMI not in ('04'))
    WHERE max_area = total_area';
    but I get:
    PROCEDURE AFM.CREATE_TAB1
    On line: 16
    PLS-00103: Encountered the symbol "04" when expecting one of the following:
    How can I create my stored procedure with Oracle version 8.1.7.0
    Thank in advance!

    What is this code suppose to accomplish?
    Is this type of processing not possible using Global Temporary Tables?
    Oracle8i PL/SQL did not parse analytic functions correctly so you would have to make that SELECT a view and then SELECT from that view in PL/SQL.
    I tried also with:When you wrap the SELECT in EXECUTE IMMEDIATE you have to properly use the single quotes. The single quote that appears at this line:
    where a.COD_RITMI not in ('04'))is assumed by the compiler as the end of the string started by EXECUTE IMMEDIATE. That is not what you want.
    Please post some more details about the type of procesing that this code is suppose to accomplish so we can suggest alternatives to get it done better.

  • How do write a stored Procedure in PL/SQL

    Hi,
    I am new to this forum. I am creating a webpage using Gridview in Visual Studio 2005.
    How to write a Stored procedure in Oracle using PL/SQL?
    I want to write a SP for the following query :
    "Select S_No, Task_ID,Last_Act_Dt,Last_Act_Tm,Status from E002 Order by S_No"
    Please help.

    In Oracle, you normally wouldn't create a stored procedure that just does a query. Depending on what you're attempting to do on the client side, and the client libraries involved, you may be able to write a stored procedure that returns a REF CURSOR and call that. This will put some limitations on what the client can do with the results, for example. The data would be read-only and scrolling back and forth in the result set would potentially rather slow and rather expensive in terms of client memory. That makes this generally a somewhat unattractive option.
    You could create a view in Oracle and just query the view in your application code. If you needed to change the query, you could then just change the view.
    Justin

  • Stored Procedure in Oracle 8

    Hi, I create a stored procedure in Oracle 10g and I want to run this same procedure in Oracle 8. Anybody knows the syntax for this procedure in Oracle 8?
    Here are the stored procedure:
    create or replace PROCEDURE Sp06_Rel_Acoes_Usuario (dt_inicio IN VARCHAR2, dt_fim IN VARCHAR2, filtro IN VARCHAR2, v_cursor OUT sys_refcursor)
    IS
    BEGIN
         OPEN v_cursor FOR
              SELECT A.AD013_DTOCORRENCIA, A.AS013_APLICATIVO, A.AS002_CDUSUARIO, A.AS013_DADOADICIONAL, AC.AS012_DSACAO
              FROM T013_ACAOUSUARIO A, T012_ACAO AC
         WHERE A.AD013_DTOCORRENCIA BETWEEN TO_DATE(dt_inicio,'dd/mm/yyyy HH24:MI:SS') AND TO_DATE(dt_fim,'dd/mm/yyyy HH24:MI:SS')
              AND A.AS002_CDUSUARIO = filtro AND A.AN012_CDACAO = AC.AN012_CDACAO                     
              ORDER BY A.AD013_DTOCORRENCIA;
    END;

    I'm pasting your code in proper format - so that everyone can understand what you have posted here.
    create or replace PROCEDURE Sp06_Rel_Acoes_Usuario (dt_inicio IN VARCHAR2,
                                                        dt_fim IN VARCHAR2,
                                                        filtro IN VARCHAR2,
                                                        v_cursor OUT sys_refcursor)
    IS
    BEGIN
      OPEN v_cursor FOR
      SELECT A.AD013_DTOCORRENCIA,
             A.AS013_APLICATIVO,
             A.AS002_CDUSUARIO,
             A.AS013_DADOADICIONAL,
             AC.AS012_DSACAO
      FROM T013_ACAOUSUARIO A, T012_ACAO AC
      WHERE A.AD013_DTOCORRENCIA BETWEEN TO_DATE(dt_inicio,'dd/mm/yyyy HH24:MI:SS')
      AND TO_DATE(dt_fim,'dd/mm/yyyy HH24:MI:SS')
      AND A.AS002_CDUSUARIO = filtro
      AND A.AN012_CDACAO = AC.AN012_CDACAO
      ORDER BY A.AD013_DTOCORRENCIA;
    END;Try to post script in proper format. It will be easier for everyone to go through your problem and debug it.
    Regards.
    Satyaki De.

  • How to write a stored procedure call to write to a db

    Hi All,
              Could you pls tell me how to create a stored procedure call to write to a DB?
    XIer

    Xler,
    If you want to learn...more details..
    http://en.wikipedia.org/wiki/Stored_procedure
    You can ask SQL Developer to write SP for you....
    Nilesh

Maybe you are looking for

  • Partner number (SPDNR) in Purchasing Condition

    Hi Folks We have a requirement for inbound freight on purchasing where we want to create a condition based on following characteristics. LIFNR-Vendor SPDNR-Carrier ZZKVGR1-Mode of transp WERKS-Plant INCO1-Incoterms I added field SPDNR in field catalo

  • Problem uploading Array with RPC

    Hi to everyone, I developed my flex application for Glasfish. Glasfish webservices are in document litteral format. Now I need to deploy on Jboss which webservices are in rpc litteral format. That is what flex application logs when i try to send a va

  • StorEdge 3310 RAID hung.

    During the billing run on a Sun Fire V440, the attached 3310 hung. Reboots of the server did nothing to improve the situation, but once the RAID was powercycled everything was alright again. sccli version 2.1.1 built 2005.09.16.23.10 build 1 for sola

  • NullPointerException in EntityEJBContext - WL 4.5.1

    Hi people WL 4.5.1 SP 14 on Solaris. We are getting these two exceptions rather often: Wed Nov 21 13:07:18 CET 2001:<I> <EJB> Ignoring exception raised in ejbPassivate: java.lang.NullPointerException at weblogic.ejb.internal.EntityEJBContext.passivat

  • IPhoto - making a book

    I have created a Hardcover book in iPhoto and want to change it to a softcover instead, how do I do this without having to re-create a new book?