New to PL/SQL, function question

Hello guys,
I'm new to PL/SQL but have done C# and some Java.
Here is an example from a book I'm using:
declare
     v_pi_nr NUMBER:= 3.14;
     function f_getDiff_Nr(i_rad1_nr NUMBER, i_rad2_nr NUMBER)
     return NUMBER is
          v_area1_nr NUMBER;
          v_area2_nr NUMBER;
          v_out_nr NUMBER;
     function f_getArea_Nr(i_rad_nr NUMBER)
     return NUMBER
     is
     begin
          return v_pi_nr*(i_rad_nr**2); /inner
     end;
     begin
          v_area1_nr:= f_getArea_Nr(i_rad1_nr);
          v_area2_nr:= f_getArea_Nr(i_rad2_nr);
          v_out_nr  := v_area1_nr-v_area2_nr;
          return v_out_nr;             /outer
     end;
     begin
          DBMS_OUTPUT.put_line('Diff between 3 and 4:'||f_getDiff_Nr(4, 3));
          DBMS_OUTPUT.put_line('Diff between 4 and 5:'||f_getDiff_Nr(4, 3));
          DBMS_OUTPUT.put_line('Diff between 5 and 6:'||f_getDiff_Nr(4, 3));
     end;I'm wondering how it works, does outer function (f_getDiff_Nr) run first then passes the result to the inner function (f_getArea_Nr)?
Many thanks,
Mike
Edited by: mharper on 23-Oct-2011 14:35

Hi, Mike,
mharper wrote:
Hello guys,
I'm new to PL/SQL but have done C# and some Java.
Here is an example from a book I'm using:
declare
     v_pi_nr NUMBER:= 3.14;
     function f_getDiff_Nr(i_rad1_nr NUMBER, i_rad2_nr NUMBER)
     return NUMBER is
          v_area1_nr NUMBER;
          v_area2_nr NUMBER;
          v_out_nr NUMBER;
     function f_getArea_Nr(i_rad_nr NUMBER)
     return NUMBER
     is
     begin
          return v_pi_nr*(i_rad_nr**2); /inner
     end;
     begin
          v_area1_nr:= f_getArea_Nr(i_rad1_nr);
          v_area2_nr:= f_getArea_Nr(i_rad2_nr);
          v_out_nr  := v_area1_nr-v_area2_nr;
          return v_out_nr;             /outer
     end;
     begin
          DBMS_OUTPUT.put_line('Diff between 3 and 4:'||f_getDiff_Nr(4, 3));
          DBMS_OUTPUT.put_line('Diff between 4 and 5:'||f_getDiff_Nr(4, 3));
          DBMS_OUTPUT.put_line('Diff between 5 and 6:'||f_getDiff_Nr(4, 3));
     end;I'm wondering how it works, does outer function (f_getDiff_Nr) run first then passes the result to the inner function (f_getArea_Nr)?f_getDif_Nr gets called first. To do its job, f_getDiff_Nr calls f_getArea_Nr, which passes a NUMBER back to f_getDiff_Nr.
I think it's easier to understand indented and commented like this
declare     -- for anonymous block
    v_pi_nr NUMBER:= 3.14;
    function f_getDiff_Nr(i_rad1_nr NUMBER, i_rad2_nr NUMBER)
     return NUMBER is
          v_area1_nr NUMBER;
          v_area2_nr NUMBER;
          v_out_nr NUMBER;
          function f_getArea_Nr(i_rad_nr NUMBER)
          return NUMBER
          is
          begin     -- f_getArea-Nr body
               return v_pi_nr*(i_rad_nr**2); /inner
          end;     -- f_getArea-Nr body
     begin     -- f_getDiff_Nr body
          v_area1_nr:= f_getArea_Nr(i_rad1_nr);
          v_area2_nr:= f_getArea_Nr(i_rad2_nr);
          v_out_nr  := v_area1_nr-v_area2_nr;
          return v_out_nr;             /outer
     end;     -- f_getDiff_Nr body
begin     -- anonymous block body
     DBMS_OUTPUT.put_line('Diff between 3 and 4:'||f_getDiff_Nr(4, 3));
     DBMS_OUTPUT.put_line('Diff between 4 and 5:'||f_getDiff_Nr(4, 3));     -- Shouldn't the arguments be (5, 4)?
     DBMS_OUTPUT.put_line('Diff between 5 and 6:'||f_getDiff_Nr(4, 3));     -- Shouldn't the arguments be (6, 5)?
end;     f_getDiff_Nr is defined inside the anonymous block; that means it can only be called from within that anonymous block.
f_getArea_Nr is defined inside f_getDiff_Nr; that means it can only be called from within f_getArea_Nr. That's an unusual way to write functions. It's much more common to define functions inside a package, or to define them as stand-alone functions (that is, not within any other PL/SQL unit). Either way, they could be called from anywhere.
Edited by: Frank Kulash on Oct 23, 2011 7:52 PM

Similar Messages

  • Sql function question.

    Hello,
    Is there any SQL function in order to separate the data by identifier ?
    Like this :
    A/B/C in this sentence, I used the ‘/’ as an identifier.
    Results :
    A
    B
    C
    I have to separate the data by using the identifier.
    Help please….
    Thanks in advance.

    I have posted a procedure that does that Re: Splitting the values in one column.
    John

  • Question about PL/SQL Function in report

    Hi all. I have a (basic) question about using a PL/SQL function in a report. In my report page I have an item (PL/SQL function) that has the following syntax:
    return username from t1
    where username like 'Le%'
    I reference this item in an email process. Ideally this function would return all usernames that begin with 'Le' in the drafted email; however, its not looping so I'm only getting a return on the first name.
    I have a few books on PL/SQL but I'm not exactly sure where to start - I imagine there is a loop process I need to integrate into the function but, like I said, I'm not sure.
    I would have posted this to the PL/SQL forum but also wanted some feedback on whether or not using this method is the best way forward. Essentially I have a table with usernames and just want to send email messages based on some simple logic.
    Thanks!
    Len

    Hi Sergio,
    First, it's an honor to have you reply to my post. Thanks!
    To be more specific,
    T1 is a table containing the results from a user security scan. Username is a column in this table containing user names. What I have done is create a page in HTML DB with the following elements:
    1. An 'Item' containing the PL/SQL function that is hidden. The purpose of this Item is to generate information from T1 that meets the simple logic parameters - in this case, the user names that begin with "Le". I have called this Item P145_TT
    2. A 'Process' containing references to HTMLDB_MAIL. The 'Process' looks similar to this:
    HTMLDB_MAIL.SEND(
    P_TO => '[email protected]',
    P_FROM => 'Anon Email Account',
    P_BODY => 'Note: This message was automatically generated. Do not attempt to reply to this email.
    These are the users that begin with Le: '||:P145_TT||' ',
    P_SUBJ => 'Summary');
    3. A 'Button' to submit the process and (hopefully) send the message containing all users that adhere to the logic in the function.
    4. If I use 'return username from t1...' I will get a username generated, but like I said previously, it only gives me the first and does not loop.

  • Pass a value from a PL/SQL function to a javascript (html header) ? ?

    Hey Guys,
    Have a question regarding how to pass a value from a PL/SQL function to a javascript in the HTML Header.
    I have created a PL/SQL function in my database, which does looping.
    The reason for this is:  On my apex page when the user selects a code, it should display(or highlight buttons) the different project id's present for that particular code.
    example= code 1
    has project id's = 5, 6, 7
    code 2
    has project id's = 7,8
    Thank you for your Help or Suggestions
    Jesh
    The PL/SQL function :
    CREATE OR REPLACE FUNCTION contact_details(ACT_CODE1 IN NUMBER) RETURN VARCHAR2 IS
    Project_codes varchar2(10);
    CURSOR contact_cur IS
    SELECT ACT_CODE,PROJECT_ID
    FROM ACTASQ.ASQ_CONTACT where ACT_CODE = ACT_CODE1;
    currec contact_cur%rowtype;
    NAME: contact_details
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 6/25/2009 1. Created this function.
    BEGIN
    FOR currec in contact_cur LOOP
         dbms_output.put_line(currec.PROJECT_ID || '|');
         Project_codes := currec.PROJECT_ID|| '|' ||Project_codes;
    END LOOP;
    RETURN Project_codes;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END contact_details;
    /

    Jesh:
    I have made the following modifications to your app to get it to work as I thing you need it to.
    1) Changed the source for the HTML Buttons Region(note use of id vs name for the Buttons)
    <script>
    function hilitebtn(val) {
    //gray buttons
    $x('graduate').style.backgroundColor='gray'
    $x('distance').style.backgroundColor='gray'
    $x('career').style.backgroundColor='gray'
    $x('photo').style.backgroundColor='gray'
    //AJAX call to get project-ids
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=GETPROJECTS',0);
    get.addParam('x01',val)
    gReturn = get.get();
    var arr=gReturn.split(':');  //dump into array
    get = null;
    for (i=0;i<arr.length;i++) {
    // alert('val=' + arr);
    if ( arr[i]==5)
    $x('graduate').style.backgroundColor='red';
    if ( arr[i]==6)
    $x('distance').style.backgroundColor='red';
    if ( arr[i]==7)
    $x('career').style.backgroundColor='red';
    if ( arr[i]==8)
    $x('photo').style.backgroundColor='red';
    </script>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr><td>
    <input type='button' id='graduate' value='Graduate'>
    </td>
    <td>
    <input type='button' id='distance' value='Distance'>
    </td>
    <td>
    <input type='button' id='career' value='Career/Tech'>
    </td>
    <td>
    <input type='button' id='photo' value='Photos'>
    </td>
    </tr></table>
    2) Defined the application process  GETPROJECTS as DECLARE
    IDS varchar2(1000);
    l_act_code varchar2(100) :=4;
    begin
    IDS:='';
    l_act_code := wwv_flow.g_x01;
    for x in(
    SELECT ACT_CODE,PROJECT_ID
    FROM ASQ_CONTACT
    where ACT_CODE = l_act_code)
    LOOP
    IDS := IDS || X.PROJECT_ID|| ':' ;
    END LOOP;
    HTP.PRN(IDS);
    END;
    3) Changed the 'onchange' event-handler on p1_act_code to be 'onchange=hilitebtn(this.value)'
    4) Added the JS to the HTML Page Footer <script>
    hilitebtn($v('P1_ACT_CODE'));
    </SCRIPT>

  • Using HANA SQL Functions in select list of CDS Views

    Dear Expert,
    Kindly please let me know if we can use the HANA SQL Function (Ex: ADD_DAYS, SECONDS_BETWEEN) in the select list of CDS Views?
    If I create a CDS like below I get error that timestamp is not supported.
    For Example:
    @AbapCatalog.sqlViewName: 'ZMR_H_CA'
    @EndUserText.label: 'CAG A'
    define view viewname
    with parameters start_ts:abap.dec( 15, 0 ) , end_ts:abap.dec( 15, 0 )
    as select from table {
    key resource_key,
    TO_TIMESTAMP(begtstmp) as start_tmp,
    TO_TIMESTAMP(begtstmp) as end_tmp
    where
    (begtstmp > $parameters.start_ts or endtstmp > $parameters.start_ts )
    and
    (begtstmp < $parameters.end_ts or endtstmp < $parameters.end_ts )
    Thanks,
    Giri

    Hi Giri,
    the list of provided features can be found in the ABAP Language Documentation (F1 in the CDS View).
    As CDS in ABAP is abstracted from the database layer, the database features are not directly accessible. That means, you cannot use any HANA or MaxDB feature available. So the answer to your question is no. The reason for this is, that ABAP CDS views can be created on all SAP-supported databases, hence, we can only provide those features, supported by all databases.
    Having said this, there are some exception, e.g. the CDS views with input parameters, which are not supported by all databases. In these cases, you'd have to additionally use the utility class CL_ABAP_DBFEATURES (see http://scn.sap.com/community/abap/blog/2014/10/10/abap-news-for-740-sp08--abap-core-data-services-cds) for more details.
    Best,
      Jasmin

  • Oracle SQL and PL/SQL interview questions.

    Can anyone forward me all Oracle SQL and PL/SQL Interview questions and answers asap.
    Many Thanks.
    Bba

    Dear Pal
    I not sure all the all answers are correct. I got one mail couple yrs back. I am just sharing mail contents. Kindly keep question and compare answers.
    1 Which is more faster - IN or EXISTS?
    EXISTS is more faster than IN because EXISTS returns a Boolean value whereas IN returns a value.
    2 Which datatype is used for storing graphics and images?
    LONG RAW data type is used for storing BLOB's (binary large objects).
    3 When do you use WHERE clause and when do you use HAVING clause?
    HAVING clause is used when you want to specify a condition for a group function and it is written after GROUP BY clause. The WHERE clause is used when you want to specify a condition for columns, single row functions except group functions and it is written before GROUP BY clause if it is used.
    4 What WHERE CURRENT OF clause does in a cursor?
    LOOPSELECT num_credits INTO v_numcredits FROM classesWHERE dept=123 and course=101;UPDATE studentsSET current_credits=current_credits+v_numcreditsWHERE CURRENT OF X;END LOOPCOMMIT;END;
    5 What should be the return type for a cursor variable.Can we use a scalar data type as return type?
    The return type for a cursor must be a record type.It can be declared explicitly as a user-defined or %ROWTYPE can be used. eg TYPE t_studentsref IS REF CURSOR RETURN students%ROWTYPE
    6 What is use of a cursor variable? How it is defined?
    A cursor variable is associated with different statements at run time, which can hold different values at run time. Static cursors can only be associated with one run time query. A cursor variable is reference type (like a pointer in C).Declaring a cursor variable:TYPE type_name IS REF CURSOR RETURN return_type type_name is the name of the reference type,return_type is a record type indicating the types of the select list that will eventually be returned by the cursor variable.
    7 What is the purpose of a cluster?
    Oracle does not allow a user to specifically locate tables, since that is a part of the function of the RDBMS. However, for the purpose of increasing performance, oracle allows a developer to create a CLUSTER. A CLUSTER provides a means for storing data from different tables together for faster retrieval than if the table placement were left to the RDBMS.
    8 What is the maximum buffer size that can be specified using the DBMS_OUTPUT.ENABLE function?
    1,000,00
    9 What is syntax for dropping a procedure and a function .Are these operations possible?
    Drop Procedure procedure_nameDrop Function function_name
    10 What is OCI. What are its uses?
    Oracle Call Interface is a method of accesing database from a 3GL program. Uses--No precompiler is required,PL/SQL blocks are executed like other DML statements. The OCI library provides· -functions to parse SQL statemets· -bind input variables· -bind output variables· -execute statements· -fetch the results
    11 What is difference between UNIQUE and PRIMARY KEY constraints?
    A table can have only one PRIMARY KEY whereas there can be any number of UNIQUE keys. The columns that compose PK are automatically define NOT NULL, whereas a column that compose a UNIQUE is not automatically defined to be mandatory must also specify the column is NOT NULL.
    12 What is difference between SUBSTR and INSTR?
    SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDEINSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-')
    13 What is difference between SQL and SQL*PLUS?
    SQL*PLUS is a command line tool where as SQL and PL/SQL language interface and reporting tool. Its a command line tool that allows user to type SQL commands to be executed directly against an Oracle database. SQL is a language used to query the relational database(DML,DCL,DDL). SQL*PLUS commands are used to format query result, Set options, Edit SQL commands and PL/SQL.
    14 What is difference between Rename and Alias?
    Rename is a permanent name given to a table or column whereas Alias is a temporary name given to a table or column which do not exist once the SQL statement is executed.
    15 What is difference between a formal and an actual parameter?
    The variables declared in the procedure and which are passed, as arguments are called actual, the parameters in the procedure declaration. Actual parameters contain the values that are passed to a procedure and receive results. Formal parameters are the placeholders for the values of actual parameters
    16 What is an UTL_FILE.What are different procedures and functions associated with it?
    UTL_FILE is a package that adds the ability to read and write to operating system files. Procedures associated with it are FCLOSE, FCLOSE_ALL and 5 procedures to output data to a file PUT, PUT_LINE, NEW_LINE, PUTF, FFLUSH.PUT, FFLUSH.PUT_LINE,FFLUSH.NEW_LINE. Functions associated with it are FOPEN, ISOPEN.
    17 What is a view ?
    A view is stored procedure based on one or more tables, it’s a virtual table.
    18 What is a pseudo column. Give some examples?
    It is a column that is not an actual column in the table.eg USER, UID, SYSDATE, ROWNUM, ROWID, NULL, AND LEVEL.
    19 What is a OUTER JOIN?
    Outer Join--Its a join condition used where you can query all the rows of one of the tables in the join condition even though they don’t satisfy the join condition.
    20 What is a cursor?
    Oracle uses work area to execute SQL statements and store processing information PL/SQL construct called a cursor lets you name a work area and access its stored information A cursor is a mechanism used to fetch more than one row in a Pl/SQl block.
    21 What is a cursor for loop?
    Cursor For Loop is a loop where oracle implicitly declares a loop variable, the loop index that of the same record type as the cursor's record.
    22 What are various privileges that a user can grant to another user?
    · SELECT· CONNECT· RESOURCES
    23 What are various constraints used in SQL?
    · NULL· NOT NULL· CHECK· DEFAULT
    24 What are ORACLE PRECOMPILERS?
    Using ORACLE PRECOMPILERS, SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA.The Precompilers are known as Pro*C,Pro*Cobol,...This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. The prcompiler translates the embedded SQL and pl/sql ststements into calls to the precompiler runtime library.The output must be compiled and linked with this library to creater an executable.
    25 What are different Oracle database objects?
    · TABLES· VIEWS· INDEXES· SYNONYMS· SEQUENCES· TABLESPACES etc
    26 What are different modes of parameters used in functions and procedures?
    · IN· OUT· INOUT
    27 What are cursor attributes?
    · %ROWCOUNT· %NOTFOUND· %FOUND· %ISOPEN
    28 What a SELECT FOR UPDATE cursor represent. [ANSWER]SELECT......FROM......FOR......UPDATE[OF column-reference][NOWAIT] The processing done in a fetch loop modifies the rows that have been retrieved by the cursor. A convenient way of modifying the rows is done by a method with two parts: the FOR UPDATE clause in the cursor declaration, WHERE CURRENT OF CLAUSE in an UPDATE or declaration statement.
    29 There is a string 120000 12 0 .125 , how you will find the position of the decimal place?
    INSTR('120000 12 0 .125',1,'.')output 13
    30 There is a % sign in one field of a column. What will be the query to find it?
    '' Should be used before '%'.
    31 Suppose a customer table is having different columns like customer no, payments.What will be the query to select top three max payments?
    SELECT customer_no, payments from customer C1
    WHERE 3<=(SELECT COUNT(*) from customer C2
    WHERE C1.payment <= C2.payment)
    32 minvalue.sql Select the Nth lowest value from a table
    select level, min('col_name') from my_table where level = '&n' connect by prior ('col_name') <
    'col_name')
    group by level;
    Example:
    Given a table called emp with the following columns:
    -- id number
    -- name varchar2(20)
    -- sal number
    -- For the second lowest salary:
    -- select level, min(sal) from emp
    -- where level=2
    -- connect by prior sal < sal
    -- group by level
    33 maxvalue.sql Select the Nth Highest value from a table
    select level, max('col_name') from my_table where level = '&n' connect by prior ('col_name') >
    'col_name')
    group by level;
    Example:
    Given a table called emp with the following columns:
    -- id number
    -- name varchar2(20)
    -- sal number
    -- For the second highest salary:
    -- select level, max(sal) from emp
    -- where level=2
    -- connect by prior sal > sal
    -- group by level
    34 How you will avoid your query from using indexes?
    SELECT * FROM emp
    Where emp_no+' '=12345;
    i.e you have to concatenate the column name with space within codes in the where condition.
    SELECT /*+ FULL(a) */ ename, emp_no from emp
    where emp_no=1234;
    i.e using HINTS
    35 How you will avoid duplicating records in a query?
    By using DISTINCT
    36 How you were passing cursor variables in PL/SQL 2.2?
    In PL/SQL 2.2 cursor variables cannot be declared in a package.This is because the storage for a cursor variable has to be allocated using Pro*C or OCI with version 2.2, the only means of passing a cursor variable to a PL/SQL block is via bind variable or a procedure parameter.
    37 How you open and close a cursor variable.Why it is required?
    OPEN cursor variable FOR SELECT...Statement
    CLOSE cursor variable In order to associate a cursor variable with a particular SELECT statement OPEN syntax is used. In order to free the resources used for the query CLOSE statement is used.
    38 How will you delete duplicating rows from a base table?
    delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name); or
    delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.dv=tb.dv);
    39 How do you find the numbert of rows in a Table ?
    A bad answer is count them (SELECT COUNT(*) FROM table_name)
    A good answer is :-
    'By generating SQL to ANALYZE TABLE table_name COUNT STATISTICS by querying Oracle System Catalogues (e.g. USER_TABLES or ALL_TABLES).
    The best answer is to refer to the utility which Oracle released which makes it unnecessary to do ANALYZE TABLE for each Table individually.
    40 Find out nth highest salary from emp table
    SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal<=b.sal);
    For Eg:-
    Enter value for n: 2
    SAL
    3700
    41 Display the records between two range?
    select rownum, empno, ename from emp where rowid in (select rowid from emp where rownum <=&upto minus select rowid from emp where rownum<&Start);
    42 Display the number value in Words?
    SQL> select sal, (to_char(to_date(sal,'j'), 'jsp'))
    from emp;
    the output like,
    SAL (TO_CHAR(TO_DATE(SAL,'J'),'JSP'))
    800 eight hundred
    1600 one thousand six hundred
    1250 one thousand two hundred fifty
    If you want to add some text like, Rs. Three Thousand only.
    SQL> select sal "Salary ",
    (' Rs. '|| (to_char(to_date(sal,'j'), 'Jsp'))|| ' only.'))
    "Sal in Words" from emp
    Salary Sal in Words
    800 Rs. Eight Hundred only.
    1600 Rs. One Thousand Six Hundred only.
    1250 Rs. One Thousand Two Hundred Fifty only.
    43 Display Odd/ Even number of records
    Odd number of records:
    select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);
    Output:-
    1
    3
    5
    Even number of records:
    select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)
    Output:-
    2
    4
    6
    44 Difference between procedure and function.
    Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.
    45 Difference between NO DATA FOUND and %NOTFOUND
    NO DATA FOUND is an exception raised only for the SELECT....INTO statements when the where clause of the querydoes not match any rows. When the where clause of the explicit cursor does not match any rows the %NOTFOUND attribute is set to TRUE instead.
    46 Difference between database triggers and form triggers?
    Data base trigger(DBT) fires when a DML operation is performed on a data base table. Form trigger(FT) Fires when user presses a key or navigates between fields on the screen
    Can be row level or statement level No distinction between row level and statement level.
    Can manipulate data stored in Oracle tables via SQL Can manipulate data in Oracle tables as well as variables in forms.
    Can be fired from any session executing the triggering DML statements. Can be fired only from the form that define the trigger.
    Can cause other database triggers to fire.Can cause other database triggers to fire, but not other form triggers.
    47 Difference between an implicit & an explicit cursor.
    PL/SQL declares a cursor implicitly for all SQL data manipulation statements, including quries that return only one row. However,queries that return more than one row you must declare an explicit cursor or use a cursor FOR loop.
    Explicit cursor is a cursor in which the cursor name is explicitly assigned to a SELECT statement via the CURSOR...IS statement. An implicit cursor is used for all SQL statements Declare, Open, Fetch, Close. An explicit cursors are used to process multirow SELECT statements An implicit cursor is used to process INSERT, UPDATE, DELETE and single row SELECT. .INTO statements.
    48 Can you use a commit statement within a database trigger?
    No.
    49 Can the default values be assigned to actual parameters?
    Yes
    50 Can cursor variables be stored in PL/SQL tables.If yes how. If not why?
    No, a cursor variable points a row which cannot be stored in a two-dimensional PL/SQL table.
    51 Can a primary key contain more than one columns?
    Yes
    52 Can a function take OUT parameters. If not why?
    No. A function has to return a value,an OUT parameter cannot return a value.
    53 What are various joins used while writing SUBQUERIES?
    Self join-Its a join foreign key of a table references the same table. Outer Join--Its a join condition used where One can query all the rows of one of the tables in the join condition even though they don't satisfy the join condition.
    Equi-join--Its a join condition that retrieves rows from one or more tables in which one or more columns in one table are equal to one or more columns in the second table.
    54 Differentiate between TRUNCATE and DELETE
    TRUNCATE deletes much faster than DELETE
    TRUNCATE
    DELETE
    It is a DDL statement It is a DML statement
    It is a one way trip,cannot ROLLBACK One can Rollback
    Doesn't have selective features (where clause) Has
    Doesn't fire database triggers Does
    It requires disabling of referential constraints. Does not require
    1 What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.
    2 Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integarity Constraints.
    I & ii.
    Exception :
    3 Where the Pre_defined_exceptions are stored ?
    In the standard package.
    Procedures, Functions & Packages ;
    4 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
    5 What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;
    The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
    6 What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.
    7 What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.
    8 What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
    9 What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
    Cursors
    10 What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line
    What is a package ? What are the advantages of packages ?
    11 What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.
    12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
    13 What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.
    14 What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.
    15 What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.
    16 What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    17 What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes
    when all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;
    18 What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.
    19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.
    20 What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.
    21 What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
    22 What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.
    23 What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.
    24 What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
    25 What are the modes of parameters that can be passed to a procedure ?
    IN,OUT,IN-OUT parameters.
    26 What are the datatypes a available in PL/SQL ?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.
    27 What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
    28 What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL
    29 What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.
    30 What are advantages fo Stored Procedures /
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.
    1 What is PL/SQL ?
    PL/SQL is a procedural language that has both interactive SQL and procedural programming language constructs such as iteration, conditional branching.
    2 Write the order of precedence for validation of a column in a table ?
    I. done using Database triggers.
    ii. done using Integarity Constraints.
    I & ii.
    Exception :
    3 Where the Pre_defined_exceptions are stored ?
    In the standard package.
    Procedures, Functions & Packages ;
    4 What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?
    % TYPE provides the data type of a variable or a database column to that variable.
    % ROWTYPE provides the record type that represents a entire row of a table or view or columns selected in the cursor.
    The advantages are : I. Need not know about variable's data type
    ii. If the database definition of a column in a table changes, the data type of a variable changes accordingly.
    5 What will happen after commit statement ?
    Cursor C1 is
    Select empno,
    ename from emp;
    Begin
    open C1; loop
    Fetch C1 into
    eno.ename;
    Exit When
    C1 %notfound;-----
    commit;
    end loop;
    end;
    The cursor having query as SELECT .... FOR UPDATE gets closed after COMMIT/ROLLBACK.
    The cursor having query as SELECT.... does not get closed even after COMMIT/ROLLBACK.
    6 What is the basic structure of PL/SQL ?
    PL/SQL uses block structure as its basic structure. Anonymous blocks or nested blocks can be used in PL/SQL.
    7 What is Raise_application_error ?
    Raise_application_error is a procedure of package DBMS_STANDARD which allows to issue an user_defined error messages from stored sub-program or database trigger.
    8 What is Pragma EXECPTION_INIT ? Explain the usage ?
    The PRAGMA EXECPTION_INIT tells the complier to associate an exception with an oracle error. To get an error message of a specific oracle error.
    e.g. PRAGMA EXCEPTION_INIT (exception name, oracle error number)
    9 What is PL/SQL table ?
    Objects of type TABLE are called "PL/SQL tables", which are modeled as (but not the same as) database tables, PL/SQL tables use a primary PL/SQL tables can have one column and a primary key.
    Cursors
    10 What is Overloading of procedures ?
    The Same procedure name is repeated with parameters of different datatypes and parameters in different positions, varying number of parameters is called overloading of procedures.
    e.g. DBMS_OUTPUT put_line
    What is a package ? What are the advantages of packages ?
    11 What is difference between a PROCEDURE & FUNCTION ?
    A FUNCTION is always returns a value using the return statement.
    A PROCEDURE may return one or more values through parameters or may not return at all.
    12 What is difference between a Cursor declared in a procedure and Cursor declared in a package specification ?
    A cursor declared in a package specification is global and can be accessed by other procedures or procedures in a package.
    A cursor declared in a procedure is local to the procedure that can not be accessed by other procedures.
    13 What is difference between % ROWTYPE and TYPE RECORD ?
    % ROWTYPE is to be used whenever query returns a entire row of a table or view.
    TYPE rec RECORD is to be used whenever query returns columns of different
    table or views and variables.
    E.g. TYPE r_emp is RECORD (eno emp.empno% type,ename emp ename %type
    e_rec emp% ROWTYPE
    cursor c1 is select empno,deptno from emp;
    e_rec c1 %ROWTYPE.
    14 What is an Exception ? What are types of Exception ?
    Exception is the error handling part of PL/SQL block. The types are Predefined and user defined. Some of Predefined exceptions are.
    CURSOR_ALREADY_OPEN
    DUP_VAL_ON_INDEX
    NO_DATA_FOUND
    TOO_MANY_ROWS
    INVALID_CURSOR
    INVALID_NUMBER
    LOGON_DENIED
    NOT_LOGGED_ON
    PROGRAM-ERROR
    STORAGE_ERROR
    TIMEOUT_ON_RESOURCE
    VALUE_ERROR
    ZERO_DIVIDE
    OTHERS.
    15 What is a stored procedure ?
    A stored procedure is a sequence of statements that perform specific function.
    16 What is a database trigger ? Name some usages of database trigger ?
    Database trigger is stored PL/SQL program unit associated with a specific database table. Usages are Audit data modifications, Log events transparently, Enforce complex business rules Derive column values automatically, Implement complex security authorizations. Maintain replicate tables.
    17 What is a cursor for loop ?
    Cursor for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closes
    when all the records have been processed.
    eg. FOR emp_rec IN C1 LOOP
    salary_total := salary_total +emp_rec sal;
    END LOOP;
    18 What is a cursor ? Why Cursor is required ?
    Cursor is a named private SQL area from where information can be accessed. Cursors are required to process rows individually for queries returning multiple rows.
    19 What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?
    Mutation of table occurs.
    20 What are two virtual tables available during database trigger execution ?
    The table columns are referred as OLD.column_name and NEW.column_name.
    For triggers related to INSERT only NEW.column_name values only available.
    For triggers related to UPDATE only OLD.column_name NEW.column_name values only available.
    For triggers related to DELETE only OLD.column_name values only available.
    21 What are two parts of package ?
    The two parts of package are PACKAGE SPECIFICATION & PACKAGE BODY.
    Package Specification contains declarations that are global to the packages and local to the schema.
    Package Body contains actual procedures and local declaration of the procedures and cursor declarations.
    22 What are the two parts of a procedure ?
    Procedure Specification and Procedure Body.
    23 What are the return values of functions SQLCODE and SQLERRM ?
    SQLCODE returns the latest code of the error that has occurred.
    SQLERRM returns the relevant error message of the SQLCODE.
    24 What are the PL/SQL Statements used in cursor processing ?
    DECLARE CURSOR cursor name, OPEN cursor name, FETCH cursor name INTO or Record types, CLOSE cursor name.
    25 What are the modes of parameters that can be passed to a procedure ?
    IN,OUT,IN-OUT parameters.
    26 What are the datatypes a available in PL/SQL ?
    Some scalar data types such as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.
    Some composite data types such as RECORD & TABLE.
    27 What are the cursor attributes used in PL/SQL ?
    %ISOPEN - to check whether cursor is open or not
    % ROWCOUNT - number of rows fetched/updated/deleted.
    % FOUND - to check whether cursor has fetched any row. True if rows are fetched.
    % NOT FOUND - to check whether cursor has fetched any row. True if no rows are featched.
    These attributes are proceeded with SQL for Implicit Cursors and with Cursor name for Explicit Cursors.
    28 What are the components of a PL/SQL Block ?
    Declarative part, Executable part and Exception part.
    Datatypes PL/SQL
    29 What are the components of a PL/SQL block ?
    A set of related declarations and procedural statements is called block.
    30 What are advantages fo Stored Procedures /
    Extensibility,Modularity, Reusability, Maintainability and one time compilation.
    31 Name the tables where characteristics of Package, procedure and functions are stored ?
    User_objects, User_Source and User_error.
    32 Is it possible to use Transaction control Statements such a ROLLBACK or COMMIT in Database Trigger ? Why ?
    It is not possible. As triggers are defined for each table, if you use COMMIT of ROLLBACK in a trigger, it affects logical transaction processing.
    33 How packaged procedures and functions are called from the following?
    a. Stored procedure or anonymous block
    b. an application program such a PRC C, PRO COBOL
    c. SQL *PLUS
    a. PACKAGE NAME.PROCEDURE NAME (parameters);
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    EXEC SQL EXECUTE
    b.
    BEGIN
    PACKAGE NAME.PROCEDURE NAME (parameters)
    variable := PACKAGE NAME.FUNCTION NAME (arguments);
    END;
    END EXEC;
    c. EXECUTE PACKAGE NAME.PROCEDURE if the procedures does not have any
    out/in-out parameters. A function can not be called.
    34 How many types of database triggers can be specified on a table ? What are they ?
    Insert Update Delete
    Before Row o.k. o.k. o.k.
    After Row o.k. o.k. o.k.
    Before Statement o.k. o.k. o.k.
    After Statement o.k. o.k. o.k.
    If FOR EACH ROW clause is specified, then the trigger for each Row affected by the statement.
    If WHEN clause is specified, the trigger fires according to the returned Boolean value.
    35 Give the structure of the procedure ?
    PROCEDURE name (parameter list.....)
    is
    local variable declarations
    BEGIN
    Executable statements.
    Exception.
    exception handlers
    end;
    36 Give the structure of the function ?
    FUNCTION name (argument list .....) Return datatype is
    local variable declarations
    Begin
    executable statements
    Exception
    execution handlers
    End;
    37 Explain the usage of WHERE CURRENT OF clause in cursors ?
    WHERE CURRENT OF clause in an UPDATE,DELETE statement refers to the latest row fetched from a cursor.
    Database Triggers
    38 Explain the two type of Cursors ?
    There are two types of cursors, Implicit Cursor and Explicit Cursor.
    PL/SQL uses Implicit Cursors for queries.
    User defined cursors are called Explicit Cursors. They can be declared and used.
    39 Explain how procedures and functions are called in a PL/SQL block ?
    Function is called as part of an expression.
    sal := calculate_sal ('a822');
    procedure is called as a PL/SQL statement
    calculate_bonus ('A822');
    Programmatic Constructs
    Last Update: September 06, 2004
    1 What are the different types of PL/SQL program units that can be defined and stored in ORACLE database ?
    Procedures and Functions,Packages and Database Triggers.
    2 What are the differences between Database Trigger and Integrity constraints ?
    A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table.
    A trigger does not apply to data loaded before the definition of the trigger, therefore, it does not guarantee all data in a table conforms to the rules established by an associated trigger.
    A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.
    3 What is difference between Procedures and Functions ?
    A Function returns a value to the caller where as a Procedure does not.
    4 What is Database Trigger ?
    A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in,update to, or delete from a table.
    5 What is a Procedure ?
    A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a specific problem or perform a set of related tasks.
    6 What is a Package ?
    A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.
    7 What are the uses of Database Trigger ?
    Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.
    8 What are the advantages of having a Package ?
    Increased functionality (for example,global package variables can be declared and used by any proecdure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)
    1 With which function of summary item is the compute at options required?
    percentage of total functions.
    2 Why is it preferable to create a fewer no. of queries in the data model?
    Because for each query, report has to open a separate cursor and has to rebind, execute and fetch data.
    3 Why is a Where clause faster than a group filter or a format trigger?
    Because, in a where clause the condition is applied during data retrieval than after retrieving the data.
    4 Which parameter can be used to set read level consistency across multiple queries?
    Read only.
    5 Which of the two views should objects according to possession?
    view by structure.
    6 Which of the above methods is the faster method?
    performing the calculation in the query is faster.
    7 Where is the external query executed at the client or the server?
    At the server.
    8 Where is a procedure return in an external pl/sql library executed at the client or at the server?
    At the client.
    9 When do you use data parameter type?
    When the value of a data parameter being passed to a called product is always the name of the record group defined in the current form. Data parameters are used to pass data to produts invoked with the run_product built-in subprogram.
    10 When a form is invoked with call_form, Does oracle forms issues a save point?
    Yes
    11 What are the important difference between property clause and visual attributes?
    Named visual attributes differ only font, color & pattern attributes, property clauses can contain this and any other properties. You can change the appearance of objects at run time by changing the named visual attributes programmatically , property clause assignments cannot be changed programmatically. When an object is inheriting from both a property clause and named visual attribute, the named visual attribute settings take precedence, and any visual attribute properties in the class are ignored.
    12 What use of command line parameter cmd file?
    It is a command line argument that allows you to specify a file that contain a set of arguments for r20run.
    13 What is WHEN-Database-record trigger?
    Fires when oracle forms first marks a record as an insert or an update. The trigger fires as soon as oracle forms determines through validation that the record should be processed by the next post or commit as an insert or update. c generally occurs only when the operators modifies the first item in the record, and after the operator attempts to navigate out of the item.
    14 What is use of term?
    The term file which key is correspond to which oracle report functions.
    15 What is trigger associated with the timer?
    When-timer-expired.
    16 What is the use of transactional triggers?
    Using transactional triggers we can control or modify the default functionality of the oracle forms.
    17 What is the use of place holder column?
    A placeholder column is used to hold calculated values at a specified place rather than allowing is to appear in the actual row where it has to appear.
    18 What is the use of image_zoom built-in?
    To manipulate images in image items.
    19 What is the use of hidden column?
    A hidden column is used to when a column has to embed into boilerplate text.
    20 What is the use of break group?
    A break group is used to display one record for one group ones. While multiple related records in other group can be displayed.
    21 What is the remove on exit property?
    For a modelless window, it determines whether oracle forms hides the window automatically when the operators navigates to an item in the another window.
    22 What is the purpose of the product order option in the column property sheet?
    To specify the order of individual group evaluation in a cross products.
    23 What is the maximum no of chars the parameter can store?
    The maximum no of chars the parameter can store is only valid for char parameters, which can be upto 64K. No parameters default to 23Bytes and Date parameter default to 7Bytes.
    24 What is the main diff. bet. Reports 2.0 & Reports 2.5?
    Report 2.5 is object oriented.
    25 What is the frame & repeating frame?
    A frame is a holder for a group of fields. A repeating frame is used to display a set of records when the no. of records that are to displayed is not known before.
    26 What is the difference between OLE Server & Ole Container?
    An Ole server application creates ole Objects that are embedded or linked in ole Containers ex. Ole servers are ms_word & ms_excel. OLE containers provide a place to store, display and manipulate objects that are created by ole server applications. Ex. oracle forms is an example of an ole Container.
    27 What is the difference between object embedding & linking in Oracle forms?
    In Oracle forms, Embedded objects become part of the form module, and linked objects are references from a form module to a linked source file.
    28 What is the difference between boiler plat images and image items?
    Boiler plate Images are static images (Either vector or bit map) that you import from the file system or database to use a graphical elements in your form, such as company logos and maps. Image items are special types of interface controls that store and display either vector or bitmap images. Like other items that store values, image items can be either base table items(items that relate directly to database columns) or control items. The definition of an image item is stored as part of the form module FMB and FMX files, but no image file is actually associated with an image item until the item is populate at run time.
    29 What is the difference between $$DATE$$ & $$DBDATE$$ $$DBDATE$$ retrieves the current database date $$date$$ retrieves the current operating system date.
    30 What is the diff. when Flex mode is mode on and when it is off?
    When flex mode is on, reports automatically resizes the parent when the child is resized.
    31 What is the diff. when confine mode is on and when it is off?
    When confine mode is on, an object cannot be moved outside its parent in the layout.
    32 What is the diff. bet. setting up of parameters in reports 2.0 reports 2.5?
    LOVs can be attached to parameters in the reports 2.5 parameter form.
    33 What is the advantage of the library?
    Libraries provide a convenient means of storing client-side program units and sharing them among multiple applications. Once you create a library, you can attach it to any other form, menu, or library modules. When you can call library program units from triggers menu items commands and user named routine, you write in the modules to which you have attach the library. When a library attaches another library, program units in the first library can reference program units in the attached library. Library support dynamic loading-that is library program units are loaded into an application only when needed. This can significantly reduce the run-time memory requirements of applications.
    34 What is term?
    The term is terminal definition file that describes the terminal form which you are using r20run.
    35 What is system.coordination_operation?
    It represents the coordination causing event that occur on the master block in master-detail relation.
    36 What is synchronize?
    It is a terminal screen with the internal state of the form. It updates the screen display to reflect the information that oracle forms has in its internal representation of the screen.
    37 What is strip sources generate options?
    Removes the source code from the library file and generates a library files that contains only pcode. The resulting file can be used for final deployment, but can not be subsequently edited in the designer. ex. f45gen module=old_lib.pll userid=scott/tiger strip_source YES output_file
    38 What is relation between the window and canvas views?
    Canvas views are the back ground objects on which you place the interface items (Text items), check boxes, radio groups etc.,) and boilerplate objects (boxes, lines, images etc.,) that operators interact with us they run your form . Each canvas views displayed in a window.
    39 What is pop list?
    The pop list style list item appears initially as a single field (similar to a text item field). When the operator selects the list icon, a list of available choices appears.
    40 What is new_form built-in?
    When one form invokes another form by executing new_form oracle form exits the first form and releases its memory before loading the new form calling new form completely replace the first with the second. If there are changes pending in the first form, the operator will be prompted to save them before the new form is loaded.
    41 What is lexical reference? How can it be created?
    Lexical reference is place_holder for text that can be embedded in a sql statements. A lexical reference can be created using & before the column or parameter name.
    42 What is forms_DDL?
    Issues dynamic Sql statements at run time, including server side pl/SQl and DDL
    43 What is difference between open_form and call_form?
    when one form invokes another form by executing open_form the first form remains displayed, and operators can navigate between the forms as desired. when one form invokes another form by executing call_form, the called form is modal with respect to the calling form. That is, any windows that belong to the calling form are disabled, and operators cannot navigate to them until they first exit the called form.
    44 What is bind reference and how can it be created?
    Bind reference are used to replace the single value in sql, pl/sql statements a bind reference can be created using a (:) before a column or a parameter name.
    45 What is an user exit used for?
    A way in which to pass control (and possibly arguments ) form Oracle report to another Oracle products of 3 GL and then return control ( and ) back to Oracle reports.
    46 What is an OLE?
    Object Linking & Embedding provides you with the capability to integrate objects from many Ms-Windows applications into a single compound document creating integrated applications enables you to use the features form .
    47 What is an object group?
    An object group is a container for a group of objects; you define an object group when you want to package related objects, so that you copy or reference them in other modules.
    48 What is an anchoring object & what is its use?
    An anchoring object is a print condition object which used to explicitly or implicitly anchor other objects to itself.
    49 What is a User_exit?
    Calls the user exit named in the user_exit_string. Invokes a 3Gl program by name which has been properly linked into your current oracle forms executable.
    50 What is a timer?
    Timer is an "internal time clock" that you can programmatically create to perform an action each time the timer expires.
    51 What is a Text_io Package?
    It allows you to read and write information to a file in the file system.
    52 What is a text list?
    The text list style list item appears as a rectangular box which displays the fixed number of values. When the text list contains values that can not be displayed, a vertical scroll bar appears, allowing the operator to view and select undisplayed values.
    53 What is a property clause?
    A property clause is a named object that contains a list of properties and their settings. Once you create a property clause you can base other object on it. An object based on a property can inherit the setting of any property in the clause that makes sense for that object.
    54 What is a physical page ? & What is a logical page ?
    A physical page is a size of a page. That is output by the printer. The logical page is the size of one page of the actual report as seen in the Previewer.
    55 What is a library?
    A library is a collection of subprograms including user named procedures, functions and packages.
    56 What is a difference between pre-select and pre-query?
    Fires during the execute query and count query processing after oracle forms constructs the select statement to be issued, but before the statement is actually issued. The pre-query trigger fires just before oracle forms issues the select statement to the database after the operator as define the example records by entering the query criteria in enter query mode. Pre-query trigger fires before pre-select trigger.
    57 What is a combo box?
    A combo box style list item combines the features found in list and text item. Unlike the pop list or the text list style list items, the combo box style list item will both display fixed values and accept one operator entered value.
    58 What does the term panel refer to with regard to pages?
    A panel is the no. of physical pages needed to print one logical page.
    59 What are visual attributes?
    Visual attributes are the font, color, pattern proprieties that you set for form and menu objects that appear in your application interface.
    60 What are three panes that appear in the run time pl/sql interpreter?
    1.Source pane. 2. interpreter pane. 3. Navigator pane.
    Regards
    B RANGARAJAN

  • Using Package to produce pl/sql function body returning sql query Report

    I have existing code that we want to use in building reports in APEX. We are needing to modify it slightly to handle some new requirements, but would like to use them in reports based upon SQL query (pl/sql function body returning sql query) functionality.
    Any suggestions as how to call these in an APEX report region?
    Thank you,
    Tony Miller
    UTMB/EHN

    Hi Tony-
    I am also v new to Apex and you may have answered a question I was in search of. I, however, now have a couple more. First a bit of background-- Like in your situation, my college has a lot of existing code (400 +) that we need to get into Apex. The majority of this canned code contains one/both: 1) many lines, sometimes containing multiple select statements 2) imbedded create table & view statements (temp user owned). Up until reading your post, I was unable to figure out an easy way of getting this existing code into the product. Thanks. Now the questions, do you know how I would go about dealing with the create tables/views. I've read some posts on this forum which suggest temporary tables being unstable in this environment. Also, do you know if there's a size limitation when passing sql code via a function?
    As you may/may not be able to tell, I'm a bit lost right now... so any info you can provide would be appreciated. Thanks.
    Don

  • Need to obtain updateable ResultSet via call to PL/SQL function

    I'm using JDBC and the Oracle JDBC driver to call a PL/SQL function that returns a SYS_REFCURSOR. I do this via a CallableStatement object and then cast the output parameter to a ResultSet object. However, I want this ResultSet object I end up with to be updateable. The following code throws an exception stating "Invalid operation for read only resultset: updateString ":
    cstmt2 = con.prepareCall("{? = call get_upload_entry_for_update(?)}",
                             ResultSet.TYPE_FORWARD_ONLY,
                             ResultSet.CONCUR_UPDATABLE);
    cstmt2.registerOutParameter(1, OracleTypes.CURSOR);
    cstmt2.setInt(2, newUploadId);
    cstmt2.execute();
    rs = (ResultSet) cstmt2.getObject(1);
    rs.next();
    rs.updateString("UPLOAD_FILENAME", fileName);
    // . . .So even though, I create the CallableStatement such that ResultSets should be updateable, it's not allowing me to do any updates. Also, in case you're wondering, inside the PL/SQL function, the query on which the cursor is based is a select statement which does specify "for update" at the end.
    I can get it to work as follows using a Statement object that executes the SELECT statement directly instead of a CallableStatement that executes a PL/SQL function:
    Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
    rs = stmt.executeQuery("select UPLOAD_FILENAME, UPLOAD_FILE from rf_upload where upload_id = "+newUploadId+" for update");
    rs.next();
    rs.updateString("UPLOAD_FILENAME", fileName);
    //. . . Although this works, the project I'm working has a goal to encapsulate all SQL into Functions and Stored Procedures so I'd like to get it working that way instead.
    So the bottom-line question is: Using the Oracle JDBC driver, how can I call a PL/SQL function in such a way that I can obtain an updateable ResultSet object?
    Thanks for any suggestions. I'd be happy to clarify anything that's unclear.

    Hmmm...
    I'm still scratching my head about this one, just not sure it's doable, but I'll point out something, maybe it will give you a clue...
    In your code, you have:
    cstmt2 = con.prepareCall("{? = call get_upload_entry_for_update(?)}",
                             ResultSet.TYPE_FORWARD_ONLY,
                             ResultSet.CONCUR_UPDATABLE);I don't think the ResultSet parameters do anything towards your goal of getting an updatable result set via the returned cursor, those parameters affect the result set produced if you were to call:
    ResultSet rs2 = cstmt2.executeQuery();and not the result set generated by:
    rs = (ResultSet) cstmt2.getObject(1);Futhermore, while the "FOR UPDATE" is almost certainly something you want to do, it also doesn't affect the cursor (I think) but merely locks the affected rows in the DB.
    You might try calling rs.getType() and rs.getConcurrency() on the ResultSet you get from getObject, though I suspect they'll merely confirm the bad news that the cursor your getting back isn't right...
    You also might try the Oracle-specific getCursor call:
    rs = ((OracleCallableStatement)cstmt2).getCursor (1)instead of getObject, though I don't think it will help...
    I've been curious enough to dig around through most of my handy references and Oracle's docs and MetaLink and come up mostly empty, although almost 5 years ago Oracle Support said:
    " Reference Cursors from a pl/sql stored procedure are not updateable in any language."

  • New help writing a function

    I am refreshing this an open a new case to see if I get more help( I do apologize, but I do need to move this to production). I am providing scripts:
    The Problem: I want to write a procedure to update a column in a table (rprawrt_paid_amt) the amount can not be greater than what is in the RPRAWRt_ACCEPT_AMT, the process is run every payroll period, the payroll table is PHREART (provide a script)
    The amount can not exceed the RPRAWRD_ACCEPT_AMT, The procedure is updating the RPRAWRT_PAID_AMT, it is going to be update every pay period, there are going to be cases when SUM(NVL(A.PHREARN_AMT,0)) is going to be greater than the RPRAWRD_ACCEPT_AMT, BUT the update CAN'T exceed the amount in RPRAWRT_ACCEPT_AMT (this value never change, it is set up at the begining of the payroll period(fiscal year).
    Please, see more explanation at the end..
    SELECT * FROM V$VERSION
    results
    racle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    PL/SQL Release 10.2.0.3.0 - Production
    CORE     10.2.0.3.0     Production
    Payroll table, I am just using the columns I need there are more columns in the table(s)
    CREATE TABLE PHREART
    PHREART_YEAR VARCHAR2(4),
    PHREART_PAYNO NUMBER(3),
    PHREART_PIDM NUMBER(8),
    PHREART_AMT NUMBER(12,2),
    PHREART_ACTIVITY_DATE DATE
    CREATE TABLE RPRAWRT
    RPRAWRT_AIDY_CODE VARCHAR2(4),
    RPRAWRT_PIDM NUMBER(8),
    RPRAWRT_FUND_CODE VARCHAR2(6),
    RPRAWRT_ACCEPT_AMT NUMBER(11,2),
    RPRAWRT_PAID_AMT NUMBER(11,2)
    I am only inserting one record but you can manipulate the data or insert more records(explain later)
    INSERT INTO RPRAWRT
    RPRAWRT_AIDY_CODE ,
    RPRAWRT_PIDM ,
    RPRAWRT_FUND_CODE ,
    RPRAWRT_ACCEPT_AMT ,
    RPRAWRT_PAID_AMT
    SELECT
    0910,
    2285428,
    'CFWS',
    60,
    45
    FROM DUAL
    I am inserting to payrolls PHREART_PAYNO  = 20 for the same PHREART_PIDM (PK)
    INSERT INTO PHREART
    PHREART_YEAR ,
    PHREART_PAYNO ,
    PHREART_PIDM ,
    PHREART_AMT ,
    PHREART_ACTIVITY_DATE
    SELECT
    2009,
    20,
    2285428,
    20,
    TO_DATE('9/28/2009','MM/DD/RRRR')
    FROM DUAL
    I am inserting to payrolls PHREART_PAYNO  = 21
    INSERT INTO PHREART
    PHREART_YEAR ,
    PHREART_PAYNO ,
    PHREART_PIDM ,
    PHREART_AMT ,
    PHREART_ACTIVITY_DATE
    SELECT
    2009,
    21,
    2285428,
    25,
    TO_DATE('10/28/2009','MM/DD/RRRR')
    FROM DUAL
    Here is the query that I want to use in my cursor, I do want to do this in a pl\sql function
    query 1
    SELECT rprawrt_aidy_code, rprawrt_pidm, rprawrt_fund_code,
    NVL (rprawrt_accept_amt, 0),
    NVL (rprawrt_paid_amt, 0) paid_amt,
    NVL (rprawrt_paid_amt, 0) pay_amt_sf,
    SUM (NVL (a.phreart_amt, 0))
    FROM phreart a, rprawrt b
    WHERE
    rprawrt_pidm = a.phreart_pidm
    AND rprawrt_fund_code = 'CFWS'
    AND rprawrt_pidm = 2285428
    AND rprawrt_aidy_code = 0910
    AND a.phreart_year = 2009
    AND (rprawrt_accept_amt IS NOT NULL AND rprawrt_accept_amt > 0
    GROUP BY rprawrt_pidm,
    rprawrt_aidy_code,
    rprawrt_fund_code,
    rprawrt_accept_amt,
    rprawrt_paid_amt,
    rprawrt_accept_amt;
    I am giving this example for just one pidm the
    AND rprawrt_pidm = 2285428
    AND rprawrt_aidy_code = 0910
    AND a.phreart_year = 2009
    are parameters passing to the function p_pidm, p_aidy_code, p_year
    Okay this is how my logic needs to work, if I run the query 1 I got this results
    RPRAWRT_AIDY_CODE = 0910
    RPRAWRT_PIDM = 2285428
    RPRAWRT_FUND_CODE = 'CWS'
    NVL(RPRAWRT_ACCEPT_AMT,0) = 60
    PAID_AMT = 45
    PAY_AMT_SF = 45
    SUM(NVL(A.PHREART_AMT,0)) = 45
    {code)
    ok this is the result for the pay period 20 and 21, let's say that for the period 22 the sum amout is 100.
    so, if we run the query 1 (that I am going to use in the cursor, I got) SUM(NVL(A.PHREART_AMT,0)) = 100
    BUT
    the RPRAWRT_ACCEPT_AMT is 60, so I can not update the accept amount for more than 60 that is the limit, this amount never change, it is set up in the begining of the period, the person said I accept 60, but lots of times they do made more than the accept amount (over time), we need to report to the government what they said in the begining in this case, 60
    so for the run of the PHREART_PAYNO 22, I should update this record on RPRAWRT_PAID_AMT = 60, so I need to substract the 15 dollars that are needed to get to 60..right 20 + 25 + 15 (forget about the rest, they will get pay, but my report don't need the rest the 85).
    Now when the next pay period comes this records should not be update again, it reaches the top (60) the RPRAWRT_ACCEPT_AMT is now 60... ]
    here is the insert
    INSERT INTO PHREART
    PHREART_YEAR   ,
    PHREART_PAYNO  ,
    PHREART_PIDM  ,
    PHREART_AMT   , 
    PHREART_ACTIVITY_DATE  
    SELECT
    2009,
    22,
    2285428,
    55,
    TO_DATE('10/28/2009','MM/DD/RRRR')
    FROM DUAL
    The person made 55 dollars on the PHREART_PAYNO 22, so now we have
    PHREART_PAYNO   20  20 dollars
    PHREART_PAYNO    21  25 dollars
    PHREART_PAYNO    22  55 dollars
    I would like to do this in a pl\sql function
    something like this
    Fetch the results from the cursor in variables the use if statements to do the updates, what I got it works but sometimes does not...
    rprawrd the equilant of prawrt, I just created the T tables with the columns I need.
    BEGIN
          IF update_rprawrd_cur%ISOPEN
          THEN
             CLOSE update_rprawrd_cur;
          END IF;
          OPEN update_rprawrd_cur;
          LOOP
             FETCH update_rprawrd_cur
              INTO v_aidy_code, v_pidm, v_fund_code, v_accept_amt, v_paid_amt,
                   v_need_to_upd, v_pay_amt_sf,v_phrearn_amt;
             ---amount to update
             --v_this_upd := NVL (v_paid_amt, 0) + NVL (v_need_to_upd, 0);
             --- v_this_upd := NVL (v_phrearn_amt, 0) - NVL (v_paid_amt, 0) + NVL(v_pay_amt_sf,0);
             EXIT WHEN update_rprawrd_cur%NOTFOUND;
             IF
                 v_accept_amt > v_phrearn_amt
             THEN
                LOCK TABLE faismgr.rprawrd IN SHARE UPDATE MODE;
              UPDATE faismgr.rprawrd
                        SET rprawrd_activity_date = SYSDATE,
                       rprawrd_paid_amt = v_phrearn_amt,
                       rprawrd_paid_date = SYSDATE,
                       rprawrd_data_origin = 'rz_upd_pkg',
                       rprawrd_user_id = p_user
                 WHERE rprawrd_pidm = v_pidm
                   AND rprawrd_fund_code = 'CFWS'
                   AND rprawrd_aidy_code = v_aidy_code;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Thank you, I certainly will look at your recommendations, and I agree with not locking the table, that is something I learned from a piece of code and I saw but I always have question about it, I believe Oracle automaticly look the table when is doing an update, I will never use again.
    I don't have any expereience using bulk collector, I will look at your documenntation and I will try to learn it, but It will be helpful if someone can help with the following:
    If you run the query 1 after you do the inserts(previous email) you will get
    RPRAWRT_AIDY_CODE = 0910
    RPRAWRT_PIDM = 2285428
    RPRAWRT_FUND_CODE = 'CWS'
    NVL(RPRAWRT_ACCEPT_AMT,0) = 60
    PAID_AMT = 45
    PAY_AMT_SF = 45
    SUM(NVL(A.PHREART_AMT,0)) = 45
    The RPRAWRT_ACCEPT_AMT is always 60, so I can not update the accept amount for more than 60 that is the limit, this amount never change, it is set up in the begining of the period, the person said I accept 60, but lots of times they do made more than the accept amount (over time), we need to report to the government what they said in the begining in this case, 60
    so for the run of the PHREART_PAYNO 22, I should update this record on RPRAWRT_PAID_AMT = 60, so I need to substract the 15 dollars that are needed to get to 60..right 20 + 25 + 15 (forget about the rest, they will get pay, but my report don't need the rest the 85).
    Now when the next pay period comes this records should not be update again, it reaches the top (60) the RPRAWRT_ACCEPT_AMT is now 60... ]
    here is the insert
    INSERT INTO PHREART
    PHREART_YEAR ,
    PHREART_PAYNO ,
    PHREART_PIDM ,
    PHREART_AMT ,
    PHREART_ACTIVITY_DATE
    SELECT
    2009,
    22,
    2285428,
    55,
    TO_DATE('10/28/2009','MM/DD/RRRR')
    FROM DUAL
    The person made 55 dollars on the PHREART_PAYNO 22, so now we have
    PHREART_PAYNO 20 20 dollars
    PHREART_PAYNO 21 25 dollars
    PHREART_PAYNO 22 55 dollars
    Then for period 23 if the person make some money the table SHOULD not be update because it reaches the limit 60
    Thank you
    Edited by: peace4all on Feb 20, 2010 6:31 AM

  • Discoverer - Import PL/SQL Function - Function Not Appears

    Hi,
    I´m trying to import 15 PL/SQL Funtions inside a custom package into the discoverer administrator, but they do not appear in the list, when trying to do an automatic import.
    Also, when I press the Import Button, it takes aproximately one hour to display the list.
    I´m using discoverer with Applications.
    Do you know what schemes are listed in there ? Because my package is in a CUSTOM Scheme, not the APPS, but it has a Public Synonym.
    I need to automatically import these functions in order to not having to do it manually, becasuse it takes to much time.
    Also, do you know if there is any way to export the BA and include this functions in there, so I won´t need to register them again in another instance after migration ?
    I´m using Discoverer 4.
    Thanks in advance.
    Nicolas.

    Hi Nicolas
    When you use the import capability you can import from a named schema so if you have your functions in a schema other than APPS or SYS, which have hundreds if not 1000s of functions, the list should populate quicker.
    I'm afraid I don't know of a way to automate the importation of PL/SQL functions. However, if you know the definition of the function rather than importing it why not try creating it manually using the New button? It takes a little getting used to, particularly in getting all of the pointers and arguments correct, but after a while it becomes second nature. This will be quicker than waiting an hour for the list of functions to popuklate.
    As for your third question, do you know if there is any way to export the BA and include this functions in there, so I won´t need to register them again in another instance after migration ? the answer is no. PL/SQL functions cannot be exported using Discoverer Administrator and need to be manually imported in the other EUL. You could take screen shots of your existing definitions and manually create them in the new environment using the New button. Once again this will be quicker.
    I'm so sorry all of the answers appear negative and please don't shoot the messenger.
    Best wishes
    Michael

  • PL/SQL Function Result Cache?

    Hi all,
    As we know, there's a new feature in 11g, called 'result cache', this 'result cache' can be shared throughout the whole instance, but if I got it right, only sql query result and function return value are cached, right? how about the store procedure, I mean, procedure also has its 'return value'--the output parameter, could it benefit from this new feature?
    Another question is, if my PL/SQL Function just retrieves the table and returns the result without any complicated calculation, is it necessary to enable the 'result cache' mechanism on this Function? because we already have 'db buffer cache' if the only thing we do is to query tables.
    Many thanks.

    Hi Morven,
    As of now, PL/SQL Result cache feature is only enabled for stored functions and not for procedures. This is due to the objectives they achieve. Functions are usually computative and procedures are for logic implementation.
    And for enabling result caching feature for a function, you are the better judge as u can test the performance in both the case. But, i would support enabling the cache because oracle 11g provides Cache as a different SGA component. db_buffer_cache will also be used for buffering other data blocks and not the result sets.
    Hope my explanation is fine.

  • Passing Multiple Values from a worksheet to PL/SQL function.

    Hi All,
    Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
    I will try to explain the scenario:
    We have a crosstab report that showing all the customer details, deposit sum of a customer in each date in a date range selected. With the customer details we are showing the Rank of a customer based on the deposit in the latest date selected. Filtering is based on the rank, ie Top50 or Top60 etc.( As I said rank is calculating based on the deposit in the latest date).This is working fine.
    Now the new requirement is to : For example, in Top50 report, list all the customers, who were in the Top50 list, in any of the dates selected. We are able to display the daywise rank, but when giving a condition like daywiserank <= 50, the result becomes uncertain. Some blank lines, wrong amounts etc..
    As a work around we tried to find out the rank in a PL/SQL function. But the issue there is : we have some multiple value parameters used in the worksheet.
    Is there any way to pass multiple values selected in a worksheet to a PL/SQL function ?
    Or any other work arounds for the scenario explained?
    Reagrds,
    Jeneesh

    Hi Russ,
    Thanks for the response.
    Russ Proudman wrote:
    1. I thought there was an analytical function similar to rank - or maybe an option of rank - that if there are duplicate records to have them all considered the same rank. So if you had 3 records all the same as rank=2 then a condition saying where rank=2 would return the 3 records. You could check into this.
    We are already using DENSE_RANK. But the issue is the output contains incorrect null values nd repeated rows.
    We got it solved as I explained in the previous post. But will that AGGREGATION MODE setting ( Which discoverer says - not recommended) have any issue? I mean side effects?
    Russ Proudman wrote:
    2. Another thought is that you can create a PL/SQL routine - that's called from a SQL function registered in Discoverer - where a table is created that does the first part of your query. Then a worksheet is created to use the data from that table. So, in essence, the table would have your top50 ranked customers. Then you can write any kind of worksheet against that table. However, DBAs are loath to allow tables - that they didn't create! - many times in a PROD environment.
    Here also the same problem will occur: as the top 50 will depend upon the parameters. I cannot pass those parameters to PL/SQL Function.And storing the top50 ( itmay be top100 or to 150 also) for all combinations of the parameters is impossible
    Russ Proudman wrote:
    3. Finally, are you sure you're rank function is correct in that if you're getting blank lines, maybe the 'over' part is not considering all columns needed to determine the rank?
    Yes the query we are using is correct. The output QUERY of discoverer gives correct results in Sqlplus.
    Regards,
    Jeneesh

  • Interactive report from PL/SQL function

    Hello All,
    i have a pl/sql function that dynamically builds up a sql query and returns it as a varchar2.
    when i create a new report then i can use this function in the report like
    return f_function(param1,param2,v('APP_ID'), v('APP_SESSION'));
    and this works fine.
    Except i cannot create an interactive report for this function, because it is not allowed !!!!
    So how can i use the function in an interactive report ?
    Thanks in advance,
    Marco

    Marco,
    Another rather extreme approach would be to go all the way and make your function pipelined (that is not only build but also execute the query) and then select from it in your interactive report.
    The disadvantage here would be that any supplementary filtering would act on the result set of the function (not as an addition to the where clause of the original query). But if you can live with that...
    The advantage would be that there's less fiddling with column headers.
    Regards,
    Iulian

  • Interactive Report with PL/SQL Function Source

    Is it possible to create interactive report with PL/SQL function source returing a query? If not, has anyone done any work to simulate the interactive reporting feature for a normal report using API?

    I haven't tried that before but you could:
    1. create a collection from your result set returned by a dynamic query,
    2. create a view on that collection,
    3. use the view in your interactive report.
    The usability of this proposal depends from a question how "dynamic" your query is - does it always have the same number of columns or not.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Passing #COLUMN_VALUE# as parameter to pl/sql function in column template

    Hi all,
    I want to color negative amounts in red in sql report using column template.
    I created a pl/sql function"isNegativeNum" which returns 1 or -1.
    create or replace function isNegativeNum(p_column_value varchar2) return number
    as
    l_dummy number;
    begin
          l_dummy := to_number(p_column_value,'999G999G990D00PR');
          IF l_dummy < 0
             THEN
                RETURN 1;
          else
                return -1;
          END IF;
    exception
    when others then
       RETURN -1;
    end;Below is column template.
    Column Template 1
    <td class="t3dataalt" #ALIGNMENT#><p color=red>#COLUMN_VALUE#</p></td>Column Template 1 Condition
    isNegativeNum('#COLUMN_VALUE#') = -1The issue is #COLUMN_VALUE# value is not being passed to the function, Insert statement in function reveals p_column_value as a string "#COLUMN_VALUE#". When I try without quotes like isNegativeNum(#COLUMN_VALUE#) = -1, I get below error.
    ORA-06550: line 1, column 48: PLS-00103: Encountered the symbol "#" when expecting one of the following: ( ) - + case mod new not null others select table avg count current exists max min prior sql stddev sum variance execute multiset the both leading trailing forall merge year month DAY_ hour minute second timezone_hour timezone_minute timezone_region timezone_abbr time timestamp interval date
         Error      ERR-1025 Error processing PLSQL expression. isNegativeNum(#COLUMN_VALUE#) = 1
    Any help is appreciated.
    Kishore

    Hi Kishore,
    using #COLUMN_VALUE# would probably not make much sense, because normally a report has multiple columns and not just the numeric column which you want to verify if it's negative. But APEX will fire the template condition for each column, because the report template is a column cell template.
    What you can do to make it more generic is to use for example
    #CHECK_AMOUNT#
    in the template and provide a not displayed column in your SQL statement which contains your value which is named CHECK_AMOUNT. For example:
    SELECT NAME
         , BALANCE
         , BALANCE AS CHECK_AMOUNT
    FROM XXX;Because this CHECK_AMOUNT column would be a generic name, you can use this template in all your reports as long as you provide this column.
    Thope that helps
    Patrick

Maybe you are looking for

  • Urgent: Change custom conditions on item level

    Hi experts, could you please tell me how you resolve this issue, its very urgent? I´m facing the promblem that my condition type doesn´t get changed! I want only to change KBETR at item level. After CRM_ORDER_SAVE is called I can see, that order got

  • How to see additional individual search helps in sh for PERNR

    Hi, In this moment I see only 3 tabs in search help for PERNR. But there are about 20 search helps. How  can I activate them ? I tried to do it by program DBPNPGMC but it didn't help. Thank you very much Irena

  • Missing Options for AppleTV in iTunes

    After the upgrade, all went fine I thought, in iTunes when I select the AppleTV form the device menu, there are only tabs for Info and Photo's. It is missing all the ones for Movies, Podcasts, Music, etc. I tried several times to delete the device in

  • Upgrading from 10.3.9 to latest OS?

    I am currently using OS 10.3.9 and would like to upgrade to the latest version possible. I have 933MHz PowerPC G4 2MB L3 cache, 512MB SDRAM. And running 10.3.9. as i just got the new iphone4, and this wouldn't connect with itune or any other programm

  • Datasheets and certs of conformance

    Hi, I was wondering if anybody knows how I can get my hands on datasheets and certificates of conformance for spare parts? I've been searching online but to no avail, I've contacted HP helplines and customer services but again, to no avail. I'm looki