Pivot function problem

Hi all,
In pivot function "in" clause i want to use sql query, because i want to take values dynamically from the table.
How can i use, is there any solution for that.
Pls help me.
mani

Here's what I was thinking:
SQL> DECLARE
  2   yrno NUMBER;
  3   x    VARCHAR2(100) := '''direct'' AS Store, ''online'' AS Internet';
  4  BEGIN
  5    SELECT year
  6    INTO yrno
  7    FROM
  8    (SELECT EXTRACT(YEAR FROM order_date) year, order_mode, order_total FROM orders)
  9    PIVOT
10    (SUM(order_total) FOR order_mode IN (x))
11    WHERE rownum = 1;
12 
13    dbms_output.put_line(yrno);
14  END;
15  /
  (SUM(order_total) FOR order_mode IN (x))
ERROR at line 10:
ORA-06550: line 10, column 40:
PL/SQL: ORA-56901: non-constant expression is not allowed for pivot|unpivot values
ORA-06550: line 5, column 3:
PL/SQL: SQL Statement ignoredWith the value of "x" easily created dynamically. Now all I can say is:
Ouch ... I've been taken out to the woodshed and beaten.
I am sending in an enhancement request for version 12.
If you agree that this is something we need please log onto metalink and do so too. Thank you.

Similar Messages

  • Pivot function in Oracle 10g???

    Hello everybody,
    at the beginning of the week I had a simple problem (I thought that...), but now after trying and trying, I can't find a solution for it. First of all I'm working on Oracle 10g with the version 10.2.0.4.0. I can't change the version, it's standard in the whole company...
    At the beginning I have a table like the following one, but please note, that the compartment, the type and the amount are flexible and can change at any time:
    comp type amount
    a1 6280 10
    a2 6280 20
    a2 4810 15
    a2 1147 12
    a3 6280 33
    Now I want the table to look like this:
    a1 a2 a3
    1147 0 12 0
    4810 0 15 0
    6280 10 20 33
    A simple question in Excel for example, I just use the pivot function and have it fixed within 10seconds. But how can I do sth. like this in Oracle with simple SQL? Or it can be PL/SQL too, cause I will use this in an APEX application.
    Can you please give me a hint or a solution? But as stated before a1, a2, a3 are just examples it is possible that tomorrow a4, a5 and so on are coming. If it is necessary I can also create additional tables and views of course!
    Thanks for your help!
    Regards
    hoge

    Hi Hoge!
    Here is your solution:
    SELECT TYPE,
           sum(a1) AS a1,
           sum(a2) AS a2,
           sum(a3) AS a3
      FROM (SELECT TYPE,
                   decode(comp, 'a1', amount, 0) AS a1,
                   decode(comp, 'a2', amount, 0) AS a2,
                   decode(comp, 'a3', amount, 0) AS a3
              FROM test)
      GROUP BY TYPE
      ORDER BY TYPE; And here is my test case setup:
    CREATE TABLE test
        (comp VARCHAR2(255),
         TYPE NUMBER,
         amount NUMBER);
    INSERT INTO test(comp, TYPE, amount) VALUES('a1', 6280, 10);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 6280, 20);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 4810, 15);
    INSERT INTO test(comp, TYPE, amount) VALUES('a2', 1147, 12);
    INSERT INTO test(comp, TYPE, amount) VALUES('a3', 6280, 33);
    commit;Best regards,
    Matt

  • Oracle rows to columns/pivot function

    Does anyone have any experience using the oracle pivot function? I have two tables:
    Table1:Users
    Username
    jsmith
    jjohnson
    jbeck
    Table2:Job Codes
    Username,Job Code
    jsmith,JC1
    jsmith,JC2
    jsmith,JC3
    jbeck,JC2
    I'm looking to formulate a query that will allow me to join the two tables and at the same time have the rows from table2 represented as columns (assuming a max of 3 job codes):
    Username,JobCode1,JobCode2,JobCode3
    jsmith,JC1,JC2,JC3
    jbeck,JC2,,
    It seems like pivot is the function I want to use for this but I can't seem to correlate the examples online back to what we're trying to do.

    Hi,
    Welcome to the forum!
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}
    Since I don;t have a version of your table, I'll use the scott.emp table.
    I think you want something like this:
    WITH     got_r_num     AS
         SELECT     job, ename
         ,     ROW_NUMBER () OVER ( PARTITION BY  job
                                   ORDER BY          ename
                           ) AS r_num
         FROM    scott.emp
    SELECT       *
    FROM       got_r_num
    PIVOT       (    MIN (ename)
                FOR r_num IN ( 1      AS name_1
                                 , 2  AS name_2
                       , 3  AS name_3
    ORDER BY  job
    ;This shows up to 3 names from each job
    JOB       NAME_1     NAME_2     NAME_3
    ANALYST   FORD       SCOTT
    CLERK     ADAMS      JAMES      MILLER
    MANAGER   BLAKE      CLARK      JONES
    PRESIDENT KING
    SALESMAN  ALLEN      MARTIN     TURNERIf there are more than 3 rows with the same job, only the first 3 (in alphabetic order; that's what the analytic ORDER BY clause is doing) will be shown. For example, there's another SALESMAN named WARD who is not shown above.
    This query requires Oracle 11.1 (or higher).
    For other pivot techniques, including ones for earlier versions, see the forum FAQ {message:id=9360005}
    Edited by: Frank Kulash on May 25, 2012 10:20 AM
    Added output

  • Has anyone had a problem with TapMedia File Manage on iPhone 5. I reported a WIFI functionality problem to the developer and asked for support. Instead they have been very unprofessional by name calling me instead of logically evaluate and troubleshoot th

    Has anyone had a problem with TapMedia File Manage installed on iPhone 5? I reported a WIFI functionality problem to the developer and asked for support. Instead the company has been very unprofessional by name calling me instead of logically evaluate and troubleshoot the problem

    Hi AKE1919,
    Welcome to the Support Communities!
    The following information should help you with this:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/HT1933?viewlocale=en_US
    Cheers,
    Judy

  • How to use Pivot function for group range in oracle SQL

    Hi,
    Good Morning !!!
    I need to show the data in the below format. There is 2 columns 1 is State and another one is rate.
    State     <100     100-199     200-299     300-399     400-499     500-599     600-699     700-799     800-899     900-999     >=1000     Total
    AK     1     2     0     4     1     4     4     35     35     4     1     25
    AL     0     0     2     27     10     17     35     2     2     35     0     103
    AR     0     0     1     0     0     2     2     13     13     2     0     6
    AZ     0     1     2     14     2     14     13     3     3     13     0     57
    CA     0     0     1     6     2     7     3     4     4     3     0     34
    Developed the below query but unable to use the range on pivot function . Please help on this.
    (select      (SELECT SHORT_DESCRIPTION
         FROM CODE_VALUES
         WHERE CODE_TYPE_CODE = ad.STATE_TYPE_IND_CODE
         AND VALUE = ad.STATE_CODE
         ) STATE,
    nr.rate
         FROM neutrals n,
         contacts c,
         addresses ad,
         xref_contacts_addresses xca,
         neutral_rates nr
                        where n.contact_id=c.contact_id
                        and n.address_id = ad.address_id
                        and xca.address_id=ad.address_id
                        and xca.contact_id=c.contact_id
                        and nr.contact_id = n.contact_id
                        and nr.rate_frequency='HOUR' )

    user8564931 wrote:
    This solutions is useful and Thanks for your reply.
    How can i get the Min value and Max value for each row ?
    State     <100     100-199     200-299     300-399     400-499     500-599     600-699     700-799     800-899     900-999     >=1000     Total     Min     Max
    IL     0     0     1     5     1     5     40     1     1     40     0     53     $10     $2,500
    IN     0     0     0     0     0     0     1     49     49     1     0     3     $70     $1,500This?
    WITH t AS
            (SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 67 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 23 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 78 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 34 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 4 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 12 VALUE FROM DUAL
             UNION ALL
             SELECT 'AL' state, 15 VALUE FROM DUAL
             UNION ALL
             SELECT 'AZ' state, 6 VALUE FROM DUAL
             UNION ALL
             SELECT 'AZ' state, 123 VALUE FROM DUAL
             UNION ALL
             SELECT 'AZ' state, 123 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 23 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 120 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 456 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 11 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 24 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 34 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 87 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 23 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 234 VALUE FROM DUAL
             UNION ALL
             SELECT 'MA' state, 789 VALUE FROM DUAL
             UNION ALL
             SELECT 'MH' state, 54321 VALUE FROM DUAL),
         -- End of test data
         t1 AS
            (  SELECT state,
                      NVL (COUNT (DECODE (VALUE, 0, 0)), 0) "<100",
                      NVL (COUNT (DECODE (VALUE, 1, 1)), 0) "100-199",
                      NVL (COUNT (DECODE (VALUE, 2, 2)), 0) "200-299",
                      NVL (COUNT (DECODE (VALUE, 3, 3)), 0) "300-399",
                      NVL (COUNT (DECODE (VALUE, 4, 4)), 0) "400-499",
                      NVL (COUNT (DECODE (VALUE, 5, 5)), 0) "500-599",
                      NVL (COUNT (DECODE (VALUE, 6, 6)), 0) "600-699",
                      NVL (COUNT (DECODE (VALUE, 7, 7)), 0) "700-799",
                      NVL (COUNT (DECODE (VALUE, 8, 8)), 0) "800-899",
                      NVL (COUNT (DECODE (VALUE, 9, 9)), 0) "900-999",
                      NVL (COUNT (DECODE (VALUE, 10, 10)), 0) ">=1000"
                 FROM (SELECT state,
                              CASE
                                 WHEN VALUE < 100 THEN 0
                                 WHEN VALUE BETWEEN 100 AND 199 THEN 1
                                 WHEN VALUE BETWEEN 200 AND 299 THEN 2
                                 WHEN VALUE BETWEEN 300 AND 399 THEN 3
                                 WHEN VALUE BETWEEN 400 AND 499 THEN 4
                                 WHEN VALUE BETWEEN 500 AND 599 THEN 5
                                 WHEN VALUE BETWEEN 600 AND 699 THEN 6
                                 WHEN VALUE BETWEEN 700 AND 799 THEN 7
                                 WHEN VALUE BETWEEN 800 AND 899 THEN 8
                                 WHEN VALUE BETWEEN 900 AND 999 THEN 9
                                 WHEN VALUE >= 1000 THEN 10
                              END
                                 VALUE
                         FROM t)
             GROUP BY state)
    SELECT STATE,
           "<100",
           "100-199",
           "200-299",
           "300-399",
           "400-499",
           "500-599",
           "600-699",
           "700-799",
           "800-899",
           "900-999",
           ">=1000",
             "<100"
           + "100-199"
           + "200-299"
           + "300-399"
           + "400-499"
           + "500-599"
           + "600-699"
           + "700-799"
           + "800-899"
           + "900-999"
           + ">=1000"
              total,
         least("<100",
           "100-199",
           "200-299",
           "300-399",
           "400-499",
           "500-599",
           "600-699",
           "700-799",
           "800-899",
           "900-999",
           ">=1000") min_val,
          greatest("<100",
           "100-199",
           "200-299",
           "300-399",
           "400-499",
           "500-599",
           "600-699",
           "700-799",
           "800-899",
           "900-999",
           ">=1000") max_val
      FROM t1
    /

  • Pivot Function in Power Query

    Hi all,
    One thing i'm struggling with is the use of the pivot function to pivot a column within PQ.  I'm confused on why this happens and why I can't clear it up...but here goes:
    I unpivot a set of columns which then gives me two columns (Attribute/Value).  I do this because I have repeated columns of data, but it should all fall under one column (think Hours, Hours1, Hours2, etc) - basically the input is coming from a form
    that has repeating fields but everything is the same data type.
    I make some adjustments to the Attribute columns (Replace items within the Attribute column) then Pivot the two columns again...theoretically I would be able to do this since i just unpivoted the same data, but:
    I get tons of errors (usually "There were too many elements in the enumeration to complete the operation".).  I'm not entirely sure why this happens and it doesn't seem to make sense to me that I can't UnPivot and Pivot and get the same results
    as I originally had.  
    Any recommendations would be greatly appreciated!
    EDIT: I'm choosing "don't aggregate" during the Pivot operation...I get values if I keep some sort of aggregate function, but not the right values (I get a count of the fields instead of the data within the fields)

    Try this solution:
    Once you are to step 3, add an index column that starts at 0 and another index column that starts at 1. 
    Transform by Pivot Column using the names in Attribute to create new columns and the Values Column set to Value.  Under advanced options select Don't Aggregate. 
    Fill Down the Date column
    Filter rows to remove null from Work Time. 
    Here's the M code from the advanced editor: 
    let
        Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
        #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1),
        #"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 1, 1),
        #"Pivoted Column" = Table.Pivot(#"Added Index1", List.Distinct(#"Added Index1"[Attribute]), "Attribute", "Value"),
        #"Filled Down" = Table.FillDown(#"Pivoted Column",{"Date"}),
        #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Work Time] <> null)),
        #"Changed Type" = Table.TransformColumnTypes(#"Filtered Rows",{{"Work Time", type time}})
    in
        #"Changed Type"
    If that doesn't work, this example might do the trick:
    http://www.excelguru.ca/blog/2015/01/07/transpose-stacked-tables/

  • Issues with use of PIVOT function

    I have a single table that gives me a Value ID for each record. There are 1-3 of them for each Dim ID. The Name values of these can be found in a 2nd table, by the Value ID from the first table. I feel like this can be handled with the pivot function, but
    I'm having trouble figuring out how to set it up properly.
    Samples are below. Top left is table 1. Top right is table 2. Bottom is how I need the data to be captured in a query.

    DECLARE @dimValue TABLE (dimID INT, valueID INT)
    INSERT INTO @DimValue (dimID, valueID)
    VALUES
    (6,1),(6,10),(6,14),(8,3)
    DECLARE @dimNames TABLE (valueID int, name varchar(50), type varchar(10))
    INSERT INTO @DimNames (valueID, name, type)
    VALUES
    (1,'George','First'),(10,'Micheal','Middle'),(14,'Johnson','Last'),(3,'Stan','First')
    -- without pivot
    SELECT v.dimID, MAX(f.name) AS first, MAX(m.name) AS middle, MAX(l.name) AS last
    FROM @dimValue v
    LEFT OUTER JOIN @dimNames f
    ON v.valueID = f.valueID
    AND f.type = 'first'
    LEFT OUTER JOIN @dimNames m
    ON v.valueID = m.valueID
    AND m.type = 'middle'
    LEFT OUTER JOIN @dimNames l
    ON v.valueID = l.valueID
    AND l.type = 'last'
    GROUP BY v.dimID
    --pivot
    SELECT DimID, MAX(first) AS first, MAX(middle) AS middle, MAX(last) AS last
    FROM @dimNames n
    PIVOT (MAX(Name) FOR type IN (FIRST, middle, last)) pvt
    INNER JOIN @dimValue v
    ON pvt.valueID = v.valueID
    GROUP BY dimID
    This shows you how to do it with and without a pivot.
    Please don't post data as images. You force us to manually type it.
    Refer to the top of the code to see one way to give us demo data and objects.

  • Samsung TFT 244T pivot function with Nvidia Geforce 6600LE

    I have a Nvidia Geforce 6600LE installed in my powermac g5.
    I am interested in the Samsung 244 T display but I am not sure if the pivot function will work with my current graphic card.
    Any help would be appreciated.
    http://www.macoteket.se/productlist.jsp?group_id=945456&productid=841409
    Powermac G5 2.2 ghz   Mac OS X (10.4.8)  

    Hi Ingvar-
    Do you have the Nvidia Forceware software? Inside of that is NVRotate software that allows rotation of monitors.
    The Samsung uses proprietory software- their software (comes with the screen) is used when the screen is rotated.
    Either way, it should work.
    G4 AGP(450)Sawtooth   Mac OS X (10.4.8)   2ghzPPC,1.62gbSDRAM, ATI9800, DVR-109,(IntHD)120&160,LaCie160,23"Cinema Display

  • Common SAP MM Functional problems

    Fellows
    Is there anyone who can explain some common SAP MM daily functional problems. im junior consultant and want to be prepared for interviews. you may just state them in point form briefly.
    thanks
    rash

    Common Issue
    1)Vendor is not created for Purchasing Organisation XXXX.
    2)Though Vendor Master is Flag for Deletion ,Vendor is shows at the time of PO Creation.
    3)How to extend the materials for another storage location
    4)How to Create the PO for Different Currencies.
    5)While Posting The Doc . Error Occure,1) Account Determination for Entry 1000 BSV _ _ not Posssible.2)  Account Determination for Entry 1000 FRL _ _ not Posssible.
    6)Not Authorisation for Movt Type ......,Transaction Code......
    7) Account Determenation for transaction ....  Cost center ...does not maintain.
    8)While Creation of GR -Authorisation missing for Company Code 0000 Asset Class XXXX,
    9)While Removing The Stock of material by Cancelling the Goods Receipt Doc.Error occur that Stock Qty difficial by xx No.
    10)While GR Cancellation error occure that document does not contain any selected item.
    11)While Creating Service Entry Sheet Error occured that Qty entered  exceeded by Qty in PO
    12)While cancelling the matl.Doc Error occure that matl is deficit of sales ordr stock.
    13) Error-Tax code does not Exist while creating Miro
    14)TDS Amount is not Captured at Miro entry.
    15)While Miro error occure that No suitable item found for Purchase Order.
    16)User ID gets Blocked due to wrong Password entered more than 3 times.
    18)Error-Gl account does not created for Chart of account XXXX while Miro
    19)In Purchase Order Service tax is 12.24 % and at Bill service tax is 10.5 .How to adjust it and How to cancell Wrong Miro
    20)Stock Statement not matched Value still lying into Stock A/c
    Rewards if Helpful...
    Regards
    Sanjay L

  • Satellite U200-122: How to use Pivot function on external Monitor?

    I have a Satellite U200-122, would like to use the external monitor in pivbot function.
    But I do not find where I can have the display rotate, so that it will be displayed in portrait format on the external monitor and accept resolution 1024x1280.
    Any ideas?
    Graphic driver: Intel Chipset 945GM express
    Thanks
    Isabel

    Thax for the tipp, but:
    That is exactly my problem: the intel graphics acceklerator DOES NOT offer any rotate functionality! I wonder why because I have read in many forums that it should have, I know it can be seen on the right part of the intel graphics accelerator window, but nothing is there.
    So i wonder, if in the U200 there is possibly a different graphic driver or management sofwtare, which just does not support this? Could it be that a graphic driver does not offer pivot???
    Shortcuts do not work either.
    Btw: when i put the laptop on a kensington workstation, then the kensington graphic manager -display -link - is used, and then with many workarounds i do get the monitor to show pivot in necessary reolution. but i want a to use a pivot monitor also at home without dockingstation...

  • Filter Function problems on ALV report. [Resolved]

    Hi,
    I developed an ALV report by using function as below:
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM = G_REPID
    *            I_CALLBACK_PF_STATUS_SET = status_set
    *            I_CALLBACK_USER_COMMAND  = USER_COMMAND
                  I_STRUCTURE_NAME = 'T_BSIK'
                  IS_LAYOUT        = GS_LAYOUT
                  IT_FIELDCAT      = GT_FIELDCAT[]
             TABLES
                  T_OUTTAB    = TAB_BSIK.
    And this ALV custom report is referenced from standard function FBL5N.
    After i completed this report, i made an comparision of FBL5N and my custom report.
    When I apply the filter function, for example, on the document type, I cannot input 2 characters in the document type field under the filter function. The field length is only 1 character. Similar case results on the field document date.
    While the standard function FBL5N works very nice.
    What should i do to make the filter function of my own ALV report as the same as the standard function FBL5N do?
    Thanks in advance.
    Lala
    Message was edited by:
            Hoo lala

    Oh, i found where the problem is...
    add below 2 statements, then the question is resolved.
      LS_FIELDCAT-ref_fieldname = ****
      LS_FIELDCAT-ref_tabname = ***
    FORM FIELDCAT_INIT tables RT_FIELDCAT.
    CLEAR LS_FIELDCAT.
      LS_FIELDCAT-COL_POS   =  3.
      LS_FIELDCAT-FIELDNAME = 'BLART'.
      LS_FIELDCAT-TABNAME   = 'TAB_BSIK'.
      LS_FIELDCAT-SELTEXT_L = 'Document Type'.
      LS_FIELDCAT-ref_fieldname = 'BLART'.
      LS_FIELDCAT-ref_tabname = 'BSIK'.
      APPEND LS_FIELDCAT TO  RT_FIELDCAT.
    endform.
    Fine now.
    Lala

  • I have the "Bookmarks and history system will not be functional" problem and not FireFox will not open at all and my whole computer freezes if I try.

    For a few weeks now, I've been getting the "Bookmarks and history system will not be functional..." message. When I clicked for more information, FireFox would freeze.
    I found a solution about a new places database, but for the past few days I can't get FireFox to open at all. Then my whole system is frozen and I have to turn it off to get it going again, thus losing a lot of unsaved data.
    How can I get FireFox back?

    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.com/kb/The+bookmarks+and+history+system+will+not+be+functional

  • View with columns based on function - problem with query

    Hi,
    I'm using Oracle 9i;
    I've created a view which has columns based on a table columns (multiple columns from 1 table) and funtion (multiple columns based on 1 function).
    The function takes ID as the first argument and name of the column to determine which value to return as the second one.
    Here is a sample of such function (simplified):
    FUNCTION my_function
    (in_id IN NUMBER, in_col_name IN VARCHAR2)
    RETURN VARCHAR2
    IS
    c_name VARCHAR2(100);
    c_last_name VARCHAR2(100);
    BEGIN
    SELECT T.NAME, T.LAST_NAME
    INTO c_name, c_last_name
    FROM TABLE_1 T, TABLE_2 Z
    WHERE T.PK = Z.FK
    AND Z.ID = in_id;
    IF in_col_name = 'NAME' THEN
    RETURN c_name;
    ELSIF in_col_name = 'LAST_NAME' THEN
    RETURN c_last_name;
    END IF;
    END;
    For simplicty I've restricted the number of columns.
    CREATE OR REPLACE VIEW my_view
    (ID, NAME, LAST_NAME)
    AS
    SELECT
    T.ID ID
    ,CAST(my_function(T.ID,'NAME') AS VARCHAR2(100)) NAME
    ,CAST(my_function(T.ID,'LAST_NAME') AS VARCHAR2(100)) LAST_NAME
    FROM TABLE T;
    There is no problem with query:
    SELECT * FROM my_view;
    The problem arises when I query the view (regardles of '=' or 'LIKE'):
    SELECT * FROM my_view
    WHERE name LIKE '%some_part_of_name%'
    The query returns rows for same names, for same it doesn't. If I put '=' and the whole name the query returns nothing, but when I put 'LIKE' and the first letter it returns rows in some cases.
    I've tried to debug this situation and I've discovered that the function recives ID not in the proper order and not the same amount of times - in explicit:
    for each ID in (1, 2, 3, 4, 5, 6, ... , 100) the function should be called twice for each ID and in the same order, but it does not.
    I get 1, 1, 2, 3, 3, 6, 20, 20 and so on.
    Help needed.
    Greetings.

    The problem is more complicated than the solutions provided here.
    The reason why I'm using the function is this:
    the original view was constructed using multiple union all selects and the speed was terrible. I've created the index on the base table to obtain a proper sort. For retriving all records at once the view works perfectly, but if one wants to query by columns based on function the results are suprisng - sometimes there are, some times there are none, or if you serch with "like" and only a part of string there are results, but with "=" there are no results.
    Here are real DDLs:
    View:
    CREATE OR REPLACE VIEW V_DOK_ARCH
    (ID_ZDAR, TYP, STAN, DATE_CREATED, CREATED_BY,
    DATE_MODIFIED, MODIFIED_BY, SPRA_ID_SPRA, PODM_ID_PODM, PODM_UMOW_ID_UMOW,
    NR_WFS, WFS_NR_INTER, UWAGI_OPER, FUNDUSZ, NUMER,
    DATA_PODPISANIA, RODZAJ, TYP_PRZY, TYP_UBEZ, NAZWISKO,
    IMIE, IMIE_OJCA, NAZWA_FIRMY, NAZWA_FIRMY_SKR, DANE_KLIE)
    AS
    SELECT /*+ INDEX(Z ZDAR_DATE_CREATED_DESC_I) */
    Z.ID_ZDAR ID_ZDAR
    , Z.TYP TYP
    , Z.STAN STAN
    , Z.DATE_CREATED DATE_CREATED
    , Z.CREATED_BY CREATED_BY
    , Z.DATE_MODIFIED DATE_MODIFIED
    , Z.MODIFIED_BY MODIFIED_BY
    , Z.SPRA_ID_SPRA SPRA_ID_SPRA
    , Z.PODM_ID_PODM PODM_ID_PODM
    , Z.PODM_UMOW_ID_UMOW PODM_UMOW_ID_UMOW
    , Z.NR_WFS NR_WFS
    , Z.WFS_NR_INTER WFS_NR_INTER
    , Z.UWAGI_OPER UWAGI_OPER
    , Z.FUNDUSZ FUNDUSZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NUMER') AS VARCHAR2(30)) NUMER
    , F_Rej_Zdar_Date(Z.ID_ZDAR, 'DATA_PODPISANIA') DATA_PODPISANIA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'RODZAJ') AS VARCHAR2(4)) RODZAJ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_PRZY') AS VARCHAR2(4)) TYP_PRZY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'TYP_UBEZ') AS VARCHAR2(3)) TYP_UBEZ
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO') AS VARCHAR2(30)) NAZWISKO
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE') AS VARCHAR2(30)) IMIE
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA') AS VARCHAR2(30)) IMIE_OJCA
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY') AS VARCHAR2(300)) NAZWA_FIRMY
    , CAST(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR') AS VARCHAR2(100)) NAZWA_FIRMY_SKR
    , CAST(LTRIM(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWISKO')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE')||' '||F_Rej_Zdar_Char(Z.ID_ZDAR, 'IMIE_OJCA')||F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY')||DECODE(F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY'),NULL,F_Rej_Zdar_Char(Z.ID_ZDAR, 'NAZWA_FIRMY_SKR'),NULL)) AS VARCHAR2(492)) DANE_KLIE
    FROM T_ZDARZENIA Z
    WHERE F_Rej_Zdar_Char(Z.ID_ZDAR, 'JEST') = 'T';
    and functions:
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Char
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN VARCHAR2
    IS
    c_numer           T_PRZYSTAPIENIA.NUMER%TYPE;--VARCHAR2(30);
    c_rodzaj           T_KLIENCI.RODZAJ%TYPE;--VARCHAR2(1);
    c_typ_przy           T_PRZYSTAPIENIA.TYP_PRZY%TYPE;--VARCHAR2(1);
    c_typ_ubez           T_PRZYSTAPIENIA.TYP_UBEZ%TYPE;--VARCHAR2(3);
    c_nazwisko           T_KLIENCI.NAZWISKO%TYPE;--VARCHAR2(30);
    c_imie                T_KLIENCI.IMIE%TYPE;--VARCHAR2(30);
    c_imie_ojca      T_KLIENCI.IMIE_OJCA%TYPE;--VARCHAR2(30);
    c_nazwa_firmy      T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(300);
    c_nazwa_firmy_skr T_KLIENCI.NAZWA_FIRMY%TYPE;--VARCHAR2(100);
    c_jest                VARCHAR2(1) := 'T';
    c EXCEPTION;
    BEGIN
    --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR);
    BEGIN
    SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
    INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.NUMER, k.RODZAJ,p.TYP_PRZY,p.TYP_UBEZ,k.nazwisko, k.imie, k.imie_ojca, k.nazwa_firmy, k.nazwa_firmy_skr
         INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, I.nazwisko, I.imie, I.imie_ojca, I.NAZWA NAZWA_FIRMY, I.NAZWA_SKR nazwa_firmy_skr
              INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                   INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.NUMER NUMER, DECODE(a.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(a.TYP_AGENTA,'P','R',a.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,a.nazwisko, a.imie, a.imie_ojca, a.nazwa_firmy, a.nazwa_firmy_skr
                        INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                             INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.NUMER_UMOWY NUMER, DECODE(p.TYP_AGENTA,'A','F','P') RODZAJ, DECODE(p.TYP_AGENTA,'P','R',p.TYP_AGENTA) TYP_PRZY,NULL TYP_UBEZ,p.nazwisko, p.imie_pierwsze, p.imie_ojca, p.nazwa_firmy, p.nazwa_firmy_skr
                                  INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.NUMER_UMOWY NUMER, DECODE(k.TYP_PRZYSTAPIENIA,'P','F','P') RODZAJ,k.TYP_PRZYSTAPIENIA TYP_PRZY,'NPO' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, k.nazwa_firmy nazwa_firmy, k.nazwa_firmy_skr nazwa_firmy_skr
                                       INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.NUMER_UMOWY NUMER, 'F' RODZAJ,'-' TYP_PRZY,'OPS' TYP_UBEZ, k.nazwisko, k.imie_pierwsze, k.imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                            INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL NUMER, NULL RODZAJ,NULL TYP_PRZY,NULL TYP_UBEZ, NULL nazwisko, NULL imie_pierwsze, NULL imie_ojca, NULL nazwa_firmy, NULL nazwa_firmy_skr
                                                 INTO c_numer, c_rodzaj, c_typ_przy, c_typ_ubez, c_nazwisko, c_imie, c_imie_ojca, c_nazwa_firmy, c_nazwa_firmy_skr
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           --dbms_output.put_line('id zdar wykonania '||WE_ID_ZDAR||' ostatni wyjatek');
                                                           NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    --raise c;
    IF WE_KOLUMNA = 'NUMER' THEN
    RETURN c_numer;
    ELSIF WE_KOLUMNA = 'RODZAJ' THEN
    RETURN c_rodzaj;
    ELSIF WE_KOLUMNA = 'TYP_PRZY' THEN
    RETURN c_typ_przy;
    ELSIF WE_KOLUMNA = 'TYP_UBEZ' THEN
    RETURN c_typ_ubez;
    ELSIF WE_KOLUMNA = 'NAZWISKO' THEN
    RETURN c_nazwisko;
    ELSIF WE_KOLUMNA = 'IMIE' THEN
    RETURN c_imie;
    ELSIF WE_KOLUMNA = 'IMIE_OJCA' THEN
    RETURN c_imie_ojca;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY' THEN
    RETURN c_nazwa_firmy;
    ELSIF WE_KOLUMNA = 'NAZWA_FIRMY_SKR' THEN
    RETURN c_nazwa_firmy_skr;
    ELSIF WE_KOLUMNA = 'JEST' THEN
    RETURN c_jest;
    END IF;
    END;
    CREATE OR REPLACE FUNCTION F_Rej_Zdar_Date
    (WE_ID_ZDAR IN NUMBER
    ,WE_KOLUMNA IN VARCHAR2
    RETURN DATE
    IS
    d_data DATE;
    BEGIN
    BEGIN
    SELECT p.DATA_PODPISANIA
    INTO d_data
    FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D1, T_PODMIOTY D2
    WHERE p.KLIE_ID_KLIE = k.ID_KLIE
    AND z.PODM_ID_PODM = D1.ID_PODM
    AND D1.KLIE_ID_KLIE = p.KLIE_ID_KLIE
    AND Z.PODM_UMOW_ID_UMOW = D2.ID_PODM
    AND D2.PRZY_ID_PRZY = P.ID_PRZY
    AND z.ID_ZDAR = WE_ID_ZDAR;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         BEGIN
         SELECT p.DATA_PODPISANIA
         INTO d_data
         FROM T_KLIENCI k, T_PRZYSTAPIENIA p, T_ZDARZENIA z, T_PODMIOTY D
         WHERE z.PODM_UMOW_ID_UMOW IS NULL
         AND z.PODM_ID_PODM = D.ID_PODM
         AND D.KLIE_ID_KLIE = k.ID_KLIE
         AND p.KLIE_ID_KLIE = k.ID_KLIE
         AND z.ID_ZDAR = WE_ID_ZDAR;
         EXCEPTION
              WHEN NO_DATA_FOUND THEN
              BEGIN
              SELECT NULL DATA_PODPISANIA
              INTO d_data
              FROM T_ZDARZENIA z, T_INSTYTUCJE I
              WHERE Z.TYP IN ('WFS526','WFS542','WFS553','WFS609','WFS611','WYP_KS','WYP_PO','WYP_SB','DI_ZAT')
              AND z.PODM_UMOW_ID_UMOW IS NULL
              AND Z.PODM_ID_PODM = I.ID_INST
              AND z.ID_ZDAR = WE_ID_ZDAR;
              EXCEPTION
                   WHEN NO_DATA_FOUND THEN
                   BEGIN
                   SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                   INTO d_data
                   FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                   WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                   AND z.PODM_UMOW_ID_UMOW = p.ID_AGUM
                   AND z.ID_ZDAR = WE_ID_ZDAR;
                   EXCEPTION
                        WHEN NO_DATA_FOUND THEN
                        BEGIN
                        SELECT p.DATA_PODPISANIA DATA_PODPISANIA
                        INTO d_data
                        FROM T_AG_AGENCI a, T_AG_UMOWY p, T_ZDARZENIA z
                        WHERE a.ID_AGAG = p.AGAG_ID_AGAG
                        AND z.PODM_ID_PODM = a.ID_AGAG
                        AND z.PODM_UMOW_ID_UMOW IS NULL
                        AND z.ID_ZDAR = WE_ID_ZDAR;
                        EXCEPTION
                             WHEN NO_DATA_FOUND THEN
                             BEGIN
                             SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                             INTO d_data
                             FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                             WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                             AND z.PODM_UMOW_ID_UMOW = p.TECH_ID_AGUMT
                             AND z.ID_ZDAR = WE_ID_ZDAR;
                             EXCEPTION
                                  WHEN NO_DATA_FOUND THEN
                                  BEGIN
                                  SELECT p.DATA_PODPISU_AGENTA DATA_PODPISANIA
                                  INTO d_data
                                  FROM T_AG_KANDYDACI a, T_AG_UMOWY_TAB p, T_ZDARZENIA z
                                  WHERE a.ID_AGKAN = p.TECH_PODM_ID_PODM
                                  AND z.PODM_ID_PODM = a.ID_AGKAN
                                  AND z.PODM_UMOW_ID_UMOW IS NULL
                                  AND z.ID_ZDAR = WE_ID_ZDAR;
                                  EXCEPTION
                                       WHEN NO_DATA_FOUND THEN
                                       BEGIN
                                       SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                       INTO d_data
                                       FROM T_WE_UM_NPO_TAB k, T_ZDARZENIA z
                                       WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                       AND k.TYP_PRZYSTAPIENIA IN ('P','W')
                                       AND z.PODM_ID_PODM IS NULL
                                       AND z.PODM_UMOW_ID_UMOW IS NULL
                                       AND z.ID_ZDAR = WE_ID_ZDAR;
                                       EXCEPTION
                                            WHEN NO_DATA_FOUND THEN
                                            BEGIN
                                            SELECT k.DATA_PODPISANIA_UM DATA_PODPISANIA
                                            INTO d_data
                                            FROM T_WE_UM_OPS_TAB k,T_ZDARZENIA z
                                            WHERE z.ID_ZDAR = k.TECH_ZDAR_ID_ZDAR
                                            AND z.PODM_ID_PODM IS NULL
                                            AND z.PODM_UMOW_ID_UMOW IS NULL
                                            AND z.ID_ZDAR = WE_ID_ZDAR;
                                            EXCEPTION
                                                 WHEN NO_DATA_FOUND THEN
                                                 BEGIN
                                                 SELECT NULL DATA_PODPISANIA
                                                 INTO d_data
                                                 FROM T_ZDARZENIA z
                                                 WHERE z.TYP NOT IN ('UM_OPS','UM_NPO','NPO_OP','UZUP_U')
                                                 AND z.PODM_ID_PODM IS NULL
                                                 AND z.PODM_UMOW_ID_UMOW IS NULL
                                                 AND z.ID_ZDAR = WE_ID_ZDAR;
                                                 EXCEPTION
                                                      WHEN NO_DATA_FOUND THEN
                                                           d_data := NULL;
                                                 END;
                                            END;
                                       END;
                                  END;
                             END;
                        END;
                   END;
              END;
         END;
    END;
    IF WE_KOLUMNA = 'DATA_PODPISANIA' THEN
    RETURN d_data;
    END IF;
    END;

  • Virtual function problem with SC 4.2

    Hi
    I'm using SC CC 4.2
    [CC -V
    CC: WorkShop Compilers 4.2 18 Sep 1997 C++ 4.2 patch 104631-04]
    not the latest patch, I realize.
    The following bit of code:
    ProcessParameters *ppp = &(_config.process_params_);
    ppp->save_to_file(String("abc"));
    config.processparams_.save_to_file(String("xyz"));
    does not work as I'd expect it to!
    config.processparams_ is of type ProcessParametersEnhanced,
    and the definition of this, and its base class, looks like:
    class ProcessParameters
    public:
    virtual int save_to_file(String filename);
    and
    class ProcessParametersEnhanced : public ProcessParameters
    public:
    virtual int save_to_file(String filename);
    (I've cut everything else out of the class definitions for clarity, and I've changed the names a bit as well, hopefully without typos).
    ppp->save_to_file(String("abc"));
    calls ProcessParameters::save_to_file(String)
    even though ppp points to an instance of ProcessParametersEnhanced, and the function is virtual.
    I've tried building a small test application, using the minimum class interfaces, but this works as I'd expect (it also works fine with gcc).
    I'm getting deseperate. Is there a bug in SC4.2 whereby it fails to resolve virtual functions correctly?
    TIA
    Paul Floyd

    Oh well, it was an SC4.2 bug
    Patch-ID# 104631-07
    Keywords: C++ 4.2 SC4.2
    Synopsis: SPARCompiler C++ 4.2: C++ 4.2 patch for Solaris 2.x
    Date: Jul/17/98
    4066271 C++ has a problem with a copy constructor using virtual and multiple inheritance
    It seems as though the copy ctor doesn't copy the vtbl.
    Cheers
    Paul

  • Function problem...pls help??

    HELLO
    i have a fucntion
    FUNCTION GET_ABRV (PLAYERID NUMBER, MATCHID NUMBER)
    RETURN VARCHAR2 AS
    A VARCHAR2(100);
    BEGIN
         SELECT ' run out ('||table_col_1||' / '||table_col_2||')'
         INTO A
    FROM TABLE
    where PLAYER_ID = PLAYERID
    AND MATCH_ID = MATCHID;     
    RETURN (A);
    EXCEPTION WHEN NO_DATA_FOUND THEN RETURN NULL;
    END;
    This fucntion gives me the output in the following manner
    SQL> SELECT GET_ABRV(201, 10) FROM DUAL
    GET_DISMISSAL_9_DESCRIPTION(201,10)
    run out (S John / H Peal)
    that is ok!
    but the problem is that suppose if the value of the 'table_col_1' and 'table_col_2' is null either alone or
    combined in the table for any row then I want the output of the fucntion according to that
    suppose i call my fucntion
    SQL> SELECT GET_ABRV(321, 12) FROM DUAL
    now suppose the value of table_col_1 is null and the value of table_col_2 is not null the fucntion
    should give me the output like this...
    GET_DISMISSAL_9_DESCRIPTION(201,10)
    run out (A Smith)
    i.e. no slash before the name 'A Smith'
    at present it is giving me this output...
    GET_DISMISSAL_9_DESCRIPTION(201,10)
    run out ( / A Smith)
    but i want that if either value of the 'table_col_1' or 'table_col_2' is null then the fucntion should
    return me only the name (in brackets) and not any slash
    incase if both values 'table_col_1' and 'table_col_2' are null then the function should return me the
    value like this
    GET_DISMISSAL_9_DESCRIPTION(1011,20)
    run out
    i.e no brackets and the slash since table_col_1' and 'table_col_2' were null
    I want this to be done through the fucntion i pasted above...using only two input values that I have given in my fucntion i.e. (PLAYERID NUMBER, MATCHID NUMBER)
    hope this will clear my problem...
    regrds,
    Asim.

    SQL> create table runs(col_1 varchar2(10), col_2 varchar2(10)) ;
    Table created.
    SQL> insert into runs values (NULL, NULL) ;
    1 row created.
    SQL> insert into runs values (NULL, 'H Peal') ;
    1 row created.
    SQL> insert into runs values ('S John', 'H Peal') ;
    1 row created.
    SQL> insert into runs values ('S John', NULL) ;
    1 row created.
    SQL> CREATE OR REPLACE FUNCTION GET_ABRV (p_rowid ROWID)
      2  RETURN VARCHAR2 AS
      3    A VARCHAR2(100);
      4  BEGIN
      5    SELECT ' run out ('||
      6     LTRIM(RTRIM(col_1 || '/' || col_2, '/'), '/')||
      7     ')'
      8    INTO A
      9    FROM runs
    10    where ROWID = p_rowid;
    11    RETURN (A);
    12  EXCEPTION
    13  WHEN NO_DATA_FOUND
    14  THEN
    15    RETURN NULL;
    16  END;
    17  /
    Function created.
    SQL> show errors
    No errors.
    SQL> select REPLACE(get_abrv(rowid), '()') from runs ;
    REPLACE(GET_ABRV(ROWID),'()')
    run out
    run out (H Peal)
    run out (S John/H Peal)
    run out (S John)
    4 rows selected.
    SQL>

Maybe you are looking for

  • Duplicate Invoices posted

    Kindly tell me how can i find the duplicate invoices posted against a single GR if any. which are the tables to be used or is there any standard transaction.

  • Basic questions about AirPort and channels

    I have a VERY limited knowledge about networks. Please keep answers simple. My setup is very basic. My computer is connected to the internet via AirPort through my wireless gateway (router). When I pull down the AirPort menu from the toolbar it lists

  • CCB-MDM Integration -- F1_SYNC_REQ_IN_REL_OBJ

    Hi All, We are configuring and installaing the CCB-MDM integration media pack 3.1.1, all the process are went successsfully other than the Business Object schema name is required error message in the batch run tree after running the D1-SILCN batch to

  • ITunes thinks disc 2 of two-disc set is disc 1

    I am trying to import Rush - Chronicles, which is a two-disc set. I was able to import disc 1 successfully. However, when I insert disc 2, iTunes shows it as disc 1, lists all the tracks from disc 1, and warns me that I'm about to import duplicate tr

  • Hierarchical Address Book Access Enumeration?

    We are currently looking at the Hierarchical Address Book (HAB) feature for our Exchange 2010 SP3 on-prem deployment. One request was to limit the user/room/resources a user can see in the HAB based on whether the user has permissions to "see" that r