How to test the stored procedure in SQL Developer or SQL Plus

Hello

It's small, but I am confused. Can someone give me the EXACT command to run to test my stored procedure described below. Please don't refer me to the documentation or offer some sort of pseudocode. I've been through the documentation - and through it again - and I just don't get it. I know that the procedure works in general because I'm calling ColdFusion, but I want to test developer SQL or SQL more before I call my ColdFusion page - it only makes sense. I'm probably not initialize variables right or something - not sure.

You will see that it is a line right insert in the firstname and lastname data base and there are 2 IN OUT values as well. Please use a fake name for the firstname and lastname values to demonstrate. I appreciate it!

create or replace
procedure sp_insertDirector_A)
vFirstname IN Directors.Firstname%TYPE,
vLastname IN Directors.Lastname%TYPE,
vInsertStatus in on NUMBER,
vNewDirectorID IN OUT NUMBER
)
IS
row_count NUMBER;
BEGIN
SELECT Count (*) FROM directors WHERE Lastname vLastname = row_count;
IF row_count > 0 THEN
vInsertStatus: = - 1;
RETURN;
END IF;

INSERT INTO administration)
FirstName, Lastname)
VALUES)
vFirstname, vLastname
);

SELECT Directors_Seq.CURRVAL INTO vNewDirectorID FROM DUAL;
vInsertStatus: = 1;
END;

If someone can tell me exactly how to test, I'd appreciate it. I asked on another site and got many responses that I tried and did not work due to various errors. Once I get a working example, I'm sure I can get the idea and continue on. I mainly use the SQL Developer.

Thank you, mallethead

p.s. I think that my if - THEN followed by the instruction INSERT is fixed - it is woring. Seems a little odd to me however.
declare
   l_instatus  number;
   l_newdirid  number;
begin
   sp_insertDirector_A('bob','smith',l_instatus,l_newdirid);
   dbms_output.put_line(l_instatus);
   dbms_output.put_line(l_newdirid);
end;
/

Tags: Database

Similar Questions

  • How to call a stored procedure PL/SQL of the Disqualification?

    I figured I could do this from a Groovy script but I am unable to make it work.

    Let's take the simplest scenario:

    At the end of a job, I have a need to call an once stored procedure that has no arguments.

    Translated by the logic of the stored procedure with Disqualification is not an option.

    If you must call it once at the end of a task, you must use the external task.

    If you call a procedure for each record, it can be done using a script.

  • How to show the stored procedure code

    Hello
    How can I get the code for creating a stored procedure using sqlplus instead of sql-developer? I want to get all of the code of the stored procedure. I saw it in writing

    SQL > desc proced_1

    I get the Argument Name, Type and input/output by default of the stored procedure, but if I want to get the code 'create procedure', how can I do?
    Thank you!

    Hai

    Try this

    Select * from user_source where name = 'Procedure_name '.
    online ordering;

    Concerning

    Srikkanth.M

  • How to call the stored procedure from javascript? (Google suggest, AJAX)

    Hi I want to set up a text field so that it behaves like [Google Suggest | http://www.google.com/webhp?complete=1 & hl = en].

    I read this post .

    Now, I installed everything according to this document. But it simply doesn't. And I don't know why.

    I think that problems can fall into the following three categories:
    1. the text field and the page invoking the appropriate javascript?
    2 - is the JavaScript call the stored procedure?
    3. the stored procedure correctly returns the result formatted?

    I'm assertive for 1 and 3, but I'm not sure 2. Because I don't know how if a stored procedure has been called? Is there a PL/SQL statement that I can query in SQL * more?

    Also, I would like to know how to debug AJAX in the APEX. It involves a lot of things.

    Finally, I used APEX 3.2 and Oracle XE. I can't find file dads.conf or marvel.conf. Is ' / apex / "the virtual directory for APEX?

    Thank you very much!

    Buffalo,

    I managed to make it work on XE with APEX 3.2!
    It took more time than expected because my XE installation was still on an earlier version of the Apex and I had put it first...

    But that's what I did:
    -in the ac.js file, I changed the path ' / apex / "and I added the ac.js file to my candidacy as a static file. So as you did.
    -J' copied my request to the XE and copied my procedure on the schema that is related to my request
    -J' gave to run anonymous rights my procedure

    Now at first, it did not work...
    Then I suddenly remembered something: If you want to run a procedure through the pl/sql gateway in the XE, XE please how it is.
    Do you this by changing the APEX_030200.wwv_flow_epg_include_mod_local function!

    This is the code for the function changed for my example:

    CREATE OR REPLACE function APEX_030200.wwv_flow_epg_include_mod_local(
        procedure_name in varchar2)
    return boolean
    is
    begin
        --return false; -- remove this statement when you modify this function
        --
        -- Administrator note: the procedure_name input parameter may be in the format:
        --
        --    procedure
        --    schema.procedure
        --    package.procedure
        --    schema.package.procedure
        --
        -- If the expected input parameter is a procedure name only, the IN list code shown below
        -- can be modified to itemize the expected procedure names. Otherwise you must parse the
        -- procedure_name parameter and replace the simple code below with code that will evaluate
        -- all of the cases listed above.
        --
        if upper(procedure_name) in (
              'MATTHIASH.INCSEARCH') then
            return TRUE;
        else
            return FALSE;
        end if;
    end wwv_flow_epg_include_mod_local;
    /
    

    After that, the AJAX function worked as expected...

    HTH
    Matthias Hoys

    Published by: mhoys on August 13, 2009 15:24

  • Test the stored procedure

    Hello

    I wrote a stored procedure and want to test it now. My procedure is here:

    create or replace PROCEDURE PRC_NEW_FAC_RECORD)

    p_F_ID in NUMBERS

    p_F_LAST IN VARCHAR2,

    p_F_FIRST IN VARCHAR2,

    p_F_MI in TANK,

    p_LOC_ID in NUMBERS

    p_F_PHONE IN VARCHAR2,

    p_F_RANK IN VARCHAR2,

    p_F_SALARY in NUMBERS

    p_F_SUPER in NUMBERS

    p_F_PIN in NUMBERS

    p_F_IMAGE IN BLOB)

    AS

    NUMBER OF F_SALARY;

    BEGIN

    SELECT AVG (P_F_SALARY) * 0.75 IN F_SALARY FROM DUAL;

    INSERT INTO VALUES FACULTY (p_F_ID, p_F_LAST, p_F_FIRST, p_F_MI, p_LOC_ID, p_F_PHONE, p_F_RANK, F_SALARY, p_F_SUPER, p_F_PIN, p_F_IMAGE);

    DBMS_OUTPUT. Put_line ("member of faculty added '");

    END;

    /

    I created a table with the following values:

    Faculty of CREATE TABLE

    (f_id NUMBER (6))

    f_last VARCHAR2 (15).

    f_first VARCHAR2 (15).

    f_mi char (1),

    loc_id NUMBER (5) not null,

    f_phone VARCHAR2 (10),

    f_rank VARCHAR2 (9).

    f_salary number (9,2),.

    f_super NUMBER (6).

    f_pin number 4,

    f_image BLOB,

    Faculty_f_id_pk KEY (f_id) PRIMARY, the CONSTRAINT

    Faculty_loc_id_fk of the CONSTRAINT FOREIGN KEY (loc_id) REFERENCES rental (loc_id));

    How would test my procedure on this table, especially if it is a foreign key?

    This is the insert, I tried to run:

    insert into faculty values ('6', 'John', 'Bonny', have ', '13', '4079347153', 'Full', '80000', ' 2', 6034', Null ");

    But I get an error message.

    Thank you very much for your help

    insert into faculty values ('6', 'John', 'Bonny', have ', '13', '4079347153', 'Full', '80000', ' 2', 6034', Null ");

    It is not necessary to join several columns in single quotes.

    How would test my procedure on this table, especially if it is a foreign key?

    First of all create a record in the location table, note the value of the loc_id column. Then newrecord Insert in the table of the Faculty and either enter NULL or use the loc_id you have noted before for loc_id column in the insert statement.

    If you want to insert data with the procedure, and then run the following statement:

    exec PRC_NEW_FAC_RECORD (6, 'John', ' Bonny ', am', NULL... and so forth);

  • How to call the stored procedure when I press the button

    Hello

    I want to know how to call the procedure/SQL statement when I press the button using callable statement.

    can someone give me it please link who knows the steps to do this.

    Thanks in advance,
    SAN

    Hello

    read this good example http://www.baigzeeshan.com/2010/05/calling-plsql-procedure-and-function-in.html

    ~ Abhijit

  • The stored procedure PL/SQL - t - it accept the custom Ref Cursor type?

    I am not able to compile the following procedure in the HR schema comes with default oracle... I use Oracle 11g Release 11.2.0.2.0 Express edition. It gives me an error (given after the code block):

    Block of code:
    CREATE OR REPLACE PROCEDURE TEST_REF IS
    DECLARE
    TYPE REF_EMP IS REF CURSOR RETURN % ROWTYPE EMPLOYEES;
    RF_EMP REF_EMP;
    V_EMP EMPLOYEES % ROWTYPE;
    BEGIN
    DBMS_OUTPUT. ENABLE (1000000);
    OPEN FOR RF_EMP
    SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID > 100;
    EXTRACT THE RF_EMP IN V_EMP;
    DBMS_OUTPUT. PUT_LINE (V_EMP. FIRST_NAME. ' ' || V_EMP. LAST_NAME);
    CLOSE RF_EMP;
    EXCEPTION
    WHILE OTHERS
    THEN DBMS_OUTPUT. PUT_LINE (SQLERRM);
    END TEST_REF;
    /

    Error:
    Errors in PROCEDURE TEST_REF:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    2/1 PLS-00103: encountered the symbol "DECLARE" when waiting for an a
    What follows:
    Start function < an ID > pragma procedure subtype type
    < between double quote delimited identifiers > delete the current cursor
    There are the external language prior
    The symbol 'start' is substituted for 'DECLARE' continue.

    16/13 PLS-00103: encountered the symbol "end-of-file" when waiting for him
    one of the following values:
    (begin case declare exit end exception for goto if loop mod)
    pragma raise return null select update while with

    Get rid of the DECLARED:

    SQL> CREATE OR REPLACE PROCEDURE TEST_REF IS
      2  TYPE REF_EMP IS REF CURSOR RETURN HR.EMPLOYEES%ROWTYPE;
      3  RF_EMP REF_EMP;
      4  V_EMP EMPLOYEES%ROWTYPE;
      5  BEGIN
      6  DBMS_OUTPUT.ENABLE(1000000);
      7  OPEN RF_EMP FOR
      8  SELECT * FROM EMPLOYEES WHERE EMPLOYEE_ID > 100;
      9  FETCH RF_EMP INTO V_EMP;
     10  DBMS_OUTPUT.PUT_LINE(V_EMP.FIRST_NAME || ' ' || V_EMP.LAST_NAME);
     11  CLOSE RF_EMP;
     12  EXCEPTION
     13  WHEN OTHERS
     14  THEN DBMS_OUTPUT.PUT_LINE(SQLERRM);
     15  END TEST_REF;
     16  /
    
    Procedure created.
    
    SQL> set serveroutput on
    SQL> exec TEST_REF;
    Donald OConnell
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • by using the stored procedure in sql statement?

    I have the following sample tables:

    project id project name
    ====== ===============
    1 project one
    2 two project
    3 three of the project


    employee_id fname lname
    =========== =============     =====
    Amy 100a
    Better B 200
    Carrie 300 C


    project number
    ===========     ===========
    1,200 people
    2 300
    of 3 100

    There's a getFullname (empployee_id) of the procedure in place that combines the fname lname full name

    what I need to accomplish is the following.

    project is created by employee
    ==============================
    project a is created by better b
    two project is created by carrie C
    three project is created by amy A

    but the rule is: you need to call the getFullName (employee_id) procedure to perform the above task and do not use join tables to get the employee full name

    I suspect that you want something along the lines of

    SELECT 'Project ' || p.project_name || ' was created by ' || get_full_name( pe.employee_id )
      FROM project p,
           project_employee pe
     WHERE p.project_id = pe.project_id
    

    If you need other attributes in the employee table, you can join at the table of the employees as well.

    Justin

  • How to execute a stored procedure on Sybase with SQL Developer

    We have accessed Sybase 15 with SQL developer.

    We can see the data in the table, if we do not, run the stored procedure (for instance sp_who) developed on Sybase.

    Could you tell me how we execute the stored procedure on Sybase with SQL Developer Sybase?

    Thank you

    Shige

    We will not intended to be a Sybase ASE customer.

    But

    A SQL Developer... @dermotoneill: Workheet advice

  • Run the stored procedure of c#

    Hi, im new to the use of stored procedures and I have the following stored procedure...

    CREATE OR REPLACE PROCEDURE DRL_PROCEDURE2 (var_SOURCE_OBJECTID IN varchar2, var_NEW_OBJECTID OUT varchar2)
    AS
    BEGIN
    SELECT MAX (NEW_OBJECTID)
    IN var_NEW_OBJECTID
    OF DRL_CONVERSION
    WHERE SOURCE_OBJECTID = var_SOURCE_OBJECTID;
    END;

    I want to be able to call this procedure from my windows form application and display the result of the stored procedure in a label... could someone please help me! Thanks in advance!

    http://www.csharpfriends.com/articles/getarticle.aspx?articleid=78
    You can find out how to call the stored procedure (in the link above you will find an example of SQL Server 2005 that also work for you from your oracle stored procedure) in c#.

    HTH
    Girish Sharma

  • How can I transfer content from an XML file in a MS SQL database of the stored procedure using LabWindows/CVI SQL Toolkit?

    Hello

    I have a problem to transfer content to an XML file in a MS SQL database through a stored procedure data/fixed. I am able to transfer the content of the file using method...

    HSTMT = DBPrepareSQL (hdbc, EXEC usp_InsertReport " ... ");

    resCode = DBExecutePreparedSQL (hstmt);

    resCode = DBClosePreparedSQL (hstmt);

    ... but in this case, I am not able to read the return value of the stored procedure.

    I tried to follow the example of the stored procedure in the help documentation (DBPrepareSQL), but I miss a xml data type?

    No idea how to solve my problem?

    Cake of KR

    DianaS salvation,

    Thanks for your comments. During this time I found another way which fullfill my needs:

    resCode = DBSetAttributeDefault (hdbc, ATTR_DB_COMMAND_TYPE, DB_COMMAND_TEXT);

    sprintf (sz_SqlStatement, "DECLARE @TESTID INT EXEC @TESTID = usp_InsertReport ' SELECT 'RetVal' %s = @TESTID", sz_Buffer ");
    HSTMT = DBActivateSQL (hdbc, sz_SqlStatement);

    While ((resCode = DBFetchNext (hstmt)) == DB_SUCCESS)

    {

    / * Enter values in the record. */

    resCode = DBGetColInt (hstmt, 1, & s32_TestId);
    }

    resCode = DBDeactivateSQL (hstmt);

    sz_Buffer is the content of the XML file.

    Cake of KR

  • How can I force DAC to run always full load for one of the task that executes the stored procedure? And remaining tasks load incremental in the second and sub sequent executions.

    Hello

    How can I force DAC to run always full load for one of the task that executes the stored procedure? And remaining tasks load incremental in the second and sub sequent executions.

    Thank you

    Jay.

    Hi if your task is running an informatica mapping you can set your DAC task to run the full mapping for incremental and full loads, so tab task just point to the mapping.

    Hope that helps.

    Thank you

  • How to view the run log in the stored procedure?

    Hello

    I'm working on a project of migrating from Sybase to Oracle (10g).

    On Sybase, when I run a stored procedure, it will connect to the console as:
    100 rows inserted
    200 rows affected
    ...

    One line per request in the stored procedure.


    Oracle, I only: 'Procedure completed successfully' (Yes, I'm french :-)


    Is there a way to get the logs for each request in my stored procedure?
    -An option?
    -One command after each request?


    Thanks in advance.

    user9321154 wrote:
    OK, it's great.

    Otherwise, there is not an option on Oracle to achieve this same result automatically.

    No, if you want to do this, you must do it yourself. PL/SQL is a real language, not a script like T - SQL language. Therefore, it is the procedure that one is successful or not, not every instruction.

    You should also be aware that if you use % ROWCOUNT SQL to get the number of rows processed and DBMS_OUTPUT. Put_line to show them on the screen, that the output will not appear before once you have completed the process, not as each DBMS_OUTPUT statement is processed.

    If you want to t shelves where in the procedure, you will need to insert the release of record in a table by using an autonomous transaction or something like UTL_FILE use to write the instructions in an o/s file.

    John

  • How to run a stored procedure by using the steps in database?

    Hello

    I'm trying to run some procedures of the store and it will not work.

    See the file attached is seq.

    I have a varchar parameter (50), which must also be provided to the stored procedure and it returns an int.

    To do this I had to only use data in an open statement

  • How to call a stored procedure stored procedure

    Hello Experts,

    I need help, even if stored procedures. I tried to know without a bit of luck. Is it possible to call the stored procedure to another stored procedure? The problem is my boss want me to work on a stored procedure, but I do not have the appropriate privileges. He won't give me permissions either. He suggested that to a stored procedure and call this stored procedure after creating a new procedure. Is this possible? If Yes, how can I do it?

    I thank in advance

    ascheffer wrote:
    Without the "privileges", whatever it is, your features in other nesting procedures won't help.

    Anton

    Unless...

    It goes to an anonymous PL/SQL block to allow him to test its procedures. ;)

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    procedure test_proc(p_var IN VARCHAR2) is
      3    begin
      4      dbms_output.put_line(p_var);
      5    end;
      6  begin
      7    test_proc('This is a test proc');
      8* end;
    SQL> /
    This is a test proc
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

Maybe you are looking for