Is it possible to distinct based on individual column ?

This is the sample data i have , on Oracle 11G ,Release 1.
WITH T AS
(SELECT '001' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION
SELECT '002' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '003' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '004' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '005' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '005' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '005' ID,TO_DATE('16-09-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '006' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
SELECT '006' ID,TO_DATE('16-09-2011','dd-mm-yyyy') DT FROM DUAL
SELECT DISTINCT ID,DT FROM T;From the above query as expected i got all those rows that have distinct ID and DT column . Here a total of 8 rows.
It is also important to note that distinct applies on whole column of a row at time and not on the individual column ,as explained in this example.
Is there any way to get all those rows whose one column do not contain repeated data.
e.g., select ID and DT where ID column do not repeat with same value.

Depends on what you want to do exactly.
But analytics can probably help you out.
E.g.
SQL> WITH T AS
  2  (SELECT '001' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION
  3   SELECT '002' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  4   SELECT '003' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  5   SELECT '004' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  6   SELECT '005' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  7   SELECT '005' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  8   SELECT '005' ID,TO_DATE('16-09-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  9   SELECT '006' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
10   SELECT '006' ID,TO_DATE('16-09-2011','dd-mm-yyyy') DT FROM DUAL
11  )
12  SELECT id
13  ,      dt
14  FROM
15  (SELECT id
16   ,      dt
17   ,      row_number() over (partition by id order by dt) rn
18   FROM T)
19  WHERE rn = 1;
ID  DT
001 16-AUG-11
002 16-AUG-11
003 16-AUG-11
004 16-AUG-11
005 16-AUG-11
006 16-AUG-11
6 rows selected.
SQL>
SQL> WITH T AS
  2  (SELECT '001' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION
  3   SELECT '002' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  4   SELECT '003' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  5   SELECT '004' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  6   SELECT '005' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  7   SELECT '005' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  8   SELECT '005' ID,TO_DATE('16-09-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
  9   SELECT '006' ID,TO_DATE('16-08-2011','dd-mm-yyyy') DT FROM DUAL UNION ALL
10   SELECT '006' ID,TO_DATE('16-09-2011','dd-mm-yyyy') DT FROM DUAL
11  )
12  SELECT id
13  ,      dt
14  FROM
15  (SELECT id
16   ,      dt
17   ,      count(*) over (partition by id) cn
18   FROM T)
19  WHERE cn = 1;
ID  DT
001 16-AUG-11
002 16-AUG-11
003 16-AUG-11
004 16-AUG-11

Similar Messages

  • Count Distinct based on another column in the same table

    Hello,
    My question in short: is is it possible to add a new column to a view which holds the DISTINCT COUNTS of values/domains of another column in the same view?
    For example, in the below table the column "Distinct Count of Occurence" shows how many distinct values a person has in the Occurence column. So AAA has 1 and 2 therefore it is 2 distinct values etc.
    My issues is that I can retrieve unique values bu Count (Select Occurence)but I can not add the new column that would add the records to the corresponding Persons in the above table.
    Is there an easy way to achieve this on the DWH level or should it be done with MDX in the cube?
    Thanks

    Hi,
    Below a solution to use the view by adding a column with window functioning, maybe this will help.
    CREATE TABLE #TMP
    PERSON VARCHAR(10),
    OCCURENCE SMALLINT
    --DROP TABLE #TMP
    INSERT INTO #TMP(PERSON,OCCURENCE)
    VALUES
    ('AAA','1'),
    ('AAA','2'),
    ('BBB','1'),
    ('BBB','1'),
    ('BBB','1'),
    ('CCC','1'),
    ('CCC','2'),
    ('CCC','3');
    --TRUNCATE TABLE #TMP
    WITH CTE
    AS
    SELECT PERSON
    ,OCCURENCE
    ,ROW_NUMBER() OVER(PARTITION BY PERSON ORDER BY OCCURENCE) AS RN
    FROM #TMP
    SELECT PERSON, MAX(RN) AS RN
    FROM CTE
    GROUP BY PERSON
    Regards,
    Reshma
    Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

  • In system settings 15 item are not accessible, get the message: cannot open it, is not possible on intel based MAC. Items like security, i cloud user and groups network and more

    in system settings 15 item are not accessible, get the message: cannot open it, is not possible on intel based MAC. Items like security, iCloud user and groups network and more.
    Genius bar told me to erase the harddisk and install OSX Maverick again. This has not changed the problems with the system settings

    You need to Repartition the drive as One partition which will erase all data from it and then reinstall OS X. then with the initial setup system you chose the language on the first screen that comes up. That sets the language for the whole system.
    There is no other way of completely removing certain information created by a previous owner. this hold strue whether you are selling or give a Mac to someone.
    To do the repartitioning you need to use the Online Internet Recovery system, if the Mac came with Lion 10.7 or above, or from the original system reinstall discs that came with it when it was new.

  • Is it possible to render the clips individually and relink- such as with Color/fcp?

    I'm fairly new to Ae/ PP, and am trying to figure out a good workflow for grading (using resolve lite) Basically, I need to denoise my footage first (neat video) and then send that footage to Resolve, then back to pp. Now, this works fine with Resolve's scene detector as it can cut up the footage, but if there are any dissolves, etc, then I need to do this via xml instead.
    What I would like to do is: Edit in PP. Send to AE to denoise, render (the denoise need to happen before grading) and replace the original files with the new denoised clips in pp. Then send the xml to Resolve. So far this would work if it wasn't for AE rendering everything into one clip, eliminating the cuts/layers.
    Is it possible to render the clips individually and relink- such as with Color/fcp? If not, any other workflow that could work for me?
    Hope someone can help- dynamic link is driving me up the wall.

    Simply use Dynamic Link to send your whole timeline to AE or use AE's Premiere project import. Then once you have a working AE project, you can use scripts like rdPreCompose to create separate sub-comps for each clip which in turn you then can render separately. Still, the limitation will always be the kind of transitions you use. Essentialyl you should avoid anything that isn't a hard cut or simple cross dissolve 'cos there's no way to recreate it in AE without eating up the handle of your footage. You'd essentialyl be shooting yourself in teh foot if you jump ahead too far in Premiere and already add too much finishing there.
    Mylenium

  • Delete duplicate rows -- based on 4 columns -- how?

    I asked this question on how to delete duplicates recently and received this suggestion which works well -- except --
    With CTE AS
    SELECT *, ROW_NUMBER() OVER (Partition by fld1 order by fld1) RowNum
    FROM #tmpA
    DELETE From CTE
    WHERE RowNum > 1
    -- the actual table I need to delete duplicate rows on is based on 4 columns.  The following table contains 14,462 rows of which 14,348 are distinct -- based on the following 4 colums.  Below is an image of a sample of the data contained in the
    table for my question and to the right of that data is the column structures (data types).  Is it possible to do something like the above example suggestion with the table in the image below?  How to do that?  I need to delete rows so that 14462
    goes down to 14348.  If I only reference one column for the delete -- this would delete like 7000+ rows.  I only need to remove 114 rows.
    Rich P

    Add the other 3 columns to the partition.
    Jason Long

  • Deleting duplicate rows based on three columns in Oracle 8i

    Hi all,
    The database we use is Oracle 8i.
    The query below raises the too_many_rows exception when I launch an application. So I want to delete the duplicated rows :
    select polarisation_1, polarisation_2
    into v_pol1_tech, v_pol2_tech
    from v_cfh_lien_element
    where nom_lien = p_nom_lien
    AND num_canal_1 = p_num_canal_1
    AND freq_emise_1 = p_freq_emise_1;
    Notice that with many possible values of the parameters p_nom_lien, p_num_canal_1 and p_freq_emise_1 then the exception is raised.
    So how to delete generally the duplicated rows based on the three columns "nom_lien" , "num_canal_1" and "freq_emise_1" ?
    Thank you very much indeed.

    Check the other thread with same question deleting duplicate rows based on three columns in Oracle 8i

  • How to change colors of individual column bar in the same data series

    in mac numbers, how to change colors of individual column bar in the same data series. The entire column series gets selected in the column bars and cannot select to change colors of specifc bars.

    Hi Kiran,
    no its not possible through Theme editor also ,because these colors are coming from Compiler which u are using.
    Regards,
    Govindu

  • Apply distinct to all the columns in a select list

    Select distinct name, date , venue , duration from tableA
    the above query distinct onlu the first column in the select list but is it possible to distinct all the columns.
    current out put is
    1 , raj, 25-may-2009, uk , 10
    1 , raj, 25-may-2009, usa , 10
    1 , raj, 25-may-2009, uk , 20
    requried output....
    1 , raj, 25-may-2009, uk , 10
    the first found row is enogh...
    thanks in advance :)
    raj

    But all these tree rows are distinct. Doesn't it? Why you want to take only first row? What's the logic?
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Access data from from two lists based on lookup columns and insert into another

    Hi,
    I am new in SharePoint and is stuck in some problem.
    I want to insert data in to a list by fetching data from 2 lists.
    The scenario is :
    List A Columns : EmployeeName, EmployeeID, EmployeeSalary 
    List B Columns : DepartmentName, EmployeeID, ManagerID
    EmployeeID is lookup column 
    I want to fetch data from these 2 lists and insert data into another list:
    List C Columns: EmployeeName, EmployeeSalary, DepartmentName 
    Can someone please explain me all the possible approaches to do the above task

    If ListA and ListB are the lists that you created, it would be better to generate the lists data into one list not seperate lists, as they both represents the property information of one employee.
    If they are existing lists, you may have following considerations:
    1. if you are a programmer, it would be easier to have a lookup column at ListA, to generate the EmployeeName, EmplyeeSalary, then using ItemAdded event, to generate the DepartmentName column based on EmployeeID column.
    2. have a lookup column look at ListA, use workflow, set when item is created, start the workflow automatically, then in the workflow, find ListB related item based on EmployeeID column, to set the DepartmentName column, SharePoint designer workflow
    set Item Value activity can do this work, you can research to find more information about how to do this.
    Thanks,
    Qiao Wei <br/> My blog:http://blog.goobol.com

  • Distinct values in each column

    Hi
    I have a table with three columns and I would like to display distinct values in each column. Could any one please help me to get the output.
    col1     col2     col3
    ====     ====     ====
    a     1     x     
    a     2     y
    a     3      z
    a     4      u
    b     5      v
    b     6      x
    b     7      x
    b     9      x
    b     10     y
    b     11     y
    b     12     y
    b     13     y
    b     14     x
    b     15     y
    b     16     z
    b     17     u
    b     18     v
    b     19     x
    b     20     x
    c     21     x
    c     22     y
    c     23     y
    c     24     y
    c     25     y
    c     26     x
    c     27     y
    c     28     z
    Output needed
    ===========
    col1     col2     col3
    ====     ====     ====
    a     1     x
    b     2     y
    c     3     z
         4     u
         5     v
         6
         7
         9
         10
         11
         12
         13
         14
         15
         16
         17
         18
         19
         20
         21
         22
         23
         24
         25
         26
         27
         28
    Thanks
    Vasanth

    but the only drawback - you need to know the column, comprising the biggest amount of distinct values beforehand.No. There is no any difference in which column will be chosen as "based".
    For demo purposes I've added extra row number column to show full generality and symmetry of the approach:
    exec dbms_random.seed(0)
    with t as ( select chr(ascii('a') + dbms_random.value(0, 3)) as c1,
                       trunc(dbms_random.value(1, 20))           as c2,
                       chr(ascii('u') + dbms_random.value(0, 6)) as c3
                  from dual connect by level <= 20
       tt1 as ( select lag(          null,  1, c1) over (partition by c1 order by null) as c1,
                       lag(to_number(null), 1, c2) over (partition by c2 order by null) as c2,
                       lag(          null,  1, c3) over (partition by c3 order by null) as c3
                  from t
       tt2 as ( select tt1.*,
                       row_number() over (order by c1) as rn1,
                       row_number() over (order by c2) as rn2,
                       row_number() over (order by c3) as rn3,
                       rownum rn
                  from tt1
       tt3 as ( select case when rn1 > rn
                            then last_value(c1) over (order by rn1 range between abs(rn1 - rn) preceding
                                                                             and abs(rn1 - rn) preceding)
                            else last_value(c1) over (order by rn1 range between abs(rn - rn1) following
                                                                             and abs(rn - rn1) following)
                       end as c1,
                       case when rn2 > rn
                            then last_value(c2) over (order by rn2 range between abs(rn2 - rn) preceding
                                                                             and abs(rn2 - rn) preceding)
                            else last_value(c2) over (order by rn2 range between abs(rn - rn2) following
                                                                             and abs(rn - rn2) following)
                       end as c2,
                       case when rn3 > rn
                            then last_value(c3) over (order by rn3 range between abs(rn3 - rn) preceding
                                                                             and abs(rn3 - rn) preceding)
                            else last_value(c3) over (order by rn3 range between abs(rn - rn3) following
                                                                             and abs(rn - rn3) following)
                       end as c3
                  from tt2
    select c1, c2, c3 from tt3
      where c1 || c2 || c3 is not null
      order by c1, c2, c3
    C1            C2 C3
    a              1 u
    b              3 v
    c              4 w
                   5 x
                   7 y
                   8 z
                   9
                  11
                  13
                  15
                  16
                  17
                  19
    13 rows selected.P.S. Thanks to [url http://www.sql.ru/forum/actualthread.aspx?bid=3&tid=482506&hl=over+range#4785373]Vladimir Sitnikov for the demo of the approach.

  • Eliminate Data based on a column

    Hello All,
    I am in very weird situation. I have to filter data based on a column. For example, my data is like :
    Col1       Col2        Col3       Col4
    A1         A              B           C
    A2         A              B            D
    A3         A              B            E
    F           G              H             I
    J            K               L             M
    I have to filter data based on col1 which has the maximum if Col2 and Col3 have same value. So the o/p of above data will be  if (A3> A2 > A1) as  Col2 and Col3 have same value A and B:
    Col1       Col2            Col3       Col4
    A3             A              B            E
    F              G               H             I
    J               K               L             M
    Please suggest.

    Hi,
    One way to do that is a Top-N Query .  Since you didn't post your table, I'll use scott.emp to illustrate.  Ename, deptno, job and hiredate in scott.emp correspond to col1, col2, col3 and co4l (respectively) in your table.
    WITH got_r_num AS
    SELECT ename, deptno, job, hiredate
    , ROW_NUMBER () OVER ( PARTITION BY  deptno, job
                   ORDER BY      ename   DESC
           ) AS r_num
    FROM scott.emp
    SELECT ename, deptno, job, hiredate
    FROM got_r_num
    WHERE r_num  = 1
    The query above displays only 1 row for each distinct combination of deptno and job, the row with the last ename.

  • "How to get distinct values of sharepoint column using SSRS"

    Hi,
        I have integrated sharepoint list data to SQL Server reporting services. I am using the below to query sharepoint list data using sql reporting services.
    <Query>
       <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
       <Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
          <Parameters>
             <Parameter Name="listName">
                <DefaultValue>{GUID of list}</DefaultValue>
             </Parameter>
             <Parameter Name="viewName">
                <DefaultValue>{GUID of listview}</DefaultValue>
             </Parameter>
             <Parameter Name="rowLimit">
                <DefaultValue>9999</DefaultValue>
             </Parameter>           
          </Parameters>
       </Method>  
    <ElementPath IgnoreNamespaces="True">*</ElementPath>
    </Query>
    By using this query, I am getting a dataset which includes all the columns of sharepoint list. Among these columns, I wanted to display only 2 columns (i.e Region and Sales type) using chart. I have created a Region parameter but when I click preview, the drop down box is giving me all the repeatative values of region like RG1,RG1,RG1,RG2,RG2,RG2,RG2,RG3.......... I wanted to display only distinct values of Region parameter so that whenever end user select region from the parameter drop down, it will display the respective value of Sales type column.
    Also when I select only RG1 parameter, it is giving me a chart including the sales type of all the Regions. (it should display me only the sales type of RG1) How can I link these 2 columns so that they will display the values respectively.
              I would really appreciate if anyone can help me out with this.
    Thanks,
    Sam.

    Hi Sam,
    By code, the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results.
    In this case, we could use the custom code to get distinct records.
    Here are the detailed steps:
    1.         Create a hidden parameter that gets all the records in one field.
    Note: Please create another dataset that is same of the main dataset. This dataset is used for the parameter.
    2.         Create a function that used to remove the duplicate records.
    Here is the code:
    Public Shared Function RemoveDups(ByVal items As String) As String
    Dim noDups As New System.Collections.ArrayList()
    Dim SpStr
    SpStr = Split(items ,",")
    For i As Integer=0 To Ubound(Spstr)
    If Not noDups.Contains(SpStr(i).Trim()) Then
    noDups.Add(SpStr(i).Trim())
    End If
    Next
    Dim uniqueItems As String() = New String(noDups.Count-1){}
    noDups.CopyTo(uniqueItems)
    Return String.Join(",", uniqueItems)
    End Function
    3.         Create another parameter that will be used for filtering the maindata.
    Please set the available value to be =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",")
    And the default value to be the value you what such as the first value:
    =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",").(0)
    4.         Go to the main dataset. Open the property window of this dataset.
    5.         In the “Filters” tab, set the filter to be:
    Expression: <The field to be filter>
    Operator: =
    Value: =Parameters!Region.Value
    The parameter “Region” should be the parameter we created in the step3.
    Now, we should get distinct values of SharePoint columns.
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jin
    Jin Chen - MSFT

  • How to filter the Rest Api data based on Taxanomy columns

    Hi Everyone,
    We are using SharePoint2010 Standard Edition.
    I wanted get the library details through REST Api. I am using as below:
    https://SiteUrl/_vti_bin/listdata.svc/Documents?$filter=Title eq 'SharePointDoc'
    Here I am able to get the info regarding "SharePointDoc". But when I am trying to get the details from Taxonomy filter, it didn't.
    Can anyone please tell me how can we filter based on Taxanomy fields.
    Thanks in Advance
    Krishnasandeep

    Hi,
    I understand that you wanted to filter the Rest Api data based on Taxanomy columns.
    Per my knowledge, in SharePoint 2010 , not all types of column are available via REST, most annoyingly managed metadata columns are amongst this group of unsupported column types.
    However, in SharePoint 2013, we can filter list items based on taxonomy (managed metadata) columns.
    Taxonomy fields can be now called via REST API using CAML query in REST calls.
    Here is a great blog for your reference:
    http://www.cleverworkarounds.com/2013/09/23/how-to-filter-on-a-managed-metadata-column-via-rest-in-sharepoint-2013/comment-page-1/
    You’d better to change the REST calls and the CAML query to check whether it works in SharePoint 2010.
    More information:
    http://platinumdogs.me/2013/03/14/sharepoint-adventures-with-the-rest-api-part-1/
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Is it possible to switch the rows and columns?

    Is it possible to switch the rows and columns of a table? The reason I ask is that it would be easier for me to input the data with the number at the top of a column and the fields going down. But it would be easier to read the data with the number on the left and the fields going to the right. Is it possible to switch a table in this way?

    mahongue wrote:
    Is it possible to switch the rows and columns of a table? The reason I ask is
    that it would be easier for me to input the data with the number at the top
    of a column and the fields going down. But it would be easier to read the
    data with the number on the left and the fields going to the right. Is it
    possible to switch a table in this way?
    It sounds to me as though you wish to transpose a table so that the original is changed from rows to columns and from columns to rows, as in the following:
    Table 1
        A   B   C
    ========
    1   o   p   q
    2   r   s   t
    3   u   v   w
    Table 2
        A   B   C
    ========
    1   o   r   u
    2   p   s   v
    3   q   t   w
    You are right - it would be nice to have a menu item to magically transpose a selected block of cells. But there isn't one. So...
    One way to solve this is to use the index() and transpose() functions to accomplish row and column cell transposition. If you are going to use a 1:1 cell correspondence and change the header columns and rows also, you can use this:
       =INDEX(TRANSPOSE(Table # :: <range>),ROW(),COLUMN())
    where Table # and <range> is substituted as in the following fashion:
       =INDEX(TRANSPOSE(Table 1 :: $A$1:$C$3),ROW(),COLUMN())
    Create a second table. Copy the modified formula above with the appropriate substitutions, select the range you wish to have your transposition inserted into (must match the transposed cell dimensions of the original range), paste the forumula and voila! the cells will be transposed.
    Cautions:
    o The target table must match the swapped cell length and width dimension. For example, if the original data range is 6 columns wide by 4 rows deep, then the corresponding table or range to hold the transposition must be 4 columns wide by 6 rows deep.
    o If your transposed data block is to be offset from the origin of the new table, then you will need to include a subtractive offset into your cell formula, since in the transpose() function the data in the master data range is referenced from its position with the master range, not its cell position in the table. Such an offset is necessary because this example formula uses the target row and column numbers to arrive at indexed positions.
    For example, if the new data range is to be offset one column to the right and one row below from the target table's origin then you must subtract (-1) from the cell and from the column references in the formula:
      Example:
      =INDEX(TRANSPOSE(Table 3 :: $B$2:$D$4),ROW()-1,COLUMN()-1)
    If someone has a better solution I'd be glad to hear of it.

  • Creating a dynamic lov based on a column

    Hi,
    I want to create a dynamic lov based on a column in a database-table.
    Eg. the query
    'select code, description from code_table'
    is the contents of the column 'lov_query' in the table 'parameters'.
    For every parameter there can be a different lov-query, but the result is always
    two columns (code and description, number and name, etc.), exactly what you need to use in a lov.
    I've written a (dbms_sql) function that takes the parameter-id and returns the lov_query.
    create or replace function "GET_PMR_LOV"
    (pmr_id in NUMBER)
    return VARCHAR2
    is
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    l_pmr_id NUMBER(9) := pmr_id;
    l_stmnt VARCHAR2(2000);
    begin
    DBMS_SQL.PARSE
    (cur, 'select pmr.lov_query from parameters pmr where pmr.ID ' || ' = 'L_PMR_ID', DBMS_SQL.NATIVE);
    DBMS_SQL.BIND_VARIABLE (cur, 'L_PMR_ID', l_pmr_id);
    DBMS_SQL.DEFINE_COLUMN (cur, 1, l_stmnt, 2000);
    fdbk := DBMS_SQL.EXECUTE (cur);
    fdbk := DBMS_SQL.FETCH_ROWS (cur);
    IF fdbk > 0
    THEN
    DBMS_SQL.COLUMN_VALUE (cur, 1, l_stmnt);
    return (l_stmnt);
    ELSE     
    return null;
    END IF;
    DBMS_SQL.CLOSE_CURSOR (cur);
    END;
    But now I'm stuck on how to pass on this statement in HTMLDB
    as an dynamic lov, I don't seem to be able to execute this statement
    into the two display and return columns. Any ideas?

    Hello again,
    This lov is on an updatable report-column where the user has to make a choice from an non-named, popup and query-based lov. In the lov-query box I have just put:
    "return get_pmr_lov(:p41_param_id)" (without the quotes ;-)
    Here's my latest version plus an alternative, which both seem to work fine:
    create or replace function "GET_PMR_LOV"
    (pmr_id in NUMBER)
    return VARCHAR2
    is
    cur INTEGER := DBMS_SQL.OPEN_CURSOR;
    fdbk INTEGER;
    l_pmr_id NUMBER(9) := pmr_id;
    l_stmnt VARCHAR2(1000);
    begin
    DBMS_SQL.PARSE (cur, 'select pmr.lov_query from paramaters pmr where pmr.ID ' || '= :L_PMR_ID', DBMS_SQL.NATIVE);
    DBMS_SQL.BIND_VARIABLE (cur, 'L_PMR_ID', l_pmr_id);
    DBMS_SQL.DEFINE_COLUMN (cur, 1, l_stmnt, 1000);
    fdbk := DBMS_SQL.EXECUTE (cur);
    fdbk := DBMS_SQL.FETCH_ROWS (cur);
    IF fdbk > 0 THEN
    DBMS_SQL.COLUMN_VALUE (cur, 1, l_stmnt);
    return (l_stmnt);
    ELSE
    return null;
    END IF;
    DBMS_SQL.CLOSE_CURSOR (cur);
    END;
    create or replace function "GET_PMR_LOV2"
    (pmr_id in NUMBER)
    return VARCHAR2
    is
    l_pmr_id NUMBER(9) := pmr_id;
    l_stmnt VARCHAR2(1000);
    BEGIN
    EXECUTE IMMEDIATE 'select pmr.lov_query from parameters pmr where pmr.ID = :1'
    INTO l_stmnt USING l_pmr_id;
    return l_stmnt;
    END;
    The error-message remains the same, unable to bind :p41_param_id !

Maybe you are looking for

  • Is it possible to run garbage collector in publisher instance with out opening a tunnel?

    Hi, In General we are running garbage collector in publisher by opening a tunnel. is there any alternate way to do that. we installed adobe cq5 on solaris10. thanks, vidhyadhar

  • Instanceof operator treatment

    Hi I am new bie in java, Following is my code. public class Test {     public static void main(String[] args) {         Test test = new Test();         System.out.println(test instanceof T);         System.out.println(test instanceof I); interface I

  • I am trying to download photoshop elements 11. The serial# is 30 digits my comp only accepts 29, hel

    II am trying to download Photoshop Elements 11 into my computer, I have other programs entered already. My computer will only allow a max of 29 digits and this sofyware is 30 digits. Help.

  • Bapi for updation of table VBRP

    Hi, I have to Update the Field 'KONDM' in the table VBRP. Is there some BAPI available for updating VBRP or we can have to go with the direct Update to the table. I have to Update this field by a stand alone report program. Thanks and regards, Pankaj

  • [SOLVED]netctl not connected

    wireless-wpa profil file; Description='A simple WPA encrypted wireless connection' Interface=wlp20s0 Connection=wireless Security=wpa IP=dhcp ESSID='TD-W8101G_1' # Prepend hexadecimal keys with \" # If your key starts with ", write it as '""<key>"' #