How to test procedures and functions of pl/sql

I am working as a QA basically i got a new assignment of testing functions and procedures, and packeged bodies. Can any one help me in this matter.
Please help me.
Hi i am new to oracle I want to test procedures and functions,
and packaged bodies of pl/sql.

It depends on what you meant by "testing". I guess you need to check that routines (functions, procedures, packages etc) in valid state and execute without errors. The simpliest way is to get some development tool like TOAD (http://www.quest.com), Oracle Maestro (http://www.sqlmaestro.com) or PL/SQL Developer (http://www.allroundautomations.com). You can connect with them to database and look at the routine state VALID or INVALID. You can recompile them, run and even debug. I guess this should be enough.
Alternatively you can do same thing from sqlplus. Of course with lesser comfort. You need to write certain SQL statements. For example i want to find invalid procedures:
SQL> select OBJECT_NAME, OBJECT_TYPE from USER_OBJECTS where STATUS='INVALID';
To check how procedures work you need to execute anonymous PL/SQL block like this:
declare
     /* local variables declaration */
     NAME VARCHAR2(4000);
     PRESIDENT_ID NUMBER(38);
     ID NUMBER(38);
begin
     /* setting up variables */
     NAME:='MICROSOFT';
     PRESIDENT_ID:='BILLY';
     ID:=NULL;
     /* calling routine */
     GEOMETRY.ADD_COMPANY(NAME,PRESIDENT_ID,ID);
end;

Similar Messages

  • How to write procedure or function or any sql statement for requirement

    Hi,
    i have a table named letter,it contains 2 columns named as letter_id and letter_content.
    select * from letter;
    letter_id letter_content
    103 Dear MFR
    103 This is in regards to the attached DM List
    103 Please Credit us after reviewing it.
    103 Thanks
    103 Regards
    103 xxxx
    108 Dear customer
    108 This is to inform that ur DM List is as follows
    108 Credit us according to the Dm after reviewing it.
    108 Thanks
    108 Regards
    108 xxxx
    now my requirement is,i need send a parameter as letter_id to a procedure or function in pl/sql in oracle,the output should be as follows:
    if we will pass parameter(letter_id) = 103 then it displays as follows:
    Dear MFR
    This is in regards to the attached DM List.Please Credit us after reviewing it.
    Thanks
    Regards,
    XXXXX.
    if we will pass parameter(letter_id) = 108 then it should displays as follows:
    Dear customer,
    This is to inform that ur DM List is as follows. Credit us according to the Dm after reviewing it.
    Thanks
    Regards,
    XXXXX.
    ---------------------------------------------------------------------------------------------------------

    i am really appriciate ur help.
    thank u so much for ur suggestions.
    when i am uning line_seq its giving an error
    ORA-00904: "LINE_SEQ": invalid identifier
    so,in my table i had created a sequense named content_seq.
    select * from letter;
    content_seq letter_id letter_content
    1 103 Dear MFR
    2 103 This is in regards to the attached DM List
    3 103 Please Credit us after reviewing it.
    4 103 Thanks
    5 103 Regards
    6 103 xxxx
    7 108 Dear customer
    8 108 This is to inform that ur DM List is as follows
    9 108 Credit us according to the Dm after reviewing it.
    10 108 Thanks
    11 108 Regards
    12 108 xxxx
    then i had used ur code as follows:
    select linefrom ( select content_seq , letter_content || case content_seq when 2 then ' ' || lead(letter_content) over (partition by letter_id order by content_seq) end as line from letter where letter_id = 103 )where content_seq <> 3;
    LETTER_CONTENT
    Dear MFR
    this is in regards to the attached DM List Please credit us after reviewing it
    thanks
    Regards
    EXP
    but when i take letter_id = 108 the format is comming different.it was unable to combine 2lines.
    Message was edited by:
    user579585
    Message was edited by:
    user579585

  • Testing Procedures and Function manually with EXEC / BEGIN..END

    This is what i noticed in SQL*Plus
    while executing Functions and Procedures with OUT parameter.
    1) For functions You can use EXEC like
    variable mybindvar number;
    exec :mybindvar:= gen_shpmt_num(2075490);and this ran successfully
    2) For procedures with OUT parameter using EXEC returned error
    variable mybindvar number;
    exec :mybindvar:= fill_turn_locns(parameter list,.....,OUT_parameter/:mybindvar not included);
    ERROR at line 1:
    ORA-00900: invalid SQL statementBut when i use BEGIN and END for this , it will run successfully
    variable mybindvar number;
    begin fill_turn_locns(parameter list,.....,:mybindvar);
    PL/SQL procedure successfully completed.
    SQL> print mybindvar;
         MYVAR
             1For functions i can use EXEC and for Procedures with OUT parameter i have to use BEGIN ..END. Right?
    Message was edited by:
    M.Zipaj

    This is what i noticed in SQL*Plus
    while executing Functions and Procedures with OUT
    parameter.
    1) For functions You can use EXEC like
    variable mybindvar number;
    exec :mybindvar:= gen_shpmt_num(2075490);and this ran successfully
    2) For procedures with OUT parameter using EXEC
    returned error
    variable mybindvar number;
    exec :mybindvar:= fill_turn_locns(parameter
    list,.....,OUT_parameter/:mybindvar not included);
    ERROR at line 1:
    ORA-00900: invalid SQL statementBut when i use BEGIN and END for this , it will run
    successfully
    variable mybindvar number;
    begin fill_turn_locns(parameter
    list,.....,:mybindvar);
    PL/SQL procedure successfully completed.
    SQL> print mybindvar;
    MYVAR
    1
    or functions i can use EXEC and for Procedures with
    OUT parameter i have to use BEGIN ..END. Right?
    Message was edited by:
    M.ZipajYou try to execute your procedure by assigning the return value to a variable:
    exec :mybindvar:= fill_turn_locns(parameter list,.....,OUT_parameter/:mybindvar not included);
    A procedure should not return a value, you can call your procedure by executing:
    exec fill_turn_locns(parameter list,.....,OUT_parameter/:mybindvar not included);

  • How to test PL/SQL procedures and functions?

    What are the proven ways to test pl/sql procedures and functions? Specifically, procedures and functions that take cursor variables as IN OUT parameter, OR procedure and functions that takes an array as IN parameter?
    Thx.

    HI,
    One way could by using PL/SQL Develper tool, see Tools/Test Manager...
    Also there are others tools, see [Cleaning Up PL/SQL Practices|http://www.oracle.com/technology/oramag/oracle/04-mar/o24tech_plsql.html] and specifically oUnit
    Regards,
    PS: Your question is very general, could you provide an specific example you are trying?
    Edited by: Walter Fernández on Nov 11, 2008 4:04 PM - Adding PS

  • How can I use the procedures and functions in my library

    hello, all
    I have a pl/sql library MYLIB.pld, MYLIB.pll and MYLIB.plx.
    How can I invoke procedures and functions there in JDeveloper?
    Thanks.
    Damon

    I am indeed using ADF BC to re-develop the oracle application.
    Here is my situation:
    We have an oracle form application.
    Our objective is to try to re-use the existing sources in the form application as much as possible:
    1. tons of procedures and functions in a pl/sql library(a file with extension name portfolioLib.pll or portfolioLib.plx);
    2. tons of form-level triggers, data-block triggers and item-triggers;
    3. tons of database stored procedures and triggers;
    After doing a research on JDeveloper, we decide to use ADF Swing+ADF BC to re-develop the application.
    My opinion for the above three kinds of sources in our form application is:
    for 1: we try to move most of procedures and functions into database(except Form build-in);
    for 2: we try to wrap those triggers in a SQLJ class;
    for 3: we try to call database procedures and functions with PreparedStatment or CallableStatement;
    I just do a test on a post-query trigger on a data-block:
    I created a sqlj file, named testSQLJ.sqlj in the test.view package;
    I tried to call it in createInstanceFromResultSet of testDeptVOImpl.java which is test.model package,
    I was told that testSQLJ cannot be found there. why?
    How can I call some classes from test.view package in some classes of test.model?
    I read some documents about how to deal with post-query trigger in JDeveloper: create a view with SQL statement, but it seems that it does not support pl/sql statement there.
    Can you give me some opinion about the above stuff?
    I really appreciate your help.
    Damon

  • How to find out list of procedures and functions inside a package

    How I can find out the list of Procedures and Functions inside a Package.

    Look at ALL_PROCEDURES and ALL_ARGUMENTS.

  • How to get a list of values used in the WHERE filter of stored procedures and functions in SQL Server

    How can I get a list of values (one or more) used in the WHERE filter of stored procedures and functions in SQL Server?
    How can get a list of values as shown (highlighted) in the sample stored procedure below?
    ALTER PROC [dbo].[sp_LoanInfo_Data_Extract] AS
    SELECT   [LOAN_ACCT].PROD_DT,
                  [LOAN_ACCT].ACCT_NBR, 
                  [LOAN_NOTE2].OFCR_CD, 
                  [LOAN_NOTE1].CURR_PRIN_BAL_AMT, 
                  [LOAN_NOTE2].BR_NBR,
    INTO #Table1
    FROM
                    dbo.[LOAN_NOTE1],
                    dbo.[LOAN_NOTE2],
                    dbo.[LOAN_ACCT]
    WHERE
                    [LOAN_ACCT].PROD_DT = [LOAN_NOTE1].PROD_DT
                    and
                    [LOAN_ACCT].ACCT_NBR = [LOAN_NOTE1].ACCT_NBR
                    and
                    [LOAN_NOTE1].PROD_DT = [LOAN_NOTE2].PROD_DT
                    and
                    [LOAN_NOTE1].MSTR_ACCT_NBR = [LOAN_NOTE2].MSTR_ACCT_NBR
                    and
                    [LOAN_ACCT].PROD_DT = '2015-03-10'
                    and
                    [LOAN_ACCT].ACCT_STAT_CD IN
    ('A','D')
                    and
                    [LOAN_NOTE2].LOAN_STAT_CD IN
    ('J','Z')
    Lenfinkel

    Hi LenFinkel,
    May I know what is purpose of this requirement, as olaf said,you may parse the T-SQL code (or the execution plan), which is not that easy.
    I have noticed that the condition values in your Stored Procedure(SP) are hard coded and among them there is a date values, I believe some day you may have to alter the SP when the date expires. So why not declare 3 parameters of the SP instead hard coding?
    For multiple values paramter you can use a
    table-valued parameter. Then there's no problem getting the values.
    If you could elaborate your purpose, we may help to find better workaround.
    Eric Zhang
    TechNet Community Support

  • Use of Procedure and Functions in ADF BC

    Hi,
    In ADF 11g
    1. can I use oracle function and procedures ( having in and OUT parameters) to expose as service interface
    2. if yes , How can this be done. and what are the allowed data types as input to procedure/function and can be returned by procedure/function
    3. How the transaction control will be achieved using ADF BC service interface.
    E.g. one ADF BC creates orders in order details and second creates Order lines in Order lines table. Now if order is created successfully but line creation fails then I want order to be rolled back also.
    Thanks.

    google it out.
    How to get two out param which is used in Procedure
    http://sameh-nassar.blogspot.in/2010/01/create-plsql-function-and-call-it-from.html
    http://adf-tools.blogspot.in/2010/09/adf-function-call-from-el-statement-in.html
    http://adf-tools.blogspot.in/2010/03/adf-plsql-procedure-or-function-call.html
    http://adfhowto.blogspot.in/2010/11/call-db-procedure-or-function-from-adf.html
    Re: use of Procedure and Functions in ADF BC

  • Are the Pl/sql procedure and function atomic by themself

    i want to ask a question does oracle pl/sql procedure and function support Atomicity for the database by themself , or they became atomic incase we call them using begin -- end;

    You appear to be discussing transaction scope which is completely independent of PL/SQL blocks like procedures or how you call procedures. It's all in where commits (or rollbacks) are issued.
    If you have a procedure like this
    CREATE PROCEDURE p1
    AS
    BEGIN
      INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
      INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
    END;where the first statement succeeds and the second statement fails as a result of a duplicate key, there will still be a Foo row in the table but the procedure will have thrown an exception. The caller of the procedure may choose to commit or rollback the change-- that will determine whether the first statement's results are made permanent. If you have a procedure like this,
    CREATE PROCEDURE p1
    AS
    BEGIN
      INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
      commit;
      INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
    END;the commit will make the first insert permanent regardless of whether the second statement fails no matter what the calling code does (that's one reason that putting commits in stored procedures is generally a bad idea-- the caller is in a much better position to know what other uncommitted work has been done and whether it is safe to commit.
    Justin

  • Procedure and Functions from ADF View Layer

    Hi,
    Before i ask my question ,I would like to mention that I have done lot of googling on this topic before asking this question.
    http://adfhowto.blogspot.in/2010/11/call-db-procedure-or-function-from-adf.html
    http://adf-tools.blogspot.ca/2010/03/adf-plsql-procedure-or-function-call.html
    Lot of threads on otn forum too on this topic.
    I m pretty new to ADf too.
    Now most of our logic is in procedures and functions ,so on various events on form(view layer) I need to call procedure and function and then return values back to value layer too.
    Now the approach mentioned in the link above is good whats best approach to return out parameters to view layer considering i will be using either the DbCall class for all calls to procedures and functions
    I am thinking of this approach to Create a view with static fields,and in Model layer set values for these fields and access them in view layer or binding view controls to these fields.
    From View layer i will call the methods in AppmodImpl which will be calling procedure( methods will be exposed as Client Interface)
    Also in few articles i came across generic CallStoredProcedure and CallStoredFunctions.
    But my main concern is how to share out parameters with view layer....can anyone give link of showing application of it on view layer.
    Regards,

    From your subject. am stating that, dont do all those stuff in backing bean. backing bean is 1:1 mapping with your .jpsx or .jsff .
    best approach would be call those things your Application Module(model layer) exposed it. access the method over your pagedef. well said by ram.

  • Procedure and function diff

    procedure compile once and run at manytime untill it s coding changes
    but
    function every time will be complied
    is it true this statement?????????
    any one help me?????????

    softsuresh wrote:
    is it true this statement?????????
    No. It is a smelly statement.
    Where did you hear it? Can you share the URL? Perhaps there are more to this.. (would hope so, else it would mean someone has very twisted and warped views of how code compilation works).
    There are no differences from a PL/SQL compiler and run-time perspective between a function and a procedure - except when it comes to popping the call stack (as a function will always return a value up the call stack, a procedure not). So procedures and functions are treated the same way by the compiler and the run-time engine. There are no differences between the two so large, that requires the one to be recompiled all the time and the other not.

  • Diif between Stored procedure and function

    HI
    I want all the differences between Stored procedure and function.
    Even the basic diff is Procedure does not return any value and Function must be...
    Thansk In advance...

    1) Functions are used for computations where as procedures can be used for performing business logic That's an opinion on usage not an actual difference.
    3) You can have DML(insert,update, delete) statements in a function. But, you can not call such a function in a SQL query.Not true. As User defind functons limitations we can use a function that issues DML in a SELECT statement, if it uses the PRAGMA AUTONOMOUS_TRANSACTION.
    4) Function parameters are always IN, no OUT is possibleEasily refutable...
    SQL> CREATE OR REPLACE FUNCTION my_f (p OUT NUMBER) RETURN DATE
      2  AS
      3  BEGIN
      4     p := to_number(to_char(sysdate, 'DD'));
      5     RETURN sysdate;
      6  END;
      7  /
    Function created.
    SQL> var x number
    SQL> var d varchar2(18)
    SQL> exec :d := my_f(:x)
    PL/SQL procedure successfully completed.
    SQL> print d
    D
    18-NOV-05
    SQL> print x
             X
            18
    SQL>
    Stored Procedure :supports deffered name resoultion Example while writing a stored procedure that uses table named tabl1 and tabl2
    etc..but actually not exists in database is allowed only in during creationNot sure what this one is about...
    SQL> CREATE PROCEDURE my_p AS
      2      n NUMBER;
      3  BEGIN
      4     SELECT count(*) INTO n
      5     FROM tab1;
      6  END;
      7  /
    Warning: Procedure created with compilation errors.
    SQL> sho err
    Errors for PROCEDURE MY_P:
    LINE/COL ERROR
    4/4      PL/SQL: SQL Statement ignored
    5/9      PL/SQL: ORA-00942: table or view does not exist
    SQL>
    7) A procedure may modifiy an object where a function can only return a value.An ounce of test is worth sixteen tons of assertion...
    SQL> CREATE OR REPLACE FUNCTION my_f2 RETURN VARCHAR2
      2  AS
      3  BEGIN
      4       EXECUTE IMMEDIATE 'CREATE TABLE what_ever (col1 number)';
      5      RETURN 'OK!';
      6  END;
      7  /
    Function created.
    SQL> exec :d :=  my_f2
    PL/SQL procedure successfully completed.
    SQL> desc what_ever
    Name                                      Null?    Type
    COL1                                               NUMBER
    SQL> I think there are only two differences between a procedure and a function.
    (1) A function must return a value
    (2) because of (1) we can use functions in SQL statements.
    There are some minor difference in allowable syntax but they are to do withj RETURN values.
    Cheers, APC

  • Unit testing, integration and functional testing

    Hello all,
    I would like to know the difference between Unit testing, integration and functional testing. And also what are the testing tools that are more commonly used?
    Thanks,
    Maxx

    Hi,
        Unit testing :
                    A complete cycle of each  module will be tested
                    ie for PP Right from requirements to planned orders /production orders
                    confirmation .
        Integration testing:
                    Here cross module testing will be carried out.
                     ie PP and MM integration
                        After confirming production order a GR is made /billing is carried out
                        and delivered.
          Functional testing:
                    This testing is carried out to see whether the system can with stand l the loads during processing by users.
                    Stress test and volume test.
                Regards,
                nandha

  • Differences between procedures and functions.

    a little confusing ..in differences between procedures and functions..
    1. Can a function return only single value?? cant we return multiple values?
    2. Can we use 'out' parameter and 'return' clause at a time in the same function
    thank you

    Hi,
    newbie wrote:
    a little confusing ..in differences between procedures and functions..
    1. Can a function return only single value?? cant we return multiple values?Yes, a function can only return a single value.
    If the return type is some kind of collection or data structure, then that 1 collection or data structure can, of course, actually contain many sep[arate values.
    If you want to return multiple values, use a PROCEDURE with multiple OUT arguments.  (Functions can have OUT arguments, too, but avoid defining functions with OUT arguments.  It can cause a lot of confusion.)
    2. Can we use 'out' parameter and 'return' clause at a time in the same functionSure, but don't take my word for it.  Try it and see.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • What is the difference between procedure and function?

    Hi,
    i want to know the difference between procedure and function.
    Also, i want to know types(if they exists) of procedures and functions .
    Regards

    Also, please try and use the SEARCH functionality offered by the forum, it's always possible someone has asked the question before you.
    Functions vs Stored Procedures
    Is one such instance.

Maybe you are looking for

  • Project Takes FOREVER to Open and Close

    We have a large RoboHTML project that outputs to a WebHelp system. The version of RoboHelp is X 5, possibly a version after that, I think - but dated 2004. Two of us share this project, but we don't use Version Control. The size of the project is abo

  • New ipod classic , how do i get movies on it

    Hi there, i recently got myself a new 80gb classic and i'm trying to get movies onto it but itunes only recognises about 3 of my movies ( they are all paid for and legit) it says these are in the wrong format as well. Does anyone know any way i could

  • User-Exit message for Purchase Order

    Hello, I've implemented a specific type of message (ZNEU) for purchase order. With some specifics conditions (not managed in SPRO), I'd like that the ouput message of a purchase order is either the standard one NEU or my specific ZNEU..but noth both

  • Upgrade to oracle 9i from oracle 8

    hi gurus, Earlier we have running our database on oracle 8.0.4. Now we want to upgrade it to Oracle 9i release 1. Which will be the best way to migrate the data. Should i take full export of oracle 8 and import it to oracle 9i? I want to access the d

  • HT5312 Security Questions Problem.

    I would like to know why the link '' send security info'' to reset my questions is not appearing since I already have 2 rescue emails, thank you.