Anydata and %rowtype

Does anyone know if this concept is possible:
create table test1(
    a   anydata)
declare
    l_emp hr.employees%rowtype;
begin
  select * into l_emp from hr.employees  where rownum = 1;
  insert into test1(a) values (sys.anydata.convert???(l_emp));
end;
/Based on a few quick tests and some searching, I don't believe that it is, but I just wanted to check and make sure first.
Tyler Muth
http://tylermuth.wordpress.com
[Applied Oracle Security: Developing Secure Database and Middleware Environments|http://www.amazon.com/gp/product/0071613706?ie=UTF8&tag=tylsblo-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0071613706]

well, you could do this
create table test1(
    a   anydata)
create type emp_ot is object
(ename varchar2(10)
,sal number
,hiredate date
declare
    l_emp emp_ot;
begin
  select emp_ot (ename, sal, hiredate)
    into l_emp
    from emp
  where rownum = 1
  insert into test1(a) values (sys.anydata.convertObject (l_emp));
end;
commit
select *
from test1
/

Similar Messages

  • SYS.ANYDATA; and Global_Name

    How to use SYS.ANYDATA?
    I thought it is a data type that can store any type of data? I created a table with an id column and a column with sys.anydata data type; then insert into that table with values of user-defined data type. It failed. What's the right way to use sys.anydata?
    Another question is how to activate the global name of a database? I tried to create a public database link, but it is inactive. Do I need to do anything to make the global name active?
    Thanks

    How to use SYS.ANYDATA?
    I thought it is a data type that can store any type of data? I created a table with an id column and a column with sys.anydata data type; then insert into that table with values of user-defined data type. It failed. What's the right way to use sys.anydata?
    Another question is how to activate the global name of a database? I tried to create a public database link, but it is inactive. Do I need to do anything to make the global name active?
    Thanks

  • Problem with Native Web Services and %ROWTYPE

    Hi,
    I have a simple stand-alone function which takes a varchar2 IN argument, uses the IN argument to retrieve data from a single table, and returns the data as TableName%rowtype.
    Accessing the generated WSDL from a browser using http://host:port/orawsv/FUNCTION?wsdl results in the following :
    <?xml version="1.0" ?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <soap:Fault>
    <faultcode>soap:Client</faultcode>
    <faultstring>Error processing input</faultstring>
    <detail>
    <OracleErrors xmlns="http://xmlns.oracle.com/orawsv/faults">
    </OracleErrors>
    </detail>
    </soap:Fault>
    </soap:Body>
    </soap:Envelope>
    I can see a successfully generated WSDL for a similar function which returns XMLType
    Is %rowtype supported as a return argument ?
    And on a related note, is ref cursor supported as a return argument in a stored procedure ?
    Thanks,
    Pete
    PS - version details as follows ...
    "BANNER"
    "Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production"
    "PL/SQL Release 11.2.0.1.0 - Production"
    "CORE     11.2.0.1.0     Production"
    "TNS for Linux: Version 11.2.0.1.0 - Production"
    "NLSRTL Version 11.2.0.1.0 - Production"
    Edited by: user13046122 on 31-Aug-2012 01:48

    It appears that %ROWTPYE is not supported directly, and that we need to create a TYPE to wrap the return data
    Thanks to Marc Thompson for the details (http://marc-on-oracle.blogspot.co.uk/2007/12/11g-database-installation-and-native.html)
    PD

  • Forms 6i, blocks and rowtype

    Is there a way to base a block on a table or view and then reference the data locally via a %rowtype. If my block has 25 items and I want to have a database procedure do the updates to the table, I can create the procedure to accept the 25 columns as parameters, or I can pass in a pl/sql table or record. If I want to pass in a record or pl/sql table, what's the easiest way to populate the pl/sql table or record. Can I reference the table name via the %rowtype and access the local values?
    Thanks

    Updating this thread...
    I see some people talking about Forms 6i and SQL Plus crashing when connecting to a database:
    APPCRASH Problem for plus80 and forms 6i builders
    Forms Developer 6i will crash if you try connecting to a database running the AL32UTF8 character set. Older systems require the UTF8 character set.
    Here are several very old threads with similar issues:
    <p>connecting form 6i  to oracle database 10G express edition
    <br>Forms 6i X 10g Database (the solution is here)
    More info: In Windows 7, I am running Forms 6i WITHOUT compatibility mode set to XP. It all seems to be running fine. I have had no problems with it since I first installed last year.
    Unfortunately, I don't have an Oracle 11 database available to try connecting to. I have only used this setup with Oracle 9 and 10 databases.

  • Any tips for debugging apply handlers? How to use SYS.AnyData

    Well, I'm setting up my first stream.
    I've set up a simple stream just to understand the concepts, but now I need to start the real work.
    I've written an apply handler that takes the LCR, turns pulls values from the sys.AnyData, and uses them in another statement. I have excerpts from it below-- I've not used a SYS.AnyData before, and I'm not sure if I've set the conversion up correctly:
    CREATE OR REPLACE PROCEDURE reg_data_handler(in_any IN SYS.AnyData)
    RETURN SYS.AnyData
    IS
         lcr     SYS.LCR$_ROW_RECORD;
         lcr_anydata SYS.AnyData;
         -- Should I declare like this
    -- or should I make it a Number for
    -- the SYS.AnyData conversion?
         -- TYPE is really a NUMBER(11)
    samp_time nh_rlp_stats.sample_time%TYPE;
    BEGIN
    -- Access the LCR
    rc := in_any.GETOBJECT(lcr);
    -- Get the object command type
    command := lcr.GET_COMMAND_TYPE();
    IF command = 'INSERT' THEN
    -- get the needed data
    lcr_anydata := lcr.GET_VALUE('new','SAMPLE_TIME');
    rc := lcr_anydata.get_number(samp_time);
    Does anyone have any tips on how to do the debugging as painlessly as possible? I've tested as much of the individual units as possible, but in order to test the code that pulls from the LCR, it seems like I'll need to hook it into the steam and hope for useful dbms_output statements. Other ideas?
    Thanks very much.
    Robin T

    Actually, I have read the supplied list a couple of times over. There is a difference between reading and doing, particularly as documentation can be mis-interpreted or miss key items. I supplied the code snippets in case some one could see that I was mis-reading the info.
    My particular concern is with debugging: are there any tips people have learnt to make the process easier? If I just hook the handler into a stream and test it that way, I suspect that it might take some time to shake the kinks out. However, it occurred to me this morning that maybe I can fake out the LCR by constructing one of my own in a wrapper procedure and calling the handler within that. So, I'll see if that speeds up the process.
    Thanks very much for your reply.

  • 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

  • Passing of old and new trigger details to a generic function or procedure

    Hi all.
    I have a requirement to pass all the new and old column information from a database trigger ( for the purposes of this discussion, it will be a before row, insert, update and delete trigger) to a procedure/function ( either is fine).
    My first thought was to create a separate routine for each table I wish to implement this in, which has a new and old input parameter for every column, however I realised I needed a solution where the called routine needs to be generic (because we'll let other developers call the same routine and we dont want them to have to create their own version for their table).
    This presents a problem as every table I wish to implement this on could have a completely different amount of columns (and dataypes). The called routine will operate under a pragma autnonmous_transaction (as it will be performing commits) so I need to pass all the fields across in one go.
    Another idea I had was to create an type object with (potentially) 300 generic fields that I assign the values to and pass that as a parameter, however I could never know before hand what datatypes are needed, CLOBS, DATE, VARCHAR, etc...
    Does anyone have any ideas on how I can accomplish this with a generic routine?
    Regards,
    Greg.

    Greg wrote:
    I hadn't heard of the ANYDATA type, I'll have a lookThe Data Cartridge Developer's Guide has all the details - http://docs.oracle.com/cd/E11882_01/appdev.112/e10765/toc.htm
    Here's a link that has some simple examples just for ANYDATA - http://orafaq.com/node/1853
    TOOLKIT ALERT - Here is a classic link you will want to keep - How to pipeline a function with a dynamic number of columns?
    I asked in another thread if they could create a locked TOOLKIT thread (like report abuse here - a global one for mods only) to put these nuggets in one place.
    see ascheffer's responses where he shows how to create a pipelined function that call return a result set with a different (dnynamic) number of columns for different calls! It uses functionality in the
    ANYTYPE - metadata
    ANYDATA - data with metadata
    ANYRESULTSET - A resultset where every column is of type ANYDATA - meaning whatever you define it to be.
    Rough overview - The cartridge exposes some interface functions (3-5 are typically needed) that you implement in a procedure. See scheffer post for his procedure:
      static function ODCITableDescribe( rtype out anytype, p_parm in varchar2, p_rows_req in number := 2 )
      return number,
      static function ODCITablePrepare( sctx out NColPipe, ti in sys.ODCITabFuncInfo, p_parm in varchar2, p_rows_req in number := 2 )
      return number,
      static function ODCITableStart( sctx in out NColPipe, p_parm in varchar2, p_rows_req in number := 2 )
      return number,
      member function ODCITableFetch( self in out NColPipe, nrows in number, outset out anydataset )
      return number,
      member function ODCITableClose( self in NColPipe )The TableDescribe does just what it's name says.
    Oracle calls these functions to get the metadata about your custom types, to describe and return result sets.
    Are you familiar with VARIANTs that are used in COM programming? A variant is a 16 byte object (record) type. 2 bytes contain the 'type' of the variant (int, char, etc) and other bytes contain data of that 'type'. It is a generic container that can hold any type of data.
    The ANYTYPE, ANYDATA and ANYRESULTSET are roughly analogous to that.

  • Type vs rowtype

         this must be one of the most ask question, from research i done
    just to get it straight here is a example
        pnLeadID          p_lead.lead_id%TYPE ,
      IS
        v_lead_rec           p_lead%ROWTYPE;
       v_lead_rec       := dml_p_lead.get_rec(pnLeadID);
    -- %TYPE is used to declare a field with the same type as
    -- that of a specified table's column:
    -- %ROWTYPE is used to declare a record with the same types as
    -- found in the specified database table, view or cursor:
    so pnleadid it gets the collumn in p_lead table
    so for v_lead_rec is saying what ever is in the collumn pnleadid =v_lead_rec
    did i get it right ? correct me if im wrong
    thanks

    did i get it right ? correct me if im wrong
    Yes - Here is some simple sample code you can use in the SCOTT schema to see what happens
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    -- pipelined function
    create or replace function get_emp( p_deptno in dept.deptno%TYPE )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
    select * from table(get_emp(20))
    Note that the function uses both %TYPE for the parameter and %ROWTYPE to hold a row of the EMP table:
    create or replace function get_emp( p_deptno in dept.deptno%TYPE )
        l_rec  emp%rowtype;
      begin
    The %TYPE makes sure that the parameter has a value that is compatible with the DEPTNO column of the DEPT table.
    Notice that you can NOT tell what that datatype actually is by looking at the code.

  • Using a sequence inside BEFORE TRIGGER

    Hi all,
    I just created a testtable and a sequence to use as a primary key column value for that table.
    I tried to create a BEFORE INSERT trigger on that table and in the trigger i tried to set up the primary key column value using the sequence
    but while compiling i am getting the error "Error(9,30): PLS-00357: Table,View Or Sequence reference 'SEQ_OF_TESTTABLE.NEXTVAL' not allowed in this context"
    My Version:Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    All the objects created with the same user. I would appraciate any help, thanks all
    EDIT
    I solved the problem using the below
    create or replace
    TRIGGER Bef_Ins_On_Testtable
    BEFORE INSERT ON TestTable
    FOR EACH ROW
    declare
    ntemp_id INT;
    BEGIN
    SELECT SEQ_OF_TESTTABLE.NEXTVAL INTO ntemp_id FROM DUAL ;
    DBMS_OUTPUT.PUT_LINE('İNSERTED');
    :NEW.VSURNAME := 'HAKKİ' ;
    :NEW.NID := ntemp_id;
    END;But i wonder why i can use the sequence(just as seqeunce_name.NEXTVAL) in INSERT statement and why cant in trigger?
    Edited by: user9371286 on 31.Tem.2010 04:15
    Edited by: user9371286 on 31.Tem.2010 04:21
    Edited by: user9371286 on 31.Tem.2010 04:27

    Please post your trigger code and your database version ( the result of: select * from v$version; ).
    Put it between tags, so your example will stay formatted.
    (see: http://forums.oracle.com/forums/help.jspa for more examples regarding tags)
    "PLS-00357: Table,View Or Sequence reference "string" not allowed in this context
        Cause: A reference to database table, view, or sequence was found in an inappropriate context. Such references can appear only in SQL statements or (excluding sequences) in %TYPE and %ROWTYPE declarations. Some valid examples follow: SELECT ename, emp.deptno, dname INTO my_ename, my_deptno, my_dept .FROM emp, dept WHERE emp.deptno = dept.deptno; DECLARE last_name emp.ename%TYPE; dept_rec dept%ROWTYPE;
        Action: Remove or relocate the illegal reference."
    +http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/plsus.htm#sthref13592+
    You can find examples of triggers referring to sequences here, by doing a search on this forum or:
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#ABC1032282                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Weird case of simple parameter assignment

    Hi, Guys !
    Here's some challenge for you. I have a Package where one of the Functions used for Error_logging. It works fine, except rarely it gives an Error :
    ORA-06512: at "CORE_PKG", line 295
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    272 PROCEDURE ERR_HANDLER_PRC
    273 (iERR_CODE IN NUMBER,
    274 oRETURN_CODE OUT NUMBER,
    275 oRETURN_MSG OUT ERROR_MSG_BV.MSG_TEXT%TYPE,
    276 iUSE_SQLERRM IN BOOLEAN DEFAULT TRUE) IS
    277
    278 vMSG_REC ERROR_MSG_BV%ROWTYPE := MSG_ROW_FNC (iERR_CODE); -- This Function selects 0 or 1 row based on passed Error code from Table of standard messages (just 33 rows)
    279
    280 BEGIN
    281
    282 IF vMSG_REC.MSG_TEXT IS NULL OR vMSG_REC.RETURN_CODE IS NULL THEN
    283 vMSG_REC.RETURN_CODE := iERR_CODE;
    284 vMSG_REC.MSG_TEXT := SQLERRM (iERR_CODE);
    285 END IF;
    286
    287 oRETURN_CODE := vMSG_REC.RETURN_CODE;
    288 oRETURN_MSG := vMSG_REC.MSG_TEXT;
    289
    290 EXCEPTION
    291
    292 WHEN OTHERS THEN
    293
    294 oRETURN_CODE := vMSG_REC.RETURN_CODE;
    295 oRETURN_MSG := vMSG_REC.MSG_TEXT;
    296
    297 INSERT_ERROR_LOG_PRC ('CORE_PKG', 'ORACLE', SQLCODE, SQLERRM, 'ERR_HANDLER_PRC',
    298 'Execution Block of ERR_HANDLER_PRC');
    299
    300 END ERR_HANDLER_PRC;
    At line 295 - just a simple assignment of one field (which is VARCHAR2 (512) <- longest Oracle SQLERRM string) belonging to a ROWTYPE variable. But that's happening inside error handler which means that initial
    error occur on Line 284 or 288. On those lines
    also similar assignments. I checked all parameters, variables, %types and %rowtypes and they all
    VARCHAR2(512) - exactly what are suppose to be. Longest string selected from Table of standard messages into %rowtype.msg_text is 97 characters (eventhough it can hold up to 512).
    So my question is HOW in the world is possible that Buffer is too small If it's SAME length that variable ???
    (and actual string less then 512)
    Any Ideas anybody ?
    Thanx ! ( Please let me know If anything is unclear )

    Thanx, Rich. I understand what you're saying and I was able to re-create error in Anonymous block which calls
    ERR_LOG_HANDLER_PRC and which call ERR_HANDLER_PRC that raises an Error.
    DECLARE
    STATUS ERROR_LOG_BV.ERROR_CODE%TYPE;
    STATUS_MSG VARCHAR2(20); <-- this declaration causes 'Buffer too small' error
    BEGIN
    PENSKE_CORE_PKG.ERR_LOG_HANDLER_PRC (SQLCODE, SQLERRM, STATUS, STATUS_MSG, TRUE, 'ORACLE',
    'ANONYMOUS_BLOCK', 'TEST_CALL');
    END;
    But this code executes fine:
    DECLARE
    STATUS ERROR_LOG_BV.ERROR_CODE%TYPE;
    STATUS_MSG ERROR_LOG_BV.ERROR_DESC%TYPE;
    BEGIN
    PENSKE_CORE_PKG.ERR_LOG_HANDLER_PRC (SQLCODE, SQLERRM, STATUS, STATUS_MSG, TRUE, 'ORACLE',
    'ANONYMOUS_BLOCK', 'TEST_CALL');
    END;
    But that's a testing code. In the real code I checked all Programs calling that routine, and all
    OUT parameters and variables declared dynamically like :
    vERR_CODE ERROR_LOG_BV.ERROR_CODE%TYPE;
    vERR_MSG ERROR_LOG_BV.ERROR_DESC%TYPE;
    So I don't know how is that possible ?

  • A new Bug Found

    Hi Mr. Steve,
    I am using your example from your blog "Optional Required Fields" and i have noticed the following behaviour.
    You have a table with 4 columns, Id, RowType, ValueA and ValueB.
    Id and RowType is mandatory and ValueA and ValueB are not (they are forced to be mandatory by the selection of the RowType.
    I created a sequence ("Test_Seq") so to populate the Id. I overriden the create method in the TestEntityImpl.java to populate the Id automatically:
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    SequenceImpl sequence = new SequenceImpl("TEST_SEQ", getDBTransaction());
    this.setId(sequence.getSequenceNumber());
    I then create a jspx and dragged the TestEntities View as an ADF Creation Form.
    I deleted the RowType and dragged it again as a selectOneRadio, with two static values (A and B).
    In the valueChange listener i created a bean and incuded the following code so that it will not force the validate method before a selection is made:
    public void RowTypeChanged(ValueChangeEvent valueChangeEvent) {
    FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("RowTypeChanged","x");
    I then opened the Page Definition xml file for my page and inside the binding i created an attribute value for the RowType that i have deleted earlier.
    In the controller class i specified the "view.util.ConditionalValidationPageController".
    By the way, i dragged your updateTest() method onto my submit button to commit the transaction.
    When i run the page, everything works fine. Conditional validation works.
    However, i don't want to have the Id input text enabled, so i disabled it (becuase it is populated automatically by the sequence).
    When i run the page, and select a value for RowType and have the other fields empty (ValueA and ValueB), instead of showing me the error, the form goes into edit mode, bringing the last record. VERY STRANGE.
    Can you please give me a solution into how i can overcome this?
    Thank you
    Antonis

    Please email me a JAR file of the version of my demo that reproduces the problem along with the exact steps to reproduce the problem. I don't have time this week to reproduce the issue myself from scratch, but you if can help me out by doing that, it will make it easier to diagnose.
    ** Please remove the two large *.jar files from ./ViewController/public_html/WEB-INF/lib to make the JAR file you send me smaller.
    Thanks.

  • Ho can I generate a scheduler_job DDL?

    Hi All,
    Any ideas on how to extract DDL of scheduler_job? I am trying to migrate scheduler jobs from one test server to production and other multiple dev/test servers. I have already tried from OEM using create like option but seems a little cumbersome as the ddl will contain a new job name. Any quicker, easier way to do this?
    Thanks
    Notse

    Hi,
    One way is to use expdp on the schema containing the jobs and then run impdp on the dumpfile specifying a SQLFILE for output.
    This will work for all jobs/programs/schedules etc but won't work for job argument values or program argument default values (these values are stored as anydata and not representable as text).
    If you want a single job exported you can also use the pl/sql below directly from the database (use the obj$ table to get the object id). Again argument values are not exported.
    exec sys.dbms_sched_main_export.export_job(11867)
    declare
      c1 varchar2(4000);
      b1 boolean := true ;
      begin
        while(b1)
        loop
          c1 := dbms_sched_main_export.next_piece(b1) ;
           dbms_output.put_line ( c1 ) ;
        end loop ;
      end ;
    /Hope this helps,
    Ravi.

  • Apply process is aborting with:ORA-12801: error signaled in parallel query

    hi,
    We created a queue of a specific type, capture and apply process on the queue. Then we started the queue capture and the apply process. The problem is that the apply process is getting enabled and with in moments going into aborted state. wea re getting the follwoing error:
    ORA-12801: error signaled in parallel query server P000
    ORA-00600: internal error code, arguments: [kwqiceval:anyconv], [], [], [], [], [], [], []
    Any idea what could have gone wrong?
    scripts:
    exec dbms_aqadm.create_queue_table(queue_table=>'qt_anc',queue_payload_type=>'type_anc',multiple_consumers=> true, compatible => '9.0');
    exec dbms_aqadm.create_queue (queue_name => 'q_anc',queue_table=>'qt_anc');
    EXEC DBMS_AQADM.START_QUEUE (queue_name => 'q_anc');
    DECLARE
    emp_rule_name_dml VARCHAR2(300);
    emp_rule_name_ddl VARCHAR2(300);
    BEGIN
    DBMS_STREAMS_ADM.ADD_TABLE_RULES(
    table_name => 'ops.t_anc',
    streams_type => 'capture',
    streams_name => 'capture_anc',
    queue_name => 'strmadmin.q_anc',
    include_dml => true,
    include_ddl => false,
    source_database => null,
    dml_rule_name => emp_rule_name_dml,
    ddl_rule_name => emp_rule_name_ddl);
    DBMS_APPLY_ADM.SET_ENQUEUE_DESTINATION(
    rule_name => emp_rule_name_dml,
    destination_queue_name => 'strmadmin.q_anc');
    END;
    DECLARE
    emp_rule_name_dml VARCHAR2(300);
    emp_rule_name_ddl VARCHAR2(300);
    BEGIN
    DBMS_STREAMS_ADM.ADD_TABLE_RULES(
    table_name => 'ops.t_anc',
    streams_type => 'apply',
    streams_name => 'apply_anc',
    queue_name => 'strmadmin.q_anc',
    include_dml => true,
    include_ddl => false,
    source_database => null,
    dml_rule_name => emp_rule_name_dml,
    ddl_rule_name => emp_rule_name_ddl);
    DBMS_APPLY_ADM.SET_ENQUEUE_DESTINATION(
    rule_name => emp_rule_name_dml,
    destination_queue_name => 'strmadmin.q_anc');
    END;
    BEGIN
    DBMS_APPLY_ADM.START_APPLY(
    apply_name => 'apply_anc');
    END;
    BEGIN
    DBMS_CAPTURE_ADM.START_CAPTURE(
    capture_name => 'capture_anc');
    END;
    /

    Hello
    The above configuration is never supported. The implicit capture expects the queue payload to be SYS.ANYDATA and same with implicit apply also.
    However you can use Streams Messaging capability to achieve this. You need to wrap the messages with SYS.ANYDATA for this to work. The implicit capture uses a persistent logminer session to generate LCRs and it then wraps it with SYS.ANYDATA and enqueues into the capture queue, it then propagated to apply queue. You can generate LCRs and wrap it with SYS.ANYDATA and then enqueue into the capture queue then apply can recognise the messages.
    Here is an example on creating LCRs (tested in 10g):
    CREATE TABLE lcr_test (col1 NUMBER);
    DECLARE
         l_lcr SYS.LCR$_ROW_RECORD;
    BEGIN
         l_lcr :=
    SYS.LCR$_ROW_RECORD.CONSTRUCT
         source_database_name=>SYS_CONTEXT('USERENV','DB_NAME'),
         command_type=>'INSERT',
         object_owner=>USER,
         object_name=>'LCR_TEST'
         l_lcr.ADD_COLUMN('new','col1',SYS.AnyData.ConvertNumber(99));
         l_lcr.EXECUTE(TRUE);
         COMMIT;
    END;
    SELECT * FROM lcr_test;
    Converting to SYS.ANYDATA:
    DECLARE
         l_lcr SYS.LCR$_ROW_RECORD;
         l_anydata SYS.ANYDATA;
    BEGIN
         l_lcr :=
    SYS.LCR$_ROW_RECORD.CONSTRUCT
         source_database_name=>SYS_CONTEXT('USERENV','DB_NAME'),
         command_type=>'INSERT',
         object_owner=>USER,
         object_name=>'LCR_TEST'
         l_lcr.ADD_COLUMN('new','col1',SYS.AnyData.ConvertNumber(99));
         l_anydata:=SYS.ANYDATA.ConvertObject(l_lcr);
         ENQ_PROC(l_anydata);
         COMMIT;
    END;
    Thanks,
    Rijesh

  • ADD_SUBSET_RULES for LOB

    Oracle 11g:
    I need to add a subset_rule for eg: (column * (some forumula)) = result. But the problem is that the table has LOB columns. And subset rule documentation says:
    Also, the specified table cannot have any LOB, LONG, or LONG RAW columns currently or in the future.I am currently in the fix as to what I can do to get rid of that row in capture process.

    Just a quick feedback on this "empty Array".
    The documentation is not cristal clear but I am convinced it refers to the array of LCR
    into the ANYDATA and not an array of ANAYDATA. Nevertherless, I have explored the ARRAY of anydata
    using an action context associated with STREAMS$_ARRAY_TRANS_FUNCTION(as opposed
    to STREAMS$_TRANS_FUNCTION) which allow the return of many ANYDATA for a single
    one ANYDATA input and managed to procuded empty ANYDATA.
    I did not found any reference or example to help me in Google or Metalink
    so I published my findings here as it may serve further people in search of info about usage of
    STREAMS$_ARRAY_TRANS_FUNCTION
    Here is a type of function that could allow this.
    The context must be associated with this function _ARRAY
    declare
      v_dml_rule_name VARCHAR2(30);
      v_ddl_rule_name VARCHAR2(30);
      action_ctx   sys.re$nv_list;
      ac_name      varchar2(30) := 'STREAMS$_ARRAY_TRANS_FUNCTION';       <-- note the '_ARRAY'
    BEGIN
        action_ctx := sys.re$nv_list(sys.re$nv_array());
        action_ctx.add_pair( ac_name, sys.anydata.convertvarchar2('strmadmin.DML_TRANSFORM_FUNCT'));
      DBMS_STREAMS_ADM.ADD_TABLE_RULES(
          table_name         => 'STRMADMIN.TEST_DROP_COL',
          streams_type       => 'capture',
          streams_name       => 'TEST_CAPTURE',
          queue_name         => 'STRMADMIN.TEST_CAPTURE_Q',
          include_dml        => true,
          include_ddl        => false,
          include_tagged_lcr => false,
          inclusion_rule     => true,
          dml_rule_name      => v_dml_rule_name ,
          ddl_rule_name      => v_ddl_rule_name );
        dbms_rule_adm.alter_rule( rule_name    => v_dml_rule_name, action_context => action_ctx);
    END;
    /This create a variation of Streams transformation function with is reported
    into as 'ONE to MANY' transformation into DBA_STREAMS_TRANSFORM_FUNCTION
    col TRANSFORM_FUNCTION_NAME for a50
    col VALUE_TYPE for a30
    select RULE_OWNER, RULE_NAME, VALUE_TYPE, TRANSFORM_FUNCTION_NAME, CUSTOM_TYPE
           from DBA_STREAMS_TRANSFORM_FUNCTION;The function becomes more complicated to adapt to this multi-anydata dimension:
    RULE_OWNER     RULE_NAME        VALUE_TYPE                     TRANSFORM_FUNCTION_NAME                            CUSTOM_TYPE
    STRMADMIN      TEST_DROP_COL44  SYS.VARCHAR2                   strmadmin.DML_TRANSFORM_FUNCT                      ONE TO MANY
    CREATE OR REPLACE function DML_TRANSFORM_FUNCT( inAnyData in SYS.AnyData)
    RETURN sys.STREAMS$_ANYDATA_ARRAY IS
        ret          pls_integer;
        typelcr      VARCHAR2(61);
        lcrOut       SYS.LCR$_ROW_RECORD;
        var_any      anydata ;
        v_num        number ;
        v_lcr        SYS.LCR$_ROW_RECORD;
        v_arr        SYS.STREAMS$_ANYDATA_ARRAY;
    BEGIN
       v_arr:=SYS.STREAMS$_ANYDATA_ARRAY();
       typelcr := inAnyData.getTypeName();
       IF typelcr = 'SYS.LCR$_ROW_RECORD' THEN
          -- Typecast AnyData to LCR$_ROW_RECORD
          ret := inAnyData.GetObject(lcrOut);
          IF lcrOut.get_object_owner() = 'STRMADMIN' THEN
             IF lcrOut.get_object_name() = 'TEST_DROP_COL' THEN
                lcrOut.delete_column(column_name=>'DATA_LONG');
                -- check if we don't need to discard this LCR
                var_any := lcrOut.get_Value('NEW','MYKEY') ;
                if var_any is not null then
                   ret:=var_any.getnumber(v_num);
                   if v_num = 4 then
                       -- We do nothing but return a null ANYDATA
                       RETURN v_arr ;
                   end if;
                end if;
                -- this LCR is not to be discared, then let's apply our transformation
                lcrOut.set_value('new','DATA_SHORT',anydata.convertvarchar2('PP CONVERTED') );
                v_arr.extend;
                v_arr(1) :=SYS.AnyData.ConvertObject(lcrOut);
                RETURN v_arr;
             END IF;
          END IF;
        END IF;
        -- if we are here then the LCR is not a row
            -- or the row was not one bound for transformation,
            -- so we alter nothing
        v_arr.extend;
        v_arr(1) :=inAnyData ;
        RETURN v_arr;
    END;
    /Alas, when the value of MYKEY is null the function produces
    a null ANYDATA which is explicitely forbidden :
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_streams_adm.htm#CDEJFBHD
      Logminer                        Captured                   Capture
            ID Capture user           Start scn   CHANGE_TIME    Type       Rule set Name   Neg rule set    Status
            41 STRMADMIN             110500477205 02-07 13:54:48 LOCAL      RULESET$_28                     ABORTED
                                                                                                                Last remote
                                                           Last system    Last scn      Delay      Last scn      confirmed      Delay
    Capture name           QUEUE_NAME                          scn         Scanned     Scanned     enqueued     scn Applied  Enq-Applied
    TEST_CAPTURE           TEST_CAPTURE_Q                                                                       110503647881
    no rows selected
    ORA-26747: The one-to-many transformation function strmadmin.DML_TRANSFORM_FUNCT
    encountered the following error:  return of NULL anydata array element not allowedOf course I could generate the header
        v_lcr        SYS.LCR$_ROW_RECORD;
                   ret:=var_any.getnumber(v_num);
                   if v_num = 4 then
                       -- lcrOut.set_value('new','DATA_SHORT',anydata.convertvarchar2('v_num = '||to_char(v_num)) );
                       v_lcr :=  SYS.LCR$_ROW_RECORD.CONSTRUCT (
                                         source_database_name=>SYS_CONTEXT('USERENV','DB_NAME'),
                                         command_type=>lcrOut.get_command_type(),
                                         object_owner=>lcrOut.GET_OBJECT_OWNER(),
                                         object_name=>lcrOut.GET_OBJECT_NAME() );
                       v_arr.extend;
                       v_arr(1) := SYS.AnyData.ConvertObject(v_lcr);
                       RETURN v_arr ;
                   end if;But the LCR is create with and sent, not discarded as expected despite
    that there are no columns and it fails miserably at apply site.
    That's all, and that's a failure. Maybe somebody else will have a better inspiration.
    Edited by: bpolarsk on Jul 2, 2009 5:57 AM

  • How to exit from a loop on 2 different conditions

    Hello Experts
    I’m trying to write a procedure in which I’m taking PROVINCE as an input parameter. All the provinces are stores in a table. I’m using a cursor and rowtype variable to check the province. After I finds province I displays province and its code. Everything works fine expect when I don’t find the province. I’m not sure how to exit from loop if I don’t find the province. I already uses exit when condition. I was expecting else condition should work and should exit from the loop but it doesn’t. Can please somebody show me how to exit if I don’t find province in the table through cursor.
    Here is my code
    set serveroutput on
    variable G_TAX varchar2(10)
    CREATE OR REPLACE PROCEDURE p_create(i_state VARCHAR2)is
    CURSOR cur_bb_tax is
    select * from bb_tax;
    bb_tax_details bb_tax%rowtype;
    begin
    if not cur_bb_tax%isopen then
    open cur_bb_tax;
    end if;
    loop
    fetch cur_bb_tax into bb_tax_details;
    if (bb_tax_details.state = i_state) then
    dbms_output.put_line(bb_tax_details.state || bb_tax_details.idstate);
    end if;
    exit when bb_tax_details.state = i_state;
    end loop;
    close cur_bb_tax;
    exception
    when others then
    dbms_output.put_line(SQLERRM);
    end;
    Thanks in advance

    Hello,
    Why don't you use dbms_output.Put_line and print output to find why logic is not able to execute? Maybe upper case/lower case/whitespace. *Also put your code between \ to preserve formatting*.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • No Devices Available

    While trying to backup my files using Backup, I got the message: Burn Disc In: No Devices Available No devices available for burning. What's wrong with this picture? Message was edited by: Brad Purvis

  • Installing from a local trial version instead of download

    Hi everyone, I had downloaded the trial version of the master suite so I'm wondering, can I install this, then activate it via my adobe login which is tied to my creative cloud? 

  • Cannot add folder to i tunes

    I have been runnng on the new version of itunes for a while. Since yesterday though, when i try to add a folder to my library, it won't appear. Sometimes though only a few files of the folder will appear. Any ideas?

  • Page setup to print

    Hi and thanks for your help. I have opened my file.acsm, and it looks good.  I go to print it.  it seems to be cutting off part of each page.  I can see it fine in digital editions, but how do I change the printing so it prints the whole page.  it se

  • Best way to Remove movies from iphoto to freeup space ?

    I would like to remove all the movies from iphoto and place them in a folder for later processing in imovie ...i would like to free up all the space any suggestions