Dynamically determining the number of cols in Select stmt

Hi,
I was wondering if it is possible to dynamically determine the number of cols in Select stmt.
For example:
If it had:
Select empno, lname from emp where empno = 32
then I'd like it to return 2.
Thanks in advance.
Sincerely,
Nikhil Kulkarni

Hi,
I was wondering if it is possible to dynamically determine the number of cols in Select stmt.
For example:
If it had:
Select empno, lname from emp where empno = 32
then I'd like it to return 2.
Thanks in advance.
Sincerely,
Nikhil Kulkarni

Similar Messages

  • Is there a way to dynamically determine the number of out parameters for a server side procedure?

    Hi,
    Below is a helper method used for calling a server-side function which loops through the inbound bindVars parameter to populate the function's IN parameters. Is there a way to dynamically determine the IN/OUT parameters based on the procedure name in the stmt parameter? No members of the CallableStatement class seemed promising, but the getParameterMetaData() method in the PreparedStatement class seemed like it could be helpful lead. However, I have not found any detailed descriptions (yet) of how to use it.
    protected Object callStoredFunction(int sqlReturnType, String stmt,
      Object[] bindVars) {
      CallableStatement st = null;
      try {
      // 1. Create a JDBC CallabledStatement 
      st = getDBTransaction().createCallableStatement(
      "begin ? := "+stmt+";end;",0);
      // 2. Register the first bind variable for the return value
      st.registerOutParameter(1, sqlReturnType);
      if (bindVars != null) {
      // 3. Loop over values for the bind variables passed in, if any
      for (int z = 0; z < bindVars.length; z++) {
      // 4. Set the value of user-supplied bind vars in the stmt
      st.setObject(z + 2, bindVars[z]);
      // 5. Set the value of user-supplied bind vars in the stmt
      st.executeUpdate();
      // 6. Return the value of the first bind variable
      return st.getObject(1);
      catch (SQLException e) {
      throw new JboException(e);
      finally {
      if (st != null) {
      try {
      // 7. Close the statement
      st.close();
      catch (SQLException e) {}
    James

    The PreparedStatement.getParameterMetaData() object is exactly what you need for this task.
    Once you have the ParameterMetaData you can ask it how many parameters are present and which mode they are. The parameters are numbered from 1 to n and you can use ParameterMetaData.getParameterMode(1); to get the mode of the 1st parameter. The modes are defined as static values in the ParameterMetaData object. Check out the doc at http://docs.oracle.com/javase/7/docs/api/java/sql/ParameterMetaData.html
    Timo

  • Dynamically determining the port number of a deployed application

              Hi
              How do I dynamically determine the port number of a deployed web application ?
              I know HttpRequest.RequestURL() returns us the entire URL but I wanted to just
              know the port number .
              Is there any API do that ??
              Thanks
              Kar
              

    kar piyush wrote:
              > Hi
              >
              > How do I dynamically determine the port number of a deployed web application ?
              > I know HttpRequest.RequestURL() returns us the entire URL but I wanted to just
              > know the port number .
              >
              > Is there any API do that ??
              >
              kar,
              Here's what I do under WL 7 SP2:
              import javax.management.AttributeNotFoundException;
              import javax.management.DynamicMBean;
              import javax.management.MBeanException;
              import javax.management.ReflectionException;
              import javax.naming.Context;
              import javax.naming.NamingException;
              import weblogic.jndi.Environment;
              import weblogic.management.MBeanHome;
              String domainName,
              serverName,
              serverPort,
              serverUrl;
              // Getting the initial context
              Environment env = new Environment();
              try
              Context ctx = env.getInitialContext();
              if (ctx == null)
              // unable to retrieve a JNDI context
              return;
              // Retrieving the server-specific MBeanHome interface
              MBeanHome home =
              (MBeanHome) ctx.lookup(MBeanHome.LOCAL_JNDI_NAME);
              if (home == null)
              // unable to retrieve the local server MBean
              return;
              // Get the domain & server name
              domainName = home.getDomainName();
              serverName = home.getMBeanServer().getServerName();
              // The server port and address are a little trickier to extract...
              Object mbeanArray[] =
              home.getMBeansByType("ServerConfig").toArray();
              DynamicMBean mbean = (DynamicMBean) mbeanArray[0];
              try
              serverPort =
              Integer.parseInt(
              mbean.getAttribute("ListenPort").toString());
              serverUrl =
              mbean.getAttribute("ListenAddress").toString();
              catch (AttributeNotFoundException thrown)
              // caught a AttributeNotFoundException
              catch (MBeanException thrown)
              // caught a MBeanException
              catch (NullPointerException thrown)
              // caught a NullPointerException
              catch (ReflectionException thrown)
              // caught a ReflectionException
              catch (NamingException thrown)
              log.debug("caught a NamingException", thrown);
              

  • How to determine the number of pixels of a desired object within a digital photograph?

    Hi everyone. I want to determine the number of pixels in an object that is part of a digital photo. I use cameras to film chunks of ice breaking away from ice cliffs or tidewater glaciers. I want to know the size of the ice chunk that my digital photographs capture. I know the width and height of the ice cliff in metres already, so I was thinking that I could convert the equivalent of 1 pixel : ? metres - this is really what I want to do. That way every time I see a chunk of ice breaking off, I can pull up the photo, outline the chunk, calculate how many pixels fill the area of ice removed by the chunk breaking off and convert to metres area 2 - thus giving me my size order. If anyone has ideas on how to do this I would really appreciate it, thanks so much community. I was thinking that Photoshop or Fireworks could help me with this, Ricky

    Thanks gener7 and normfb.
    The Photoshop help measurement page is brilliant and I think I can use the info on that page to work out my iceberg sizes. Check out the attached photo - you are looking at an ice cliff - essentially the front of a tidewater glacier that flows in the ocean. I'm a research student and I look at the process of iceberg calving - this is the term we use to define the sudden breaking away or detachment of ice chunks from glaciers that end in the sea.
    I used the lasso tool to crop the area of ice lost as a single chunk of ice detached from the ice cliff. At the same time I had the histogram window open. The histogram showed me how many pixels were contained in the cropped area. What I need to do now is work out what 1 pixel is equivalent to in metres. Soon I will have a digital elevation model for the ice cliff that will offer centimetre to metre scale resolution of the surface topography - so that should really help. The photographs I have are taken every 30 seconds - which is brilliant for documenting how the geometry of the ice cliff adjusts in response to detaching ice pieces and also because the ice is moving. I am a research student in Canada, and at the time I took the photos we measured that the ice cliff was advancing at a rate of approximately 12 metres per day! That's pretty fast. The flow of the ice is a first order control on the rate of iceberg production - you are essentially pushing ice into the ocean where it breaks off. I'm having to learn everything Photoshop from scratch...so please bare with me because maybe some of the photoshop questions I ask are simple to most!
    I noticed the "integrated density" function on the help sheet you suggested. This function also provides the square number of pixels contained in the cropped area I select...I guess this is similar to the histogram right?
    Either way - i just need the scale conversion to go from 1 pixel : metres or cm equivalent. At that point I think I will have to manually select every single iceberg event from my time-lapse photos and do this the manual way!  I have about 800 events to manually digitise and calculate the area for...
    Thanks everyone, Ricky

  • How to determine the number of messages in a queue, that ...

    Hi,
    what's the proper way to count the number of the messages in an Advanced Queue that are currently visible to consumers?
    Currently we use:
    select count(*) from aq$queue_tab_name q where q.QUEUE = 'Q_NAME';
    The problem with that approach:
    If one consumer dequeues a lot of messages in one transaction, that change in the number of messages visible to other consumers is only made visible after the consumer issues a commit. Before the commit is issued, the above "select count(*) ..." statement (issued from a different DB-session) does not reflect the fact that one consumer consumed a lot of messages, messages that are not available to other consumers anymore (only exception: the original consumer issues a rollback sooner or later).
    So before the commit is issued:
    -the consumed messages are NOT visible to other consumers anymore (which is intended behaviour)
    -but the "select count(*) ..." statement (issued from a different DB session) does NOT reflect that fact
    So the case could arise that the queue becomes empty, while "select count(*) ..." says that e.g. 1000 messages are still in the queue.
    Is there a solution to this problem?
    PS: For our use-case we need these dequeue option :
    dbms_aq.remove;
    dbms_aq.first_message;
    dbms_aq.on_commit;
    Again, the queue itself works correctly, I just need to find a way to determine the number messages that are currently dequeable / visible to the consumers at specific point in time.
    I couldn't find a func/proc in dbms_aq for that purpose.
    Best wishes
    Peter

    The following might be of interest in better understanding the issue you are facing in a broader context:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5771117722373

  • How do I determine the number of plots on a waveform graph?

    How do I determine the number of plots that have previously been plotted on a waveform graph? I am loading dynamic data from a file. If I convert to an array and size it and there is only one plot, I get the number of data points and I don't know how to tell the difference.

    Usually by reading the graph terminal or a local of it and determining the first or second dimension (not sure which at the moment) size of the resulting 2 dimensional array. If it is a 1 dimensional array you have either only one plot or an array of clusters each representing one plot. But as these data types are determined by compile time, there shouldn't be a problem with this causing ambiguity.
    Rolf K
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Determine  the number of periods on 0FISCPER3

    I have a problem concerning the design of a query. The aim of the query is firstly to get rid of variable periodic variations of specific volume data and secondly to compare this data with the same number of periods of the previous year.
    Therefore I inserted the following columns and help columns:
    S1: key figure volume ; variables: business year (0FISCYEAR) ; periods (=FISCPER3; from - to)
    S2: key figure volume; variable offset  of  business year (-1)
    S3: formula: S2/12 (therefore mean value of the previous business year)
    S4: (formula variable to determine  the number of periods) S3 * number of periods  (formula variable)
    Actually the formula variable (attribute 0FISCPER3, substitute path, figure) picks up the variable 0FISCPER3 twice: the value from and to. A calculation of the difference within the formula variable did not work.
    Now it is not possible for Business Warehouse to carry out the replacement of the figure.
    <i>Message
    However, these are not the same for all formula components , or the selection is not available in the terms. Another possibility is that the variable cannot be consistently replaced by “from” or “to”</i>
    Can you tell me which mistake I made  respectively how to construct this query!
    Thank you very much in advance.

    Hi,
    the best is to go with a varexit.
    Assuming your var on 0FISCPER3 is name VPER3.
    Create a fromula variable not ready for input processed by user exit: VNPER.
    Here's the ABAP:
    DATA:
        l_poper_from LIKE T009C-POPER,
        l_poper_to LIKE T009C-POPER,   
        l_nper TYPE I.
      WHEN 'VNPER'.
        IF i_step = 2.
          LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'VPER3'.
            CLEAR l_s_range.
            MOVE loc_var_range-low TO l_poper_from.
            MOVE loc_var_range-high TO l_poper_to.   
            l_nper = l_poper_to - l_poper_from + 1.   
            l_s_range-low      = l_nper.
            l_s_range-sign     = 'I'.
            l_s_range-opt      = 'EQ'.
            APPEND l_s_range TO e_t_range.
            EXIT.
          ENDLOOP.
        ENDIF.
    please note that the code may be adjusted.
    Use then your form varexit in your columns calculations.
    hope this helps...
    Olivier.
    Message was edited by:
            Olivier Cora

  • Run a query that will determine the number of parts to produce

    I have the task that I have to determine the number of parts that need to be produced based on the number of products sold for the day (each product consists of many parts).
    I am using SQL 11g Express.
    I have stared at this for so long and tried so many different ways. Below are a few of what I have tried, with the error messages. I'm not sure where I'm going wrong to get this calculation. Any help here is greatly appreciated!
    Here's my info:
    /**PRODUCT**/
    CREATE table Product
        SKU       VARCHAR2(10) NOT NULL,
        ProdDesc   VARCHAR2(50) NOT NULL,
        Price      NUMBER(5,2),
        PRIMARY KEY(SKU)
    /**PART**/
    CREATE table Part
        PartID     NUMBER(6) NOT NULL,
        PartDesc   VARCHAR2(50) NOT NULL,
        PRIMARY KEY(PartID)
    /**PRODUCTPART**/
    CREATE table ProductPart
        SKU        VARCHAR2(10) NOT NULL CONSTRAINT fk_ProductPart_Product REFERENCES Product (SKU),
        PartID     NUMBER(6) NOT NULL CONSTRAINT fk_ProductPart_Part REFERENCES Part (PartID),
        NumOfParts NUMBER(3),
        CONSTRAINT pk_ProductPart PRIMARY KEY (SKU, PartID)
    CREATE table Customer
        CustID     NUMBER(6) NOT NULL,
        CustFname  VARCHAR2(20) NOT NULL,
        CustLname  VARCHAR2(20) NOT NULL,
        Company    VARCHAR2(40),
        Address    VARCHAR2(40) NOT NULL,
        City       VARCHAR2(30)NOT NULL,
        State      VARCHAR2(2)NOT NULL,
        Zip        NUMBER(5)NOT NULL,
        Phone      NUMBER(10)NOT NULL,
        PRIMARY KEY (CustID)
    CREATE table CustOrder
        OrderID    NUMBER(6) NOT NULL,
        Qty        NUMBER(3) NOT NULL,
        OrderDate  Date NOT NULL,
        SKU        VARCHAR(10) NOT NULL CONSTRAINT fk_CustOrder_Product REFERENCES Product (SKU),
        CustID     Number(6) NOT NULL CONSTRAINT fk_CustOrder_Customer REFERENCES Customer (CustID),
        PRIMARY KEY (OrderID)
    Here are some of the queries:
    SELECT ProductPart.Qty
    SELECT CustOrder.SKU,
    sum(CustOrder.qty)
    FROM CustOrder
        GROUP BY CustOrder.SKU;)
    FROM ProductPart
    WHERE ProductPart.Qty * sum(CustOrder.Qty)
    ORA-00936: missing expression
    SELECT o.OrderDate AS "Date Ordered",
           o.OrderDate + 5 AS "Date Due",
           pp.PartID AS "Part No.",
        pp.NumOfParts * COUNT(o.SKU) AS "Qty"
    FROM CustOrder o
    JOIN ProductPart pp
      ON o.SKU = pp.SKU
        GROUP BY pp.PartID, o.OrderDate, COUNT(o.SKU)
    ORDER BY o.OrderDate
    ORA-00934: group function is not allowed here
    SELECT ProductPart.Qty,
           ProductPart.PartID,
           ProductPart.PartDesc
    (SELECT COUNT(CustOrder.SKU)
    FROM CustOrder
    GROUP BY CustomerOrder.SKU)TotalProducts,
    ProductPart.Qty * TotalProducts AS "Qty"
    FROM ProductParty
    WHERE CustOrder.SKU = Product.SKU
    AND Product.SKU = ProductPart.SKU
    ORA-00936: missing expression
    SELECT ProductPart.Qty,
           ProductPart.PartID,
           ProductPart.PartDesc
    (SELECT sum(CustOrder.qty)
    FROM CustOrder
    GROUP BY CustOrder.SKU)TotalProducts
        ProductPart.Qty * TotalProducts
        FROM ProductPart
    ORA-00936: missing expression

    Hi,
    893443 wrote:
    ... CREATE table CustOrder
    OrderID NUMBER(6) NOT NULL,
    Qty NUMBER(3) NOT NULL,
    OrderDate Date NOT NULL,
    SKU VARCHAR(10) NOT NULL CONSTRAINT fk_CustOrder_Product REFERENCES Product (SKU),
    CustID Number(6) NOT NULL CONSTRAINT fk_CustOrder_Customer REFERENCES Customer (CustID),
    PRIMARY KEY (OrderID)
    INSERT INTO CustOrder(OrderID, Qty, OrderDate, SKU, CustID)
    VALUES(2101, 2, '10-26-2011', 'DVCK1212', 1101);You're still trying to put a VARCHAR2 into a DATE column. Depending on your NLS settings, that may work on your system (at least today), but it definiely doesn't work on mine.
    Don't use a VARCHAR2 where a DATE is expected. Use TO_DATE to convert a string into a DATE:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/functions203.htm#sthref1662
    Ideally The report would look something like this:Why not like this?
    ORDERDATE      PARTID PARTDESC                        TOTAL_QTY
    10-24-2011       1003 12" X 24" Ventilated Shelf             42
    10-24-2011       2001 12" X 12" Solid Shelf                 108
    10-24-2011       3001 12" X 96" Side Panel                   50
    10-25-2011       1004 12" X 30" Ventilated Shelf             72
    10-25-2011       2001 12" X 12" Solid Shelf                  54
    10-25-2011       2002 12" X 18" Solid Shelf                   6
    10-25-2011       3001 12" X 96" Side Panel                   44
    10-26-2011       1001 12" X 12" Ventilated Shelf             42
    10-26-2011       1004 12" X 30" Ventilated Shelf              6
    10-26-2011       2003 12" X 24" Solid Shelf                  12
    10-26-2011       3001 12" X 96" Side Panel                   20Did you make some mistakes in your results? If not, explain how to get the correct results in the places where the ouput above is wrong. For example, how do you get the row for orderdate of Oct 26 and partid=2001?
    {OrderDate    PartID    PartDesc NumOfParts(Total for that day)
    10-24-2011    2001    12" X 12" Solid Shelf 108
    10-24-2011    2003    12" X 24" Solid Shelf 32
    10-24-2011    3001    96" Side Panel 50
    10-25-2011    2002    12" X 18" Solid Shelf 6
    10-25-2011    2001    12" X 12" Solid Shelf 54
    10-25-2011    1004    12" X 30" Ventilated Shelf 72
    10-25-2011    3001    96" Side Panel 44
    10-26-2011    2001    12" X 12" Solid Shelf 12
    10-26-2011    2004    12" X 30" Solid Shelf 6
    10-26-2011    2003    12" X 24" Solid Shelf 12
    10-26-2011    1001    12" X 12" Ventilated Shelf 30
    10-26-2011    3011    96" Side Panel 20}Use \ tags, as described in my last message, before and after formatted text, to preserve spacing.
    My issue is, I can't get the equation right to produce the total number of parts. I think I need to multiply ProductPart.NumOfParts by SUM(CustOrder.Qty) Group by CustOrder.SKU.More likely that you need to multiply numofparts * qty, and then take the SUM of the result.
    Why would you GROUP BY sku?  Does each row of output represent a different product (and therefore a different sku), or does each row of output represent a different part. regardless of which product(s) that part is related to?
    If you want a separate total for each orderdate, you'll have to include orderdate in the GROUP BY clause, too.
    To get partdesc in the output, you'll either need to include partdesc in the GROUP BY clause, or wrap it in an aggregate fucntion.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to determine the number of rows to be displayed in a report

    hello experts,
    Has anyone ever come across this requirement before? Before a report finishes being executed and before it displays the results, is there a way to determine the number of rows to be displayed as the result?
    Many thanks in advance.
    Regards,
    Inma

    Hello Arun,
    Thanks for your reply but do you know which method I should use for this purpose if I use the table interface?
    Thanks,
    Inma

  • Function Module to determine the number of pages in a pdf file

    Hi All,
    Is there any standard function module to determine the number of pages in a pdf file?
    Thanks,
    Sai

    Hi unk2,
    There's no functionality in the Acrobat.com online services to do a character count. But, you could use ExportPDF to convert your PDF file to Word format, and then do your character count in Word.
    Please let us know if you need additional assistance.
    Best,
    Sara

  • Determine the number of lines of textfield or floating field

    Hi,
    Is there a way to determine the number of lines of text in a textfield or in a floatingfield.
    My problem is that I'm creating a form with three tables(made of subforms) underneed each other that needs to be set to hidden when the total of rows is greater than 25.
    Now it would be easy to just count the rows but these rows can exist of multiple lines of text.
    The fields of my row are floating fields so when the text is bigger than the displayable width the text continous on a new line in the same row. So I need to know when this happens because now I can show only 24 rows.
    I tried counting the characters but this doesn't work, when there are a lot of 'i,j,l' or other small characters I can place 40 characters in my textfield, but when there are a lot of 'm,w' characters I can place only 22 characters in my field.
    I also tried to use xfa.layout.h(TextField1,"cm") to determine the height of the field, but it always retuns the value -1. I get the same -1 with the y or x - position.
    Does anybody have an idea how to solve this problem?
    Thanks in advance,
    RonnyR

    oops ... i got it thanks.
    code below -----
    for(var i=0; i <= s.length-1; i++)
    sCurrentLetter = s.substring(i,i+1);
    if (s.charCodeAt(i) == 13)
    // this is a line break

  • How can I determine the number and resolution of the current displays/screens?

    I am developing a vision application that will require a specific window size, thus the application must run with the screen resolution at predified levels. It is also possible that the application will run on a system with multiple monitors, so I need to be able to determine the number of monitors, and the resolution of each.

    Hi
    I recommend you to work with the VI Server functions (Application class properties). See my little example.
    Regards,
    Luca
    Attachments:
    VI_Server.vi ‏22 KB

  • How can I determine the number and sizes of redologs?

    Dear all,
    How can I determine the number and sizes of redologs are sufficient to allow redo log switching while hot backup is in progress?
    Please advice,
    Amy

    Two questions here - what the OP put as the subject title and what was asked in the thread, which are different questions.
    I would interpret the question in the thread to mean "how to avoid hanging due to archiving waiting for a redo log group to become available." Alert log, wait events, and user complaints would be the source of information here.

  • Determining the number of elements defined in an enum

    Hello,
    I have an enum and I want to determine the number of elements (constants) defined in this enum by source code. I know I can use reflection but I just want to know if there's an easier way.
    Thank you very much.

    Hey JavaWisdom,
    You can use the ordinal method. I made a simple example to demonstrate.
    public class NumberOfEnums {
         public static enum Enumeration {
              item1, item2, item3, item4
         public void count() {
              Enumeration[] values = Enumeration.values();
              int numElems = 0;
              for (Enumeration type : values) {
                   if (type.ordinal() > numElems) {
                        numElems = type.ordinal();
              // Correct 0 indexed numbering
              numElems += 1;
              System.out.println("numElems : " + numElems);
         public static void main(String args[]) {
              NumberOfEnums noe = new NumberOfEnums();
              noe.count();
    }Cheers,
    Cypher

  • Dynamically modifying the number of Form detail rows

    Hi,
    A challenge for you all!
    I am building a product details system in Portal forms.
    One of the screens is a Product Ingredients form with Product as the master block and ingredients as the Detail block. There can be between 1 and 20 ingredients in any 1 product and as these all have to sum to a volume percentage of 100% the client would like to see all ingredients for a product on 1 screen and not have to do Next/Previous to see them all.
    As you increase detail rows on a master detail form the performance of the form decreases dramatically so I would like to minimise the number of detail rows displayed for each product to maximise performance.
    To this end I wish to dynamically modify the number of detail rows displayed to match the number of ingredients on a product as that product is queried.
    I can handle figuring out how many rows I want to set the page to but have not been able to figure out how to change the number of detail rows displayed at run time.
    Anyone know how (or if!) this is possible ?
    All help gratefully recieved
    Andy

    The rownum pseudo-column hold the number of the row but it doesn't work like you expect. It is assigned before sorting for example and it is not absolute. SQL conceptually deals with sets and sets have no inherent order. See http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
    If you want to have an absolute number in a row you will need to maintain it yourself with PLSQL code.

Maybe you are looking for