PL/SQL Query return function, adding the column links

Hi all

I'm working on a SQL report with the area type = function from PL/SQL Query to return
All columns are generated dynamically based on my mapping table and a column of ID.
So whenever the page is loaded, according to the ID mapping table returns a set of columns in a particular order.
So not only the columns are dynamic, but the order of the columns varies also.
But the first 1 column is standard (it doesn't come from the mapping table) and is coded in my pl/sql block hard.

I'm fighting with the addition of a link to this column. The link must be a Javascript function which takes the parameters in the form of 2 columns in the mapping table.
My pl/sql block is something like that...
v_select := 'SELECT <g href=javascript:f_report1(#map_id#,#comments#)><img src=""></a> as report1, ';  // g=a
v_cols := 'contains all columns from the mapping table based on a ID(hidden item)';
v_from := 'FROM table';
v_where := 'where condition is put in here';
v_query := v_select||v_from||v_where;
return v_query;
Now, I'm not able to transmit the values of this #map_id # and #comments # correctly. I tried so many different combinations of channels, but could not make it work.

I'm not sure that the order of this map_id and commentscolumn and therefore cannot connect through the report attributes.
How can I go to a column value to the function?



Thank you
Dippy

This should work if all goes well:

v_select := q'[ SELECT '' as chart, ]';

Published by: Dimitri Gielis on May 20, 2010 20:10

Tags: Database

Similar Questions

  • How to identify columns that have the same data in a SQL query or function?

    Deal all,

    How to identify columns that have the same data in a SQL query or function? I have the sample data as below

    DEPT_IDEMP_IDCome on
    !CITYSTATECOUNTRY111 June 1983DELHIHUMAN RESOURCESIndia1218 January 1987DELHIHUMAN RESOURCESIndia1328 November 1985DELHIHUMAN RESOURCESIndia144 June 1985DELHIHUMAN RESOURCESIndia255 June 1983MUMBAIHDIndia266 June 1983MUMBAIHDIndia277 June 1983MUMBAIHDIndia288 Jun. 1983MUMBAIHDIndia399. June 1983GURGAONDLIndia31010 June 1983GURGAONDLIndia

    Now, I want to Indify columns that have the same data for the same Department ID.

    Is it possible in sql unique or do I have to write the function for this? Pls Help how to write?

    Thanks in advance.

    You can try this?

    WITH T1)

    DEPT_ID, EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY

    ), ()

    SELECT 1, 1, TO_DATE('1.) June 1983', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 2, TO_DATE('18.) January 1987', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 3, TO_DATE('28.) November 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 4, TO_DATE('4.) June 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.5, TO_DATE('5.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.6, TO_DATE('6.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.7, TO_DATE('7.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.8, TO_DATE('8.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 3, 9, TO_DATE('9.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DUAL UNION ALL

    SELECT 3.10, TO_DATE('10.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DOUBLE)

    SELECT DEPT_ID,

    RTRIM (XMLAGG (XMLELEMENT(A,VALS||',')). Extract ('//Text ()'), ',') COLUMNS_WITH_DUPLICATE

    DE)

    SELECT * FROM)

    SELECT DEPT_ID,

    EMP_ID,

    Date of birth

    CITY,

    STATE,

    COUNTRY

    DE)

    SELECT DEPT_ID,

    EMP_ID,

    Date of birth

    CITY,

    STATE,

    COUNTRIES,

    COUNT (*) OVER(PARTITION BY DEPT_ID ORDER BY EMP_ID DESC,DOB DESC,CITY DESC,STATE DESC, COUNTRY DESC) RN

    DE)

    SELECT DEPT_ID,

    CASE WHEN(CEID>1) AND THEN 'YES' ELSE 'NO' END AS EMP_ID.

    CASE WHEN(CDOB>1) THEN 'YES' ELSE 'NO' END AS DATE OF BIRTH,

    CASE WHEN(CCITY>1) AND THEN 'YES' ELSE 'NO' END AS CITY.

    CASE WHEN(CSTATE>1) AND THEN 'YES' ELSE 'NO' END AS STATE.

    CASE WHEN(CCOUNTRY>1) THEN 'YES' ELSE 'NO' END AS A COUNTRY

    DE)

    SELECT DISTINCT

    DEPT_ID,

    CEID,

    CDOB,

    CITY,

    CSTATE,

    CCOUNTRY

    DE)

    SELECT DEPT_ID,

    COUNT (*) TO THE CEID (DEPT_ID PARTITION, EMP_ID),.

    COUNT (*) ON CDOB (DEPT_ID SCORE, DATE OF BIRTH),

    COUNT (*) ON THE CITY (DEPT_ID PARTITION, CITY),

    COUNT (*) ON CSTATE (DEPT_ID PARTITION, STATE).

    COUNT (*) ON CCOUNTRY (DEPT_ID, COUNTRY PARTITION)

    FROM T1)))

    WHERE RN = 1)

    UNPIVOT (CLO FOR (VALS) IN (EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY)))

    WHERE COLS = "YES".

    DEPT_ID GROUP;

    OUTPUT:

    DEPT_ID COLUMNS_WITH_DUPLICATE
    --------- ------------------------

    1 CITY, COUNTRY, STATE
    2 CITY, COUNTRY, STATE
    3 CITY, COUNTRY, STATE

    Post edited by: Parth272025

  • SQL query for data of the quarter... Help, please

    Dear Experts,

    Please help with this query...

    I have data as below:

    YearQuarterMRRMORR %
    -------------------
    20121ST QUARTER10
    Q230
    Q350
    Q460
    20131ST QUARTER20
    Q230

    Now I need to caluclate MORR % as column values below

    for 2012 T2 MRR % = (Q2MRR-Q1MRR) / (30-10) Q1 * 100 / 10 * 100

    for 2012, T3 MRR % = (Q4MRR-Q3MRR) / Q2 * 100

    for 2012 T4 MRR % = (Q1MRR-Q4MRR) / Q1 * 100 here q1 2013 and the 4th quarter of 2012...

    like this he wll go...

    Please help with me query calculate values in the column % MRR.

    Best regards

    ASP.

    Maybe NOT TESTED! No database at your fingertips

    Select the year, quarter, mrr,.

    ratio_to_report (q_mrr) on pct_mrr (partition by order of the year by quarter)

    (select the year, quarter, mrr,)

    MRR - lag (mrr, 1, 0) on q_mrr (partition by order of the year by quarter)

    t

    )

    Concerning

    Etbin

  • function body pl/sql return SQL query - if with in the select statement

    Hi all

    I have a condition where, when the summary field is checked, only we see the this column for users in the report. IF statement is possible in this case? I gave the code below... is possible to write something like below, or y at - it another way to do it?

    \
    v_sql: = ' select TBLCASES. INVESTIGATOR as an INVESTIGATOR,';
    v_sql: = v_sql | "TBLCASES. CASENUMBER as CASENUMBER,';
    v_sql: = v_sql | "TBLCASES. OPENDATE as OPENDATE,';
    v_sql: = v_sql | "TBLCASES. ESTCOMPLETE as DATE_CIBLE,';
    v_sql: = v_sql | "TBLCASES. STATUS of STATUS ';
    v_sql: = v_sql | "TBLCASES. Case CODE case CODE as,';
    v_sql: = V_sql | "TBLCASES. FAIR_HOTLINE as FAIRHotline,';
    v_sql: = v_sql | "TBLCASES. NYSIG as NYSIGCase,';
    v_sql: = v_sql | "TBLCASES. The REGION';

    IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
    v_sql: = v_sql | "TBLCASES. SUMMARY,';
    END IF;

    v_sql: = v_sql | "TBLCASES. PROGAREA as PROGArea ';
    v_sql: = v_sql | ' from TBLCASES where 1 = 1';
    .. \

    Hi Lucie,.

    You are adding and removing a column in a report, so it may be useful to have the extra on the end of the query.
    You get an error? If so, paste it in...

    BUT - that I would put a condition on the column where ': P44_INCLUDE_SUMMARY_FIELD is not null '
    It under 'Attributes of the column' report select the change column icon, and there a breadcrumb "Condition."
    Select "In Expression 1 point value is not Null" and put the P44_INCLUDE_SUMMARY_FIELD in the Expression 1 text box.

    And I have to make it more readable like that when I do the dynamic SQL code:
    IF: P44_INCLUDE_SUMMARY_FIELD is not null THEN
    v_INCLUDE_SUMMARY_FIELD: = ' TBLCASES. SUMMARY summary ';
    END IF;

    v_sql: = ' select TBLCASES. RESEARCHER, researcher,
    TBLCASES. CASENUMBER as CASENUMBER
    TBLCASES. OPENDATE as OPENDATE,
    TBLCASES. ESTCOMPLETE as DATE_CIBLE,
    TBLCASES. STATUS of STATUS,
    TBLCASES. Case CODE case CODE as,
    TBLCASES. FAIR_HOTLINE as FAIRHotline,
    TBLCASES. NYSIG as NYSIGCase,
    TBLCASES. REGION as the region,
    TBLCASES. PROGAREA as PROGArea,' |
    v_INCLUDE_SUMMARY_FIELD |
    ' from TBLCASES where 1 = 1; ';

    It will be useful,
    BRITISH COLUMBIA

  • 'Function SQL Query return' using with Flash graphics

    I created a pl/sql function that returns a SQL query in a varchar2 of this form:

    Select the null link
    -value > < x value
    < value y of Series1 > series 1 label
    < value Series2 y > 2 series label
    < value of y Series3 > series 3 Label
    ...
    ...
    from tablea a
    Join tableb b
    On a.col = b.col
    order of < x value >

    If I call the function of a graphic Flash box series SQL with the Type of Source query "SQL query" value that returns the function like this:

    return functionname (to_date ('30-sep-2010, ' mon-dd-yyyy ""))

    It parses correctly and the page is saved; However, when I run the page I get no output - error messages or another indication of a problem.

    Now, if I call the function in a SQL client, capture the result of the query SQL using the dbms_output and paste that into the box graphic Flash series SQL - change the Source Type of SQL query query - and save the page it works fine when I run it and returns a chart series flash.

    Can anyone suggest either;

    1. what I might have missed or done wrong?
    2. a way to effectively diagnose the problem...

    I tried to use the debugger Apex - what is very nice, indeed - but it provides no information on what might be my problem. I tried to write my own my function debug messages using the apex_debug_message package - nothing...

    Thank you
    Eric

    Hi Eric,.

    Try to pull the source like this:

    begin
       return functionname(to_date('30-sep-2010', 'dd-mon-yyyy'));
    end;
    

    This works very well for me, and if I take the begin-end and the final semicolon from the return statement I get the same behavior as you.

    He doesn't mention in aid of the source (only during the wizard if) this source type must be expressed in this way, but I agree, it would be useful that the tool would validate to this format meets it "Query SQL that returns the function" or give some sort of indication of the sentence. In any case, this should help you will again.

    Hope this helps,
    John

    If you find this information useful, please do not forget to mark the 'useful' or 'correct' post so that others benefit as well.

  • reload the page when SQL query returns a value

    Hello world

    the title of this discussion may seem strange, but I'll try to explain why I need this:

    A user has the ability to connect on my APEX application. There are several tabs in my application that are visible only if a certain SQL statement returns a value which is not the case by default. The user has also the ability to download a file that is transferred to an external system that analyzes the file and writes the data in the database. During this writing process - which may take several minutes - conditions for some of the tabs to show the will becomes real (-> the query will return a value). When the user refreshes the page manually, the tabs will be displayed. However, I want the tabs will appear automatically when the condition is met.

    Is it possible to refresh the page as soon as the query returns a value? It is perhaps possible to check it on the client side and trigger a refresh of the page when the condition is met. It would be even better if only the tabset has been updated, but refreshing the full page is fine as well.

    Thank you!

    Here is an overview of how it can be done

    This is possible thanks to a dynamic action being performed on a timer.

    View default tabs and dynamic action hide them on loading the page if they are not to be considered

    Create a dynamic action that will execute your query every 5 seconds or more

    If the query returns data, you can use the dynamic action to show your tabs using javascript

  • Production PL/SQL query: can not find the error

    I have a PL/SQL which produces a query for me, which is used to fill out a report. I use this to supply a filter/search form. Since I want to only filter using xxx movies WHERE = yyy when yyy actually has something else NULL, I use a PL/SQL script in the query I need to produce. However, it does not work as expected and I can't understand why. Here is my code:
    DECLARE
      query VARCHAR(1000);
    BEGIN
      query := 'SELECT * FROM F_OBJEKTE WHERE 1=1 ';
      IF :P15_REGION != null THEN
        query := query || 'AND REGION = :P15_REGION ';
      END IF; 
      RETURN query;
    END;
    However, the report still contains all lines, as if P15_REGION has not been defined - and so I guess that the script never enters the IF part. Everyone around who can enlighten me, why it is?

    Just another little thing: is there a way I can print debugging messages I see when I press the "Debug" button on the lower bar of APEX? It would help a lot of debugging such PL/SQL functions.

    Try changing

    IF: P15_REGION! = null THEN

    TO

    IF: P15_REGION is not null THEN

  • pl/sql - sql query return

    Hi all... I hope someone can help.
    Worked a lot to solve this problem, but I can't find a solution.
     
    DECLARE
         lv_sql VARCHAR(32767);
         lv_pivot_cols VARCHAR2(1000);
    BEGIN
         FOR i IN (SELECT DISTINCT comp_name, pro_name FROM  cat_attributes order by comp_name)
         LOOP
              lv_pivot_cols := lv_pivot_cols ||'('||''''||i.comp_name||''''||','|| '''' || i.pro_name ||''''||')'||',';
         END LOOP;
         lv_pivot_cols := RTRIM(lv_pivot_cols,',');
    
         lv_sql := 'SELECT * FROM
         (SELECT position,cat_id, att_name as ATTRIBUTE, pro_name, value,comp_name
         FROM   cat_attributes )
    PIVOT (
                        max (value)
                        FOR (comp_name,pro_name) IN (' ||lv_pivot_cols||')) where cat_id=:P1100_CHOOSE_CATEGORY order by position';
            
         RETURN lv_sql;                    
         --DBMS_OUTPUT.PUT_LINE(lv_sql);
    END;
    the code above works well, but I want to add a where condition in the separate statement, which depends on an element of the apex.
    as:
    SELECT DISTINCT comp_name, pro_name FROM  cat_attributes where  cat_id=:P1100_CHOOSE_CATEGORY order by comp_name 
    But if an add this condition got
    error report: ORA-01403: no data found
    any suggestions?


    I would also like to change the size of characters max column header. now, it may be only * 30 * characters for the column header. is there a possibility to raise it?

    Thanks for all your suggestions

    Hello

    Hmm. Is the value of ': P1100_CHOOSE_CATEGORY ' in Session State?

    In this case, would be the usual suspect: ": P1100_CHOOSE_CATEGORY" has no value in Session State. You said if she had a value in Session State?

    Now, someone might say, "well, the other query work it must have a value in Session State! Well, maybe. But might work work with null query ': P1100_CHOOSE_CATEGORY '?? If it is null, then get the value stored in the Session State.

    Howard

  • SQL query returns no row vs. multiple lines

    Hello

    I am trying to get the result of a simple sql query,
    If there is no row returned, he would have "No. ROWS" in the result set.
    Other wise all the rows containing data is necessary.

    Let me know how this could be achieved. Under query works for the latter and not first case as mentioned below

    OUTPUT

    + (box 1) when we use B_ID = 123456 +.

    IDS
    -----
    'NO LINE '.

    + (box 2) when we use B_ID = 12345 +.
    IDS
    -----
    1 11112345
    2 22212345
    create table TEMP_AAA
    (
      A_ID VARCHAR2(10),
      B_ID VARCHAR2(10)
    )
    
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('111','12345');
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('222','12345');
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('333','12000');
    INSERT INTO TEMP_AAA(A_ID,B_ID) VALUES('444','10000');
    WITH 
    MATCH_ROWS AS
    (
           SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE B_ID=12345
    ),
    
    MATCH_ROW_COUNT AS
    (
           SELECT COUNT(1) AS COUNTS FROM MATCH_ROWS
    ),
    
    PROCESSED_ROWS AS
    (
           SELECT
                 CASE WHEN COUNTS = 0
                      THEN 
                       (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID=12345),'NO ROWS') IDS FROM DUAL)
                      ELSE
                       MATCH_ROWS.IDS
                 END IDS     
            FROM MATCH_ROWS,MATCH_ROW_COUNT
    )
    
    SELECT * FROM PROCESSED_ROWS;

    Hello

    I think you want to put this on a report or something. I have what would be easier to do this logic there. But if you want that this is possible.
    Like this

    with
    temp_aaa as
    (select '111' a_id ,'12345' b_id from dual union all
    select '222'      ,'12345'  from dual union all
    select '333'      ,'12000'  from dual union all
    select '444'      ,'10000'  from dual
    )
    , wanted_rows as
    ( select  '123456' B_ID from dual)
    select
      temp_aaa.A_ID || temp_aaa.B_ID IDS 
    
    from
      temp_aaa
      ,wanted_rows
    where
      temp_aaa.b_id = wanted_rows.b_id
    union all
    select
      'NO ROWS'
    FROM
      DUAL
    WHERE
      (SELECT COUNT(*) FROM TEMP_AAA, wanted_rows WHERE TEMP_AAA.B_ID = wanted_rows.B_ID) = 0
    

    In addition, you mix var and number of always use the same type or convert explicitly (to_number or to_char)

    WITH
    MATCH_ROWS AS
    (
           SELECT A_ID||B_ID IDS FROM TEMP_AAA WHERE      B_ID           =12345
    --                                                    varchar2(10)   number
    ),
    ...
    

    And again in the

                      THEN
                       (SELECT NVL((SELECT IDS FROM TEMP_AAA WHERE B_ID           =12345),'NO ROWS') IDS FROM DUAL)
    --                                                             varchar2(10)   number
    

    Kind regards

    Peter

  • Help please SQL... Adding a column of total accumulated in a table

    Tonight... I have the task of adding a column of total cumulative to a table that contains a list of transactions. The table contains entries for several accounts.

    for example

    create the table adam_test1
    (
    account char (4),
    date of entry_date,
    amount number 4,
    Balance number 4
    );


    insert into adam_test1 values ('1000', January 1, 2000 ", 50", null);
    insert into adam_test1 values ('1000', January 2, 2000 ', 40', null);
    insert into adam_test1 values ('1000', 3 January 2000', '-50', null ");
    insert into adam_test1 values ('1000', January 4, 2000 ', 10', null);
    insert into adam_test1 values ('1000', 5 January 2000', '-250', null ");
    insert into adam_test1 values ('1000', January 6, 2000', '100', null);
    insert into adam_test1 values ('1000', January 7, 2000 ", 50", null);

    insert into adam_test1 values ('2000,' 1 January 2000 ', 30', null);
    insert into adam_test1 values ('2000', January 2, 2000 ', 10', null);
    insert into adam_test1 values ('2000', 3 January 2000', '-520', null ");
    insert into adam_test1 values ('2000', January 4, 2000', '140', null);
    insert into adam_test1 values ('2000', 5 January 2000', '-4', null ");
    insert into adam_test1 values ('2000', January 6, 2000 "," 120", null);
    insert into adam_test1 values ('2000', January 7, 2000 ', 57', null);


    SQL > select * from adam_test1;

    ACCO ENTRY_DAT BALANCE AMOUNT
    ---- --------- ---------- ----------
    1000 1 JANUARY 00 50
    1000 2 JANUARY 00 40
    1000 3 JANUARY 00-50
    1000 4 JANUARY 00 10
    1000 5 JANUARY 00-250
    1000 6 JANUARY 00 100
    1000 7 JANUARY 00 50
    2000 1 JANUARY 00 30
    2000 2 JANUARY 00 10
    2000 3 JANUARY 00-520
    2000 4 JANUARY 00 140
    2000 JANUARY 5, 00-4
    2000-6 JANUARY 00 120
    2000-7 JANUARY 00 57

    .. I tried a few things to fill the values using rowid, but I was not able to get anything to work - ideas?
    Thank you!
    Adam

    Use MERGE:

    merge
      into  adam_test1 t1
      using (
             select  rowid,
                     sum(amount) over(partition by account order by entry_date) balance
               from  adam_test1
            ) t2
      on (t1.rowid = t2.rowid)
      when matched
        then
          update set t1.balance = t2.balance
    /
    
    ACCO ENTRY_DAT     AMOUNT    BALANCE
    ---- --------- ---------- ----------
    1000 01-JAN-00         50         50
    1000 02-JAN-00         40         90
    1000 03-JAN-00        -50         40
    1000 04-JAN-00         10         50
    1000 05-JAN-00       -250       -200
    1000 06-JAN-00        100       -100
    1000 07-JAN-00         50        -50
    2000 01-JAN-00         30         30
    2000 02-JAN-00         10         40
    2000 03-JAN-00       -520       -480
    2000 04-JAN-00        140       -340
    
    ACCO ENTRY_DAT     AMOUNT    BALANCE
    ---- --------- ---------- ----------
    2000 05-JAN-00         -4       -344
    2000 06-JAN-00        120       -224
    2000 07-JAN-00         57       -167
    
    14 rows selected.
    
    SQL> 
    

    SY.

  • SQL + reel, white space in the columns, help.

    Hi all.

    I use SQL on Oracle Database 10g Enterprise Edition Release 10.2.0.3.0

    I have a massive script that I am wanting to wrap the output to a text file.

    I have more than 600 columns and the script is like:

    set the position
    trigger the echo
    Set feedback off
    set verify off
    Set serveroutput off
    termout off Set
    Set trimout on
    Set trimspool on
    tab set to
    NewPage 0 value
    set space 0
    set linesize 6251
    set pagesize 0
    the null value 0
    define array 1000
    the value of colsep |
    coil c:\[filename].txt
    Select / * + parallel (table 4) * /.
    col1,
    col2,
    col3,
    COL4,
    col5,
    col6,
    col7,
    COL8,
    col9,
    col10,
    Col11,
    col12... etc.

    My output looks like:

    99990001 | + {space} + 2003 | 0 + {space} + | 0 + {space} + | + {space of} + 1 | 0 + {space} + | 0 + {space} + | 0 {space}. 0 + {space} + | 0 + {space} + | 0 + {space} + | 0 + {space} + | 0 etc

    When I need to look like:

    99990001 | 2003 | 0 | 0 | 1. 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0... etc.

    I can't concatinate columns as this would force the SET NULL option won't do not and using NVL for each column makes the query take too much time.

    a post on this thread Re: save output sql command separate values by the States that you cannot force coil of sql to remove spaces, is it true?

    all threads in this research http://forums.oracle.com/forums/search.jspa?threadID= & q = colsep & objID = c84 & dateRange = last90days & userID = & numResults = 15 lead me to believe that it is also not possible.

    The coil may not have gaps as it is used by some sort of contraption of system before my time to really understand and I said that it's just not having them.

    Thanks in advance for any help.

    G

    I think that concatenating your columns with NVL(col1,0) will be your only option. In addition, it didn't really the request that much more time.

  • SQL query returning no rows, please help!

    I have a table that contains the user checks for a specific procedures alongwith the date stamp. Now, I want the list of all procedures that are not accessible by users in the last 6 months. Or, all of the procedures that have not been used/accessible during the last 6 months.

    That's what I'm trying, but is does not return all rows:

    SELECT DISTINCT proc_name,
    TRUNC (entry_date)
    OF log_web
    WHERE NOT IN (SELECT proc_name proc_name
    OF log_web
    WHERE TRUNC (entry_date) > TRUNC (SYSDATE - 180))
    ORDER BY DESC 2

    Please notify.
    Thank you in advance.

    Hello

    NOT IN never returns TRUE if the subquery returns NULL values. If proc_name doesn't have a NOT NULL constraint, change the subquery to

    WHERE        proc_name     NOT IN ( SELECT  proc_name
                                FROM      log_web
                         WHERE      entry_date     > TRUNC (SYSDATE - 180)
                         AND      proc_name     IS NOT NULL
                          )
    

    I don't see any other suspect.
    Post a small example of data (CREATE TABLE and INSERT statements) where the query produces results worng.

  • Query that count only the column null lines

    create table test
    (a varchar2 (10))
    b varchar2 (10),
    c varchar2 (10),
    d varchar2 (10),
    e varchar2 (10));


    SQL > DESC TEST
    Name Null? Type
    ------------------------------- -------- ----
    A VARCHAR2 (10)
    B VARCHAR2 (10)
    C VARCHAR2 (10)
    D VARCHAR2 (10)
    E VARCHAR2 (10)

    SQL > SELECT * FROM TEST;

    A B C D E
    ---------- ---------- ---------- ---------- ----------
    A1 - A3 A4-
    B1 - B3, B4-
    C1 - C3 C4-
    D1 - D4 D5
    -E2 - E4 E5


    I want an application that only count the rows of the column as null

    A B C D E
    --- ---- ----- ------ -------
    1 4 2 0 3

    Published by: Nilesh hole, Pune, India, on August 28, 2009 12:30
    select SUM(case when a is null then 1 else 0 end)
          ,SUM(case when b is null then 1 else 0 end)
          ,SUM(case when c is null then 1 else 0 end)
          ,SUM(case when d is null then 1 else 0 end)
          ,SUM(case when e is null then 1 else 0 end)
    from TEST
    /
    

    Published by: Toon Koppelaars August 28, 2009 09:07

  • Gets the error ORA-01779 after I added the column

    Hi, I'm a total newbie in APEX but collaborated with ordinary development Oracle (tables, views, packages, triggers, etc) for a number of years.

    I ve been assigned in order to respect an existing application to APEX. One task is to add a column to a single character named 'ACTIVE' to a database table and also present on a current project list page. The value can be 'Y' or 'n'. In the view which is the source of data for the project page ad 'Y' turned into 'Yes' and 'n' turned into 'no '. So far so good, everything works well.

    There is another page on which it is possible to create new or modify existing projects. This page uses a view as a source of data. On this page, I added a group of radiobutton that contains two options: 'Yes' and 'no '. When I select to edit a project in the project list page the second page is loaded and the correct option, 'yes' or 'No', is marked on the page. This group of radiobutton works exactly like a couple of other groups of radiobutton also represented with a single character column in the database. So far so good!

    However, when I try to save the project file by clicking on "Apply Changes" I get this error:

    ORA-20001: DML error: p_rowid = 50, ID = p_alt_rowid, p_rowid2 =, p_alt_rowid2 is. ORA-01779: cannot modify a column that is mapped to a table not preserved key

    What is the problem here? The new 'ACTIVE' column is added to the view, when I run the view I Don t get all records in duplicate, the underlying table has a column id as the primary key.

    Since I Don t know that APEX is under the hood it s hard tp what's wrong. Anyone knows the solution to this problem?

    / Magnus

    Hello Magnus,

    Is there an INSTEAD OF trigger defined on the view? Have you added the new column ACTIVE there too?

    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this response in marking it as useful or Correct ;-)

  • Please tell us how to remove the 'message thread function' in the column 'Object' of my Inbox.

    Hello!
    For some reason, the column of the object on the Inbox of my e-mail account now has the topics of conversation. I have no idea how the son got there - and you would appreciate the help in eliminating these threads.
    Thanks a lot for your help.

    In the main menu bar:
    View (Alt - V) - sort by - Unthreaded

Maybe you are looking for