TABLE  FUNCTION OR CAST WITH TABLE FUNCTION

Consider following scenario:
I've a function which returns nested table of employees.
I am calling this function in some other procedure and building a query dynamically.
Sample code looks like
CREATE OR REPLACE  PROCEDURE TEST_PROC( P_EMP_ID   IN   NUMBER,
                                        O_EMP_LIST OUT  SYS_REFCURSOR) IS
v_tbl_emp_id       tbl_emp_id;
begin
v_tbl_emp_id :=  fn_get_usr_list (P_EMP_ID);--fetches employee id  reporting to given emp id
v_select_clause :=
         'SELECT EMP_NO,EMP_NAME,DEPT_NO';
v_from_clause := ' FROM EMP';
v_where_clause1 :=
            ' WHERE emp_no IN (
                      SELECT  COLUMN_VALUE
                                 FROM TABLE
                                         (CAST
                                             (:v_tbl_emp_id AS tbl_emp_id
--AND I AM APPENDING AND CLAUSES BASED ON VARIOUS CONDITION
v_qry :=     v_select_clause  || v_from_clause|| v_where_clause1;
OPEN O_EMP_LIST FOR v_qry USING v_tbl_emp_id;
END TEST_PROC;I CAN REWRITE THE SAME CODE AS
CREATE OR REPLACE  PROCEDURE TEST_PROC( P_EMP_ID   IN   NUMBER,
                                        O_EMP_LIST OUT  SYS_REFCURSOR) IS
begin
v_select_clause :=
         'SELECT EMP_NO,EMP_NAME,DEPT_NO';
v_from_clause := ' FROM EMP';
v_where_clause1 :=
            ' WHERE emp_no IN (
                      SELECT  COLUMN_VALUE
                                 FROM TABLE(fn_get_usr_list (:P_EMP_ID)))';
--AND I AM APPENDING AND CLAUSES BASED ON VARIOUS CONDITION
v_qry :=     v_select_clause  || v_from_clause|| v_where_clause1;
OPEN O_EMP_LIST FOR v_qry  USING P_EMP_ID;
END TEST_PROC;Now I would like to know which one performs better
USING TABLE ALONE OR USING CAST ALONG WITH THE TABLE FUNCTION?
AND PLEASE HELP ME ON FORMATTING CODE.
I've added tags still its not formatting!!
Thanks,
NM
Edited by: user10862473 on Apr 11, 2011 12:14 AM
Edited by: BluShadow on 11-Apr-2011 09:13
fixed {noformat}{noformat} tags

To be sure which is better you will have to test them both. You can use either AUTOTRACE or Oracle trace (tkprof) to get run metrics - system resources used when running both versions of the query. AUTOTRACE won't provide CPU information, but if you can find the qieries in (G)V$SQL you can find it there. Oracle trace is more effort but should provide more metrics. I could do it if I have privileges :(..
All I can do is check the time taken by the both procedures using set timing on, which gives same result for both.
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.07Thanks,
NM

Similar Messages

  • Removing Color Cast with TIFF images?  (PSE 8)

    Hello,
    Hoping someone can help.  I'm trying to "remove color cast" with TIFF images and I'm not seeing the option as available.  It works fine when I try to use it with JPEG images.
    To be clear....I'm using PSE 8...after opening a picture (of course), on the top menu "Enhance", then "Adjust Color".  When I'm working with a TIFF image the option "Remove Color Cast" is not available/active.  It works fine with JPEG images.
    What am I missing?
    Thanks,
    Rich

    Alternatively if you want to keep the file at 16 bit click File >>Open As >>Camera Raw
    Then use the temperature and tint sliders to edit your tiff.
     

  • RTFEditorKit isn't casting with TableEditorKit

    Hi,
    I am preparing RTFEditor. I did paging and other properties (bullet, numbered etc.) but I can't use table on jtextpane. I'm postin my Codes below.
    my call button Codes:
    private void mnTabloEkleActionPerformed(java.awt.event.ActionEvent evt) {
          TableEditorKit  ourKit = (TableEditorKit) m_monitor.getEditorKit(); // editorkit get edildiðinde ise çalýþmýyor.
          TableDocument myDoc = (TableDocument) m_monitor.getDocument();// bu olamszsa tabloyu koymuyor.
            myDoc.insertTable(0, 2, new int[] {200, 100, 150});
            myDoc.insertTable(4, 2, new int[] {100, 50});
            try {
                myDoc.insertString(10, "Paragraph after table.\nYou can set caret in table cell and start typing.", null);
                myDoc.insertString(4, "Inner Table", null);
                myDoc.insertString(3, "Cell with a nested table", null);
                myDoc.insertString(0, "Table\nCell", null);
            catch (BadLocationException ex) {
                ex.printStackTrace();
    }my TableEditorKit's Code:
    package editor.page;
    import dys.javax.swing.text.rtf.RTFEditorKit;
    import javax.swing.text.*;
    * @author Administrator
    public class TableEditorKit extends RTFEditorKit {
        ViewFactory defaultFactory = new PageableEditorKit().getViewFactory();  //bu alaný commentlediðimizde yazý çýkýyor,
                                                                                //tablo çýkmýyor sayfa geniþliyor.
        public ViewFactory getViewFactory() {
            return defaultFactory;
        public Document createDefaultDocument() {   //bu alaný commentlediðimizde yazý ve tablo
                                                     //çýkmýyor sadece sayfa orjinal haline yakýn bir þekilde duruyor.
            return new TableDocument();
    at last my RTFfEditorKid's Code:
    package editor.page;
    import java.awt.*;
    import java.awt.print.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.geom.AffineTransform;
    import javax.swing.event.*;
    import dys.javax.swing.text.rtf.RTFEditorKit;
    public class PageableEditorKit extends RTFEditorKit {
        PageableViewFactory factory = new PageableViewFactory();
        private JTextPane editor = null;    //  w = 72 * 8.5 = 612    (inch = 72 )
        public static int DRAW_PAGE_INSET_TOP = 20;
        public static int DRAW_PAGE_INSET_LEFT = 10;    //public static int DRAW_PAGE_INSET_TOP = 0;
        protected int pageWidth = 730;
        protected int pageHeight = 940;
        public static String PAGE_BREAK_ATTR_NAME = "page_break_attribute";
        protected Insets pageMargins = new Insets(100, 125, 100, 125); //protected Insets pageMargins = new Insets(0, 0, 0,0);
        protected JTextPane header;
        protected JTextPane footer;
        public boolean isChangeSize = false;
        private boolean isValidHF;
        public static int HF_SHIFT = 3;
        boolean isPageBreakInsertion = false;
        public boolean isHeaderFooter = false;
        public final PaginationPrinter pp; // = new PaginationPrinter(pf, editor);
        protected float headerOrjHeight = 22;
        protected float headerOrjWidth = 100;
        protected float footerOrjHeight = 22;
        protected float footerOrjWidth = 100;
        public boolean refresh = false;
        protected Rectangle edtGorunenAlan;
        public int actifPage = 0;
        protected int hfTiklananPage = 0;
        DocumentListener relayoutListener = new DocumentListener() {
            public void insertUpdate(DocumentEvent e) {
                relayout();
            public void removeUpdate(DocumentEvent e) {
                relayout();
    ....

    when I wrote this code:
    TableEditorKit  ourKit = (TableEditorKit) m_monitor.getEditorKit();I am taking error bellow.
    Exception in thread "AWT-EventQueue-1" java.lang.ClassCastException: editor.page.PageableEditorKit cannot be cast to editor.page.TableEditorKit
            at editor.Editor.mnTabloEkleActionPerformed(Editor.java:2014)
            at editor.Editor.access$5200(Editor.java:122)
            at editor.Editor$51.actionPerformed(Editor.java:1038)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
            at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1170)
            at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1211)
            at java.awt.Component.processMouseEvent(Component.java:6038)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
            at java.awt.Component.processEvent(Component.java:5803)
            at java.awt.Container.processEvent(Container.java:2058)
            at java.awt.Component.dispatchEventImpl(Component.java:4410)
            at java.awt.Container.dispatchEventImpl(Container.java:2116)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
            at java.awt.Container.dispatchEventImpl(Container.java:2102)
            at java.awt.Component.dispatchEvent(Component.java:4240)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)Edited by: selcukyapici on Jun 21, 2009 11:33 PM

  • Parameter.Value proper cast with c# oracle number to c# int??

    Hello,
    I'm trying to get a return value from an Oracle stored function using C# and odp.net.
    The function basically looks like:
    function f( id in number ) return number
    is
    id_new number := null;
    begin
    select sequenct_name.nextval
    into id_new
    from dual;
    -- do some stuff
    return id_new;
    end;
    The C# call basically looks like
    cmd.Parameters.Clear();
         cmd.CommandText = "f";
         cmd.CommandType = CommandType.StoredProcedure;
         // set up return variable
         ret = cmd.Parameters.Add( "id_new",     // name
              OracleDbType.Decimal );          // type
         ret.Direction = ParameterDirection.ReturnValue;
         // pass in original id
         cmd.Parameters.Add( "id",      // name
              OracleDbType.Decimal,     // type
              id,               // value
              ParameterDirection.Input ); // direction
         cmd.ExecuteNonQuery();
         if ( ret.Value != null ){
    //          ai_id_new = (int) ret.Value;
    //          ai_id_new = (OracleDbType.Decimal ret.Value;
    //          ai_id_new = (int)(decimal) ret.Value;
    //          ai_id_new_d = (decimal) ret.Value;
    //          ai_id_new = (int)(Int32) ret.Value;
    //          ai_id_new = (Int32) ret.Value;
              ai_id_new = int.Parse(ret.Value.ToString());
    You can see all of the casts that I had to comment out. The last line works, but I don't like it:
    ai_id_new = int.Parse(ret.Value.ToString());
    Does anyone know what the proper cast is for the ret.Value Object?? to get it assigned back to a C# int?
    Thanks,
    David

    figured it out
    have to do this in c# file
    int ai_new_id;
    OracleDecimal ora_dec;
    ora_dec = (OracleDecimal) ret.value;
    ai_new_id = ora_dec.ToInt32();

  • Type casting with dblink?

    Hi!
    I want to use an functions result for both a call to local procedure and an remote procedure.
    When I want to call an remote procedure, I must declare the (return)variable and return-signature
    as "remote type", e.g. using @dblinkname
    the function i write is of general purpose so I want to deploy it on local and remote site. I could deploy it locally using ...@dblinkname and remote without.
    But I would like to use on version of the same code and not two, so I tried this:
    codelines dbms_sql.varchar2s@DL_PROD.WORLD;
    codelinesl dbms_sql.varchar2s;
    codelinesl := f();
    codelines := cast (codelines as dbms_sql.varchar2s@DL_PROD.WORLD);
    and got pls-00220

    the function i write is of general purpose so I want
    to deploy it on local and remote site. I could deploy
    it locally using ...@dblinkname and remote without.
    But I would like to use on version of the same code
    and not two,Why would the use of the function in the above example result into two versions?

  • Can I do dynamic class cast with java SE1.4.2?

    Hi,
    I have some question on dynamic class cast.
    I'm using java SE1.4.2. Suppose I have a method :
    castObjectToSomething(Object o)
    Something s = (Something) o;
    However, I don't know what is the class to cast until runtime. How can I do a runtime class cast?
    I know that java 5.0 have a Class.cast() method which java1.4.2 does not have. But can I do the same stuff by using SE1.4.2?
    Thank You!!!!!
    oh_silly

    There is no sense in wanting to cast to a class that is only known at runtime. Because you can't do anything with such a class during runtime. Even though you could technically retrieve the class name, the method names and the parameter names, you could do nothing with this class as you don't know what it is doing. If you would know what it can do, you would know it also during compile time and then you would know the classname/interface name you want to cast to and can import it and use it reasonably.
    Tell us the requirement that you think you have and we will proof you that you don't need such a requirement.

  • Having problem of cast with OrdDoc

    hi all
    i have some problem with cast of OrdDoc
    it is running very well but now it creats some problem for me here is statement
    doc = (OrdDoc)rset.getCustomDatum(6,OrdDoc.getFactory());
    and the exception also given below
    java.lang.ClassCastException: oracle.sql.CHAR
         at oracle.ord.im.OrdDoc.create(OrdDoc.java:1288)
         at oracle.jdbc.driver.OracleStatement.getCustomDatumValue(OracleStatement.java:5233)
         at oracle.jdbc.driver.OracleResultSetImpl.getCustomDatum(OracleResultSetImpl.java:518)
         at docSave.fetch(docSave.java:78)
         at demo.sample._doc._jspService(_doc.java, Compiled Code)
         at oracle.jsp.runtime.HttpJsp.service(HttpJsp.java)
         at oracle.jsp.app.JspApplication.dispatchRequest(JspApplication.java)
         at oracle.jsp.JspServlet.doDispatch(JspServlet.java)
         at oracle.jsp.JspServlet.internalService(JspServlet.java, Compiled Code)
         at oracle.jsp.JspServlet.service(JspServlet.java)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at org.apache.jserv.JServConnection.processRequest(JServConnection.java:314)
         at org.apache.jserv.JServConnection.run(JServConnection.java:188)
         at java.lang.Thread.run(Thread.java:479)
    plz read it and give me some suggestions
    thanx in advance

    What is your classpath?

  • Color cast with Huey Pro

    I am using a Huey Pro to calibrate my monitors for use with Aperture. After calibration both my MacBook Pro and iMac have a very red color cast.
    Thanks,
    Ken

    have you tried reporting this on the pantone support site - if you do a search there, you'll find a couple of problems mentioning the same thing your seeing.
    I have the same problem and it could be a broken calibrator.

  • Red / brown color cast with Pantone Huey

    Hi all
    I may have made a breakthrough in trying to figure out why my prints don't look like what's on the screen despite calibrating my monitor, downloading the lab's icc files, softproofing, etc.
    I believe my Huey Pantone (the cheaper version, not the Pro) is creating a reddish/brownish color cast after calibration.
    It became very apparent when I set my background to light gray and turned the Huey to "uncorrected". I checked the Pantone website and there seem to be known issues for this. I guess they'll send me a new device (tech support was backed up so I didn't get through).
    A couple of questions:
    1. For others that use Huey, how do you do your calibration? What do you set brightness too? Room lights on or off? Got any color casts, or is it clean? BTW, I have the dreaded left to right gradient, do you think that's affecting things?
    2. If you've got a good monitor profile, would you consider emailing it to me, just so I could play around with it and compare to my calibrated setting?
    Thanks!

    have you tried reporting this on the pantone support site - if you do a search there, you'll find a couple of problems mentioning the same thing your seeing.
    I have the same problem and it could be a broken calibrator.

  • Type cast with String representation

    I have a hashtable full of Objects along with a String representation of their type. Is it possible to cast an Object back using a String representation of its type. ie
    String str = "helpme";
    String type = "String";
    str = (Object)str;
    now I want to get str back to String type but with using the variable type.

    Do not crosspost: http://forum.java.sun.com/thread.jsp?thread=355714&forum=4&message=1482427

  • Information Broad casting with bursting option.

    Dear Experts,
    I have one query which is being broadcasted out using bursting option. Now
    I want to make one variable mandatory with no default values. Could I do
    that?
    Could any one through some light on this.
    Thanks

    Hi Gurus,
    I tried to create variant by following the below link.But here i'm unable to get variant Attributes. Could any one did this. If Yes kindly throw some light on this as its a priority issue for me.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9075b11a-6e43-2c10-b7be-cfa0e97ec0cc?quicklink=index&overridelayout=true.
    Any other solutions are also welcome.
    Here my problem is i have a query with some variables. I need to broadcast this query. here current fiscal period and current date is getting sysdate  by using i_step1. I saved this values as a variant and  used this variant in Broadcasting. when ever i execute the broacast i need to get system date ( Ie Current date) but here its not getting like that. its getting the variant saved date.
    I dont want this my dates should be dynamic.
    Did any one solved similar kind of problem.Any suggestions?
    Thanks

  • TYPE casting with SQL Server 2005

    Hi,
    I recently migrated to SQL Server 2005 database from Oracle 10g. I used the %TYPE operator in Oracle to cast to the appropriate column data type.
    PROCEDURE INS_USER
                   i_USERNAME               IN USERS.USERNAME%TYPE,
                   i_PASSWORD               IN USERS.PASSWORD%TYPE,
    IS BEGIN
    How can I do this in SQL Server 2005? Is there any similar operator to %TYPE in SQL Server??

    i don't know !
    you can try a SQL server forum.

  • Blue cast with connected cameras

    When ever I use either my internal iSight camera OR a Firewire connected camera as a webcam I get a blue monochrome image. Using the iSight for one of the iLife apps it works fine. I have posted here because I'm under the impression that it is Quicktime that configures cameras in the Mac OS, but I can find no way of altering the way QT is intergrating with websites and controlling the video. I can move the same Firewire camera to my G4 laptop running the same OS (10.4.8) and have no problems on the same website, so it is a problem with the Intel based iMac somewhere.
    Intel iMac 24"   Mac OS X (10.4.8)  

    Thanks for the suggestion, but I don't believe it to be an iSight issue as the problem occurs with ANY camera hooked to that computer and used as a webcam. The same caneras work fine on another computer.

  • Type cast with string name

    I have a hashtable full of Objects. I also have there type represented by a String. How can I typecast these Objects back to there type. i.e.
    String str = "helpme";
    str = (Object)str;
    String type = "String";
    can I use the var type to cast str back to a String;

    I've never used reflection before so my answer maybe way off from what you're looking for.... but to solve your problem on casting an Object to a type specified by a String variable you could use a case or if statement if you know what types are available ahead of time and call the appropriate methods to return your Object type.
    For example... You could create a method for each type you expect to return.
    public String getStringValue( Object obj ) {
         return (String)obj;
    public Integer getIntegerValue( Object obj ) {
         return (Integer)obj;
    public Byte getByteValue( Object obj ) {
         return (Byte)obj;
    }Then... depending on what the value of your String type variable is you can call the appropriate method that will return the Object type you're wanting.
    String type = "String";
    if( type.equals("String") )
         String yourStr = getStringValue(yourObject);
    else if( type.equals("Integer") )
         Integer yourInt = getIntegerValue(yourObject);
    else if( type.equals("Byte") )
         Byte yourByte = getByteValue(yourObject);This maybe not be the most efficient way especially since there can be potential errors but it can work assuming the String type is really representing the type of Object yourObject is.
    I don't know.. just a possible solution that popped in my head.
    .kim

  • Casting with a Object reference

    Object tObject;
    tObject = new Date(2000,12,25); //tObject is pointing to a new Date object
    Date tDate = (Date)tObject; // tObject is being cast to a date object, so does it mean that tObject and tDate are pointing at the same Date object
    int tYear = tDate.getYear();
    any help would be great

    Exactly. This won't work:Object anObject = new Object();
    (JPanel) anObject.setLayout(new BorderLayout()); // Wrong!!!!!because casting doesn't create inheritance; it simply informs the compiler of an inheritance (through definition) that should already be there. If it isn't, the compiler won't know about it, but you will get an exception when you try to run it.
    This, however, will work:Object anObject = new JPanel();
    (JPanel) anObject.setLayout(new BorderLayout()); // Right!!!!!because the inheritance you are specifying is really there.
    When you cast, you are in effect telling the compiler something like "this animal is an elephant". The compiler will say "OK, I believe you", but if what you have is really a tiger, prepare to be mauled instead of being given a ride.

Maybe you are looking for

  • Multiple Problems

    Hey! I got some problems here.. 1. xmodmap: i just can get my 6 button mouse (logitech mouseman dual optical) work (6th button on xev says button 8) through manually executing $ xmodmap -e "pointer = 1 2 3 4 5 7 8 6 9 10" if i try to use the ButtonMa

  • DML with sqlj in app.module

    I do DML with the help of stored pl/sql procedures (in packages), and I'm building a bc4j application. I do custom doDML methods for the entities, and I would like to get use of the generated sqlj wrapper classes for my stored packages. Is this possi

  • SQL server plugin - cluster?

    Ive previously installed a sql server plugin for 11g grid control. works great. Is there a how-to or a suppoprt note on installing for 2008 SQL server cluster? cant seem to find. In the install guide on the download link for the plugin, the versions

  • How do i delete photos stored in my itunes library

    I can not sync my new iphone5 because there is not enough space in my itunes library.  How do i remove photos store in my itunes library? 

  • Internet connection problem after migrating from Powerbook G4

    After starting up my friend's new Macbook 2ghz for the first time, I migrated everything from his old Powerbook G4. However on starting the machine for the first time, although the Internet Status suggested his Airport connection to his Netgear route