Conditional column to the conversion of the line

Hi, I have a dynamic query in PL/SQL that accepts ledger_id as a parameter and creates a flat file based on ledger_id.

Here is my requirement: the user can enter one or more ledger_ids

Country Great book ID
WE2001
CA2002
CA2003
BE2004

for above scenario I need data like this:

Country Great book ID
WE2001
CA2002,2003
BE2004

So, if he or she between 2002 and 2003 (both are for the Canada) I need to pass as 2002,2003

Thank you

Kiran

Hello

This sounds like a job for LISTAGG:

SELECT country

LISTAGG (ledger_id, ",") THE Group (ORDER BY ledger_id) AS ledger_id_list,

FROM table_x

GROUP OF countries;

You don't have to know how many ledger_ids there are for all countries, but the totla of the list, including the commas, size cannot be more than 4,000 characters.

Tags: Database

Similar Questions

  • Conversion of column to the lines

    Hello
    I'm currently building and SQL to convert columns from several lines to all lines - see below the test data and the expected result:
    CREATE TABLE XX_TEST (NAME VARCHAR2 (10), A1 VARCHAR2 (10), A2 VARCHAR2 (10), A3 VARCHAR2 (10), A4 VARCHAR2 (10), A5 VARCHAR2 (10));
    INSERT INTO XX_TEST VALUES('LIST','A','B','C','D','E');
    INSERT INTO XX_TEST VALUES('L1','1',,'3',,);
    INSERT INTO XX_TEST VALUES('L2','1','5','4',,);
    ENGAGE
    SELECT * FROM XX_TEST;

    Expected result:
    NAME is the table XX_TEST column, but the COLUMN and the VALUE are converted to lines - columns

    NAME THE COLUMN VALUE
    L1 A1 1
    L1 A2 NULL
    L1 A3 3
    L1 A4 NULL
    L1 A5 NULL
    L2 A1 1
    L2 A2 5
    L2 A3 4
    L2 NULL A4
    L2 A5 NULL

    Thank you
    BS

    Hello

    user13409900 wrote:
    Thank you Alex and Frank,

    Don't foget Aketi!

    The two ways are really good and functional in my situation.
    I apologize for not giving version: I'm on 11g so I think that can use Unpivot. It would be really more faster (performance given the volume of data) to use unpivot characteristic of 11 g?

    If there is no significant difference, whereas I think is that SELECT... UNPIVOT would be faster. It is purely a guess. It depends on several factors, including your data, your index and your machine. I don't have access to one of them.

    Try both ways and compare performance. (Compare the results, too, to check that the two qiueries are really doing the same thing).
    If you need help, see this thread:
    HOW to: Validate a query of SQL statement tuning - model showing

    I've never used before unpivot.

    This sounds like a good opportunity to learn.

  • Custom script in RPO making empty columns in the line items during the training.

    Hello friends,

    its URGENT! need help.

    We have a requirement of the company in the case of the currency 'EUR', it should delete the dot (.) and replace the comma (,) with dot (.) and other currencies it must remove the comma from columns, quantity, price per unit and Total.

    For example:

    For "EUR" 2.123,00 and it must convert it to 2123.00 and 2.123 must convert 2123.

    "USD" 2.123,00 to convert to 2.12300 and 2 123 to convert to 2123.

    This requirement, we wrote a custom script User Exit (UserExitLineItemValidate) function and call that function in line item validation.

    but after having formed the invoices for currency 'EUR' by supervised and learning check (SLV), it removes the values in the column quantity, unit price and Total.

    and if we remove the script, train and then reapply custom script it works but not always.

    My Script:

    Public Sub UserExitLineItemsValidate (pWorkdoc As SCBCdrPROJLib.SCBCdrWorkdoc, pValid As Boolean)

    ' User exit is called at the end of the Document_Validate on the class "bills".

    Dim strQuantity As String

    Dim strUnitPrice As String

    Dim strTotal As String

    Dim lngRow As Long

    Dim pTable As SCBCdrTable

    Set pTable = pWorkdoc.Fields ("LineItems"). Table (pWorkdoc.Fields("LineItems"). ActiveTableIndex)

    If fnIsVerifier and pWorkdoc.Fields ("Currency"). Text = "EUR" Then

    For lngRow = 0 To pTable.RowCount - 1


    strUnitPrice = pTable.CellText ("unit price", lngRow)

    If InStr (strUnitPrice, ".") > 0 and InStr (strUnitPrice, ",") > 0 Then

    strUnitPrice = Replace(strUnitPrice,".","")

    strUnitPrice = Replace(strUnitPrice,",",".")

    pTable.CellText ("unit price", lngRow) = strUnitPrice

    ElseIf InStr (strUnitPrice, ",") > 0 Then

    strUnitPrice = Replace(strUnitPrice,",",".")

    pTable.CellText ("unit price", lngRow) = strUnitPrice

    End If

    strTotal = pTable.CellText ('Total', lngRow)

    If InStr (strTotal, ".") > 0 and InStr (strTotal, ",") > 0 Then

    strTotal = Replace(strTotal,".","")

    strTotal = Replace(strTotal,",",".")

    pTable.CellText ('Total', lngRow) = strTotal

    ElseIf InStr (strTotal, ",") > 0 Then

    strTotal = Replace(strTotal,",",".")

    pTable.CellText ('Total', lngRow) = strTotal

    End If

    strQuantity = pTable.CellText ("quantity", lngRow)

    If InStr (strQuantity, ".") > 0 Then

    strQuantity = Replace(strQuantity,".","")

    End If

    If InStr (strQuantity, ",") > 0 Then

    strQuantity = Replace(strQuantity,",",".")

    End If

    pTable.CellText ("quantity", lngRow) = strQuantity

    Next LngRow

    On the other

    For lngRow = 0 To pTable.RowCount - 1

    strTotal = pTable.CellText ('Total', lngRow)

    If InStr (strTotal, ",") > 0 Then

    strTotal = Replace(strTotal,",","")

    pTable.CellText ('Total', lngRow) = strTotal

    End If

    strUnitPrice = pTable.CellText ("unit price", lngRow)

    If InStr (strUnitPrice, ",") > 0 Then

    strUnitPrice = Replace(strUnitPrice,",","")

    pTable.CellText ("unit price", lngRow) = strUnitPrice

    End If

    Next LngRow

    End If

    End Sub

    At a very high level of control, (and I can't currently that take a long time to respond)

    • You do this on EVERY invoice, and not only those that you are sub classification (which means "documents that you are training").  Is your intention to assign all invoices or only those formed?
    • In your code, you have the test as shown condition "If fnIsVerifier and pWorkdoc.Fields("Currency").» Text = "EUR" Then".»  You are in essence saying the system ONLY evaluate this condition if the system determines if the application Verifier is running.  What is the desired effect?  Otherwise if the auditor is never used on this document, and the table of line items is never changed, this code would never trigger.
  • transpose the data in the column to the line

    I want to change the columns in lines, my data is

    TYPERANK
    1A
    1AA
    1AAA
    2B
    2BB

    I want it in

    RANK (1)RANK (2)
    AB
    AABB
    AAA

    Please help me

    Thanks for the response guys, in the meantime, I found the solution too

    SELECT MAX(CASE WHEN ID=1 THEN RATING ELSE NULL END) AS RC,

    MAX(CASE WHEN ID=2 THEN RATING ELSE NULL END) LAUGHED

    FROM (SELECT ID, RATING, ROW_NUMBER() over (ORDER BY rowid ID PARTITION) RN)

    OF RANK_TEST) X

    GROUP BY RN;

    Thank you very much

  • Works with tables/columns of the lines and the parameter names... syntax help

    I am trying to create a function that returns the distinct value and counts of a user defined schema/table/column.

    The code below defines a [stats_on_column_obj] object type and creates a single table of this type [stats_on_column_tab].

    The function is supposed to take three input variables: p_schema_name, nom_table_p, p_column_name and return an array (above).

    I can hardcode a select into (the)... but once I try to convert it into settings & immediate exec I'm stuck. The red section is where the problem is (I think).

    Oracle 10g.

    Stats_on_column_obj CREATE TYPE IS OBJECT (

    COL_VAL VARCHAR2 (500),

    NUMBER OF COL_VAL_CNT (7)

    );

    CREATE TYPE Stats_on_column_tab IS TABLE OF stats_on_column_obj;


    FUNCTION to CREATE or REPLACE get_STATS_ON_COLUMN

    (

    p_schema_name IN varchar2,

    nom_table_p IN varchar2,

    p_column_name IN varchar2

    )

    RETURN STATS_ON_COLUMN_tab

    IS

    l_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab: = STATS_ON_COLUMN_tab ();

    n INTEGER: = 0;

    str_select_tbl varchar2 (5000);

    BEGIN

    str_select_tbl: = 'SELECT'. p_column_name |' as col_val, count (*) as col_val_cnt FROM ' | p_schema_name |'. ' || nom_table_p: ' group of ' | p_column_name;

    FOR r IN (str_select_tbl)

    LOOP

    l_STATS_ON_COLUMN_tab. EXTEND;

    n: = n + 1;

    l_STATS_ON_COLUMN_tab (n): = STATS_ON_COLUMN_obj (r.col_val, r.col_val_cnt);

    END LOOP;

    RETURN l_STATS_ON_COLUMN_tab;

    END;

    /

    [Error] PLS-00103 (124:4): PLS-00103: encountered the symbol "LOOP" when expecting one of the following numbers: * & - + / at rem rest mod.. < an exponent (*) > | multiset year DAY_

    [Error] PLS-00103 (126:9): PLS-00103: encountered the symbol "=" when expected in the following way: constant exception < an ID > < a between double quote delimited identifiers > double Ref table Fedya Chariot of time timestam

    [Error] PLS-00103 (127:29): PLS-00103: encountered the symbol "

    [Error] PLS-00103 (128:4): PLS-00103: encountered the symbol "END" when waiting for one of the following numbers: begin function package pragma procedure subtype type use < an ID > < a double quote delimited identifier > form

    SELECT * FROM TABLE (get_STATS_ON_COLUMN ('SCHEMAS_X', 'TABLE_X', 'COLUMN_X'));

    Scott@ORCL > CREATE OR REPLACE
    FUNCTION get_STATS_ON_COLUMN () 2
    3 p_schema_name IN varchar2,
    4 nom_table_p IN varchar2,
    5 p_column_name IN varchar2
    6                                )
    7 STATS_ON_COLUMN_tab of RETURN
    8 EAST
    9 v_STATS_ON_COLUMN_tab STATS_ON_COLUMN_tab: = STATS_ON_COLUMN_tab ();
    10 v_n INTEGER: = 0;
    11 v_str_select_tbl VARCHAR2 (5000);
    BEGIN 12
    13 v_str_select_tbl: = ' SELECT stats_on_column_obj (' | p_column_name |) ', Count OF ' |
    14 p_schema_name | '.' || nom_table_p | "Group of" | p_column_name;
    15 v_str_select_tbl EXECUTE IMMEDIATE
    COLLECTION IN BULK 16
    17 IN v_STATS_ON_COLUMN_tab;
    18 RETURN v_STATS_ON_COLUMN_tab;
    END 19;
    20.

    The function is created.

    Scott@ORCL > select *.
    2 from table)
    (3 get_STATS_ON_COLUMN)
    4                                            'SCOTT',
    5                                            'EMP',
    6                                            'JOB'
    7                                           )
    8                       )
    9.

    COL_VAL COL_VAL_CNT
    -------------------- -----------
    CLERK                          4
    SELLER 4
    PRESIDENT 1
    MANAGER 3
    ANALYST 2

    Scott@ORCL >

    Or better change function in the pipeline.

    SY.

  • column using the line

    I have this result of the query;

    Select col1 from
    T1;

    col1
    -------
    2
    3
    4, 6
    5,1,7


    I want the result to be like this
    col1
    ----------
    2
    3
    4
    6
    5
    1
    7

    I'm new in 10g, please help

    Thanks to Peter ;)
    Re: Simple Question: how to divide the string into multiple lines concatenated?

    SQL> with t1 as ( -- generating sample data
      2  select '2' col1 from dual union all
      3  select '3' from dual union all
      4  select '4,6' from dual union all
      5  select '5,1,7' from dual
      6  )
      7  --
      8  -- actual query
      9  --
     10  select regexp_substr(col1,'[^,]+',1,s2.column_value)
     11  from   t1
     12  ,      table ( cast ( multiset(select rownum rn from dual connect by rownum <= length(col1) - length(replace(col1, ',')) + 1)
     13                 as sys.dbms_debug_vc2coll
     14               )) s2
     15  /
    
    REGEXP_SUBSTR(COL1,'
    --------------------
    2
    3
    4
    6
    5
    1
    7
    
    7 rows selected.
    
  • error 103 to the column of the line 6 17

    Hi all

    brand new m forms of oracle, using oracle forms 6i
    m using this code

    BEGIN
    IF
    : OVERALL. FABRIC = "BUY" THEN
    GO_BLOCK ('PURCHASE_ORDER');
    ON THE OTHER
    : OVERALL. FABRIC = "BUSINESS" THEN
    GO_BLOCK ('LOOMS_CONTRACT');
    ON THE OTHER
    : OVERALL. FABRIC = 'KNITTING' CAN
    GO_BLOCK ('KNITTING_CONTRACT');
    END IF;
    END;



    where is the error please do some need full.
    thnks.

    Published by: 940133 on June 26, 2012 21:42

    Published by: 940133 on June 26, 2012 21:47

    Try this

    BEGIN
    IF :GLOBAL.FABRIC = 'PURCHASE' THEN
    GO_BLOCK('PURCHASE_ORDER');
    ELSif :GLOBAL.FABRIC = 'LOOMS' THEN
    GO_BLOCK('LOOMS_CONTRACT');
    ELSif :GLOBAL.FABRIC = 'KNITTING' THEN
    GO_BLOCK('KNITTING_CONTRACT');
    END IF;
    END;
    
  • Conditional column values

    Someone knows how to put a condition on a value in the column so that you can change depending on another column in the line?

    My logic is IF column B = "OK" then show the value in "column A" other "unfinished" in column A.

    It is in any case the idea behind it.

    You will need to ensure that the code inside your SQL using DECODE or CASE, as in this example:

    http://Apex.Oracle.com/pls/OTN/f?p=31517:23

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • Need help for the conversion of the lines in columns

    Hi all

    I have a table with 2 columns.
    colId value
    1 aaa
    2 bbb
    3 ccc
    1 ddd
    Eee 2
    3 fff

    I want to store the data in the table above in another table that has 3 columns.
    col1 col2 col3
    AAA bbb ccc
    DDD eee fff

    I am pivot query. But I don't get it properly. Help, please.

    I have Oracle Database 11 g Enterprise Edition Release 11.1.0.6.0 - 64 bit Production

    Thanks in advance,
    Girish G

    Published by: Girish G July 28, 2011 01:28

    Girish G wrote:
    Hey Tubby,

    Let me explain the real-world scenario.

    I'm the external source CLOB data in oracle stored procedure.

    The data are coming in the form below.

    col1 # | #col2 # | #col3 ~ | ~ col1 # | #col2 # | #col3 ~ | ~ col1 # | #col2 # | #col3

    # Here. #-> is the column delimiter.
    and ~ | ~-> is the line delimiter.

    I want to store these data in a table that has 3 columns.

    My approach was to extract the data for each column and store it in a temporary table in separate lines. Then move the data from the temporary table to the destination table.

    Are there other alternatives for my requirement? Please suggest.

    Thank you
    Girish G

    Much better when you show us the context like that.

    It's late and I have sleepiness in my bones, so it's not likely optimal.

    select
       regexp_substr(split, '[^@]+', 1, 1) as col1 ,
       regexp_substr(split, '[^@]+', 1, 2) as col2 ,
       regexp_substr(split, '[^@]+', 1, 3) as col3
    from
    (
       select
          replace(regexp_substr(source_str, '[^@]+', 1, level), '#|#', '@') as split
       from
       (
          select
             replace('val1#|#val2#|#val3~|~val4#|#val5#|#val6~|~val7#|#val8#|#val9', '~|~', '@') as source_str
          from dual
       )
       connect by level <= length(source_str) - length (replace(source_str, '@') )  + 1
    );
    

    I do not have an instance running (tested on XE) 11 so I can't use "magical" things like regexp_count and fun stuff. This should give you a basic idea of how to analyze data well.

    I decode your delimiters in something "more manageable" just because it's easier than worrying about the escaping of special characters and all that fun stuff I'm too asleep to try.

    Since you are dealing with a CLOB (you actually over 4,000 characters of data?) you have to give it up and look for a function in the pipeline as a suitable alternative.

  • column to the conversion of the line

    CREATE TABLE TEST_PLC

    (

    NUMBER OF "PRCS_ID."

    VARCHAR2 (20 BYTE) "LIC_ID."

    VARCHAR2 (1 BYTE) "REG."

    VARCHAR2 (10 BYTE) "PLCY1."

    VARCHAR2 (10 BYTE) "PLCY2."

    VARCHAR2 (10 BYTE) "PLCY3".

    );

    Insert into TEST_PLC (PRCS_ID, LIC_ID, REG, PLCY1, PLCY2, PLCY3) values (123456, 'XXXX', 'W', '1212', null, null);

    Insert into TEST_PLC (PRCS_ID, LIC_ID, REG, PLCY1, PLCY2, PLCY3) values (345678, 'XXXX', 'W', ' 6789 ', ' 1101', null);

    Insert into TEST_PLC (PRCS_ID, LIC_ID, REG, PLCY1, PLCY2, PLCY3) values (456789, 'YYYY', 'W', "2222", null, null);

    Insert into TEST_PLC (PRCS_ID, LIC_ID, REG, PLCY1, PLCY2, PLCY3) values (567890, 'YYYY', 'W', "6767", "7878 ', null);

    Insert into TEST_PLC (PRCS_ID, LIC_ID, REG, PLCY1, PLCY2, PLCY3) values (135791, 'ZZZZ', 'W', '4646', null, null);

    I have a table as above and I want to fill new table as my results below.

    PRCS_ID is an indicator only, I want to combine PLCY1, PLCY2, PLCY3 in a single column as PLCY and know if it is PLCY1 or PLCY2 or PLCY3 I need a new seq column with the values 1, 2 or 3. in real time, I have PLCY columns in my source, but I just want to test with small sample

    Expected results

    PRCS_IDLIC_IDREGPLCYSEQ
    123456XXXXW12121
    345678XXXXW67891
    345678XXXXW11012
    456789AAAAW22221
    567890AAAAW67671
    567890AAAAW78782
    135791ZZZZW46461

    I checked some of the examples but not able to get my desired result

    Please help to solve one.

    Hello

    It's called Unpivoting.

    To see the results you want:

    SELECT *.

    OF test_plc

    UNPIVOT (plcy

    FOR seq (plcy1 AS 1

    plcy2 AS 2

    plcy3 AS 3

    )

    )

    ;

    Output:

    PRCS_ID LIC_ID R SEQ PLCY

    ---------- -------------------- - ---------- ----------

    XXXX 123456 W 1 1212

    XXXX 345678 W 1 6789

    XXXX 345678 W 2 1101

    AAAA 456789 W 1 2222

    AAAA 567890 W 1 6767

    AAAA 567890 W 2 7878

    ZZZZ 135791 W 1 4646

    Exactly what you asked for, except that the column forms SEQ before PLCY.  In a relational table, the column order should not matter, but if you really want to have PLCY come before SEQ, then don't say ' SELECT * '. the list instead, all the columns in the order you want.

    If you want to create a new table as the result above, use the query in an AS TABLE CREATE statement above:

    CREATE TABLE new_plc

    AS

    SELECT *.

    ...

    If you already have a table, and you want to fill with the results of the above query, use this query in an insert oou MERGE:

    INSERT INTO new_plc (prcs_id, lic_id, reg, seq, plcy)

    SELECT *.

    ...

  • the lines updated in response to conditions in the subquery is me stumping

    Database is 10 gr 2

    Application admin wants me to change the values in a column (col_1) in a table where the lines meet the following condition

    Select 1.col_1

    of OQ.table_a 1, OQ.table_b 2

    where

    1.col_2 = 2.col2

    and 2.col_3 = 0 ' '

    and 2.col_4 = 'abcd '.

    and 1.col_1 = '0'

    This query returns 750 lines, I want to change 1.col_1 to '1' in all these lines, so I run:

    Update OQ.table_a set 1.col_1 = '1'

    where 1.col_1 in

    (

    Select 1.col_1

    of OQ.table_a 1, OQ.table_b 2

    where

    1.col_2 = 2.col2

    and 2.col_3 = '0'

    and 2.col_4 = 'abcd '.

    and 1.col_1 = '0'

    )

    and I get 1095 lines updated and must roll back.

    I have not worked with SQL in a while and miss me something real simple here - any ideas?

    Thanks in advance

    All ranks your subquery returns aura col1 = 0 because it is part of your WHERE clause. So where clause contained in the outer query is essentially saying 'where 1.col1 = 0' If you update each line that contains a 0 in col1. This table has a primary key, if so

    Update OQ.table_a set 1.col_1 = '1'

    where 1.primary_key in

    (

    Select 1.primary_key

    of OQ.table_a 1, OQ.table_b 2

    where

    1.col_2 = 2.col2

    and 2.col_3 = '0'

    and 2.col_4 = 'abcd '.

    and 1.col_1 = '0'

    )

    If there is no primary key do not use rowid.

  • Highlight the line in the standard State is based on the value in the column...

    I'm trying to highlight the lines of a standard report based on the value of the TICKET_TYPE column.

    I followed the post: highlighted a line in a tabular form based on a column in the row

    but the difficulty. I have the following error:

    ORA-06550: line 1, column 34: PLS-00201: identifier 'SHRIMP' must be declared ORA-06550: line 1, column 7: PL/SQL: statement ignored

    ERR-1025 expression PLSQL treatment error. SHRIMP = "SHRIMP".




    My report query is:

    Select T.TRIP_ID,
    T.TRIP_ID trip_show,
    T.TRIP_ID trip_select,
    T.DAYS_AT_SEA,
    T.NBR_OF_CREW,
    T.TRIP_START_DATE,
    T.VESSEL_ID,
    o.ticket_type ticket_type
    TRAVEL t, o one_ticket_type
    where t.dea_permit_id =: G_DEA_PERMIT_ID and t.trip_id = o.trip_id

    I created a new template called a ticket-enhancement.

    line 1 = tempate < td #ALIGNMENT headers # = "" #COLUMN_HEADER # "class ="t14data"style =" background: red "> #COLUMN_VALUE # < table >"
    model condition rank 1 = use based on the expression of pl/sql
    template expression rank 1 = #TICKET_TYPE # = "SHRIMP" (* I also tried without the quote)


    any thoughts? Thank you!!

    Edited by: KEH813 may 25, 2010 11:10

    I'm not sure of the JavaScript. Whenever you sort the report, coloring disappears and you can send the page again.

    PS Don't forget to mark the answers as Correct or useful.

    Best regards
    Mathieu Gosselin

  • Implement conditional read-only column in the set of two Tables

    Hello

    I would like to implement a mechanism of "read-only conditional" on a column in a table with two tables in total to be involved in this situation.

    I have a demo/proof of concept of the present and things work as expected in the tests I've done; However, I would like any input as to if there is a better way, etc.

    This is a far-fetched but demo that illustrates the main ingredients however. Oracle 10.2.0.4 version 64 bit on Windows Server 2008 Release 2 64-bit.

    -Table DDL and small sample data
    create table band(
      band_id   number primary key,
      band_name varchar2(20),
      status    varchar2(20)
    );
    
    create table band_member(
      band_id references band,
      member_name varchar2(20)
    );
    
    insert into band values(3, 'The Rutles', 'prefab4');
    insert into band values(4, 'The Beatles', 'established');
    commit;
    
    insert into band_member values(3, 'Ron Nasty');
    insert into band_member values(3, 'Dirk McQuickly');
    insert into band_member values(3, 'Stig O''Hara');
    insert into band_member values(3, 'Barrington Womble');
    commit;
    
    insert into band_member values(4, 'John Lennon');
    insert into band_member values(4, 'Paul McCartney');
    insert into band_member values(4, 'George Harrison');
    insert into band_member values(4, 'Ringo Starr');
    commit;
    -The rules relating to the conditional objective of read-only

    1 is not allowed to update band.band_name when band.status = 'prefab4'
    2 is not allowed to insert/update / deletion of lines of band_member when the parent a band.status row = 'prefab4'

    -The triggers used to implement the goal (current solution)
    create or replace trigger t1
    before update of band_name on band
    for each row
    when (old.status = 'prefab4' or new.status = 'prefab4')
    begin
      raise_application_error(-20010,
        'can not update band_name when status=''prefab4''');
    end;
    /
    
    create or replace trigger t2
    before insert or update or delete on band_member
    for each row
    declare
      l_status band.status%type;
      l_band_id band_member.band_id%type;
      cursor l_cursor (p_band_id number) is
      select status from band
      where band_id = p_band_id
      for update;
    begin
      if updating or inserting then
        l_band_id := :new.band_id;
      else
        l_band_id := :old.band_id;
      end if;
      open l_cursor(l_band_id);
      fetch l_cursor into l_status;
      close l_cursor;
      if l_status = 'prefab4' then
        raise_application_error(-20011,
          'can not update child when parent status=''prefab4''');
      end if;
    end;
    /
    -Quick example of test for each condition
    update band
    set    band_name = 'THE RUTLES'
    where  band_id = 3;
    
    update band
           *
    ERROR at line 1:
    ORA-20010: can not update band_name when status='prefab4'
    ORA-06512: at "DEMO.T1", line 2
    ORA-04088: error during execution of trigger 'DEMO.T1'
    
    
    update band_member
    set    member_name = 'RON NASTY'
    where  member_name = 'Ron Nasty';
    
    update band_member
           *
    ERROR at line 1:
    ORA-20011: can not update child when parent status='prefab4'
    ORA-06512: at "DEMO.T2", line 18
    ORA-04088: error during execution of trigger 'DEMO.T2'
    As I said, while my simple tests seem to show the correct results, there I was wondering if there could be a better way to implement such functionality.

    I tried to provide the information needed, but if I managed to omit something, please let me know.

    See you soon,.

    Chalfont

    Hi, Chalfont,

    user13146957 wrote:
    ...
    I'm went to the road to slider to add the clause "for update" to force the serialization on the line - i.e. the idea was to avoid the case where another session might want to update the State a moment after my extraction but before the rest of the finished code. Who is?

    No, not really. The trigger on tape prevents anyone else from ever change their status from 'prefab4' to something else (or vice versa).
    Even apart from this, you put some efforts to prevent something which will be allowed a fraction of a second later (or maybe the other way around). What is significant in that split second?

    I didn't think about other ideas rather than the approach of the trigger, but came up empty, somehow, to this day. I am open to resort to others and make some schema changes is not off the table either.

    FGA (Fine grain access), or his brothers and sisters more older VPD (virtual private database) can also do what you want, but instead of trigger an error, they ignore the illegal action. This can be an advantage or a disadvantage, depending on your needs.

    Another approach is for the owner of the table, not to grant INSERT, UPDATE or DELETE privileges to anyone: all DML must be made via a procedure (or procedures) belonging to the owner of the table, which grants EXECUTE privileges instead of other privileges.

  • The line formatting based on the value of a column

    Hi friends

    I'm trying to format the entire row based on the value of the first column in my answers.

    Example, if the first value of column 'F' now, I want the row to be colorful

    I can do a conditional formatting on a column, but I want to do down the line

    F 8.1% 12.0%
    ------------------------------------------
    E 5.2% 3.5%
    ------------------------------------------
    M 2.3% 3.3%
    ------------------------------------------


    If one has done this or suggestions please answer

    Thank you
    Sang A

    Well, the conditional formatting can be done in PivotTables until the next version, 11g. In the meantime, you two options:

    (1) http://gerardnico.com/weblog/2009/04/06/obiee-cross-conditional-formatting-on-a-pivot/

    (2) http://oraclebizint.wordpress.com/2008/04/29/oracle-bi-ee-101332-conditional-formatting-based-on-multiple-character-columns-in-a-pivot-table/

    (3) you can use your custom column filter functionality to get your ' sales in year 20xx "and a presentation to make this dynamic variable. So you can declare an array and use the method I described above.

    filters on columns

    Good luck.

  • Set the line report radio group when it is clicked on a link column.

    Can Hi anyone help?

    I have a sql report with a group on the left radio record selector, it is used on click to fill out some additional fields in the page. I also have a column of link on the right side of the report that is used to display another page in popup. What I want is to synchronize the group radio selector when the link is clicked (i.e. Select and click on the current online radio group when the link column is selected).

    Page layout

    RG1 link pencil icon line details
    RG2 link pencil icon line details
    RG3 link pencil icon line details

    additional field 1
    additional field 2

    Report of the attributes - link URL column.
    JAVASCRIPT: modalWin2 ('f? p = & APP_ID.: #SHOW #: & SESSION.: SAVE_STATUS: no);



    I guess I can call another function of javascript in the URL from the link above, and somehow, I get the number of the line of the selected link. I think that if I can get that I can use the code below, where n is the row number of the selected link.

    JavaScript: -.

    var l_check = $x_FormItems ($x('EVENT_HIST1'), 'radio');
    checked l_check [n] = true;
    var l_click is l_check [n] ravishing ();.

    Thanks, Pete

    Pete:

    One way to resolve your condition is as below

    Modify the report query to be something similar to

    select
    apex_item.radiogroup(40,empno,null,null,'id=rg_'||rownum) rad,
    ename,
    '' link_column
    from emp
    

    And the JS function fx as

    function fx(emp,rgId) {
    $x(rgId).checked=true;     // checks radio on this row
    modalWin2('f?p=&APP_ID.:' + emp + ':&SESSION.::::SAVE_STATUS:N'); // popup page call
    }
    

    CITY

Maybe you are looking for

  • After the upgrade to v26.0 - text in textarea boxes is spread out on the page

    After the upgrade to version 26.0 - I'm on windows XP, all text in textarea boxes spill out of the box and on the page. Text wrapping is disabled. It always happens like that: I load a page with a textarea box that contains a lot of text in there. Te

  • Equium M40X hangs & reboots after reinstalling Windows XP

    The laptop works fine in safe mode. I tried to do the windows updates, but in safe mode, it gives an error to the windows update server. BIOS of the laptop is later. Perhaps can someone suggest what to do to solve this problem. Concerning Mahmood ADi

  • solenoid USB 6212

    I'm trying to control a solenoid TTL using a USB 6212 and LabView.  I'm new to LabView and don't know if my code is correct.  I'm also not sure which way I'm supposed to use.  I appreciate all help.

  • Could not load mndsifz.dat error on start up

    Recently when I started my PC, so came with the message above.  I click OK and everything seems to work OK.  How I either correct the error or eliminate it? It is said that it is trying to load from C: program data / mndisfz.dat I do not have a direc

  • Cannot validate the certificate pop when opening outlook.

    Hello, I am running Windows Vista with outlook 2007.  Everytime I open outlook lately, I get the following message. "Same description DV. [CODE] Certificate revocation statusCalling application: Microsoft OutlookCertificate name: / C = US / ST = Wash