Help me to write this pl block

Table name xbrl1
JE_HEADER_ID     JE_LINE_NUM     ENTERED_DR     ENTERED_CR     ACCOUNTED_DR     ACCOUNTED_CR
59,120.00     4.00          136.00          265.99          1          2
59,120.00     5.00          281.00          549.59          1          2
59,120.00     6.00          342.00          668.89          1          2
Table name xbrl2
ERP_FIELDS     ELEMENT_DATA
je_header_id     uniqueID
je_line_num     lineNUM
entered_dr     amount1
entered_cr     amount2
accounted_dr     amount3
accounted_cr     amount4
I hope every one can make it the caps hedding are column name and below is the data.
I want to write a plsql block ( or query) which give me the data from table xbrl1
and column headings from xbrl2 mapping xbrl1.column heading with xbrl2.ERP_FIELDS and taking column heading from xbrl2.ELEMENT_DATA column
some thing like below
oup put
uniqueID     lineNUM          amount1          amount2          amount3          amount4
59,120.00     4.00          136.00          265.99          1          2
59,120.00     5.00          281.00          549.59          1          2
59,120.00     6.00          342.00          668.89          1          2
can any body help me plz, I have requested for environment to test, I will be getting it by today evening can any one of you write me the code for this.
can be assume that if it is a procedure(or block)
I will be passing the in parameter as comma separated columns names of xbrl1 to the procedure it should take the col name as in parameter and give the result as above, if nothing is passed (nul) to the inparameter it should give me all the data of xbrl1 table with column heading coming from xbrl2.ELEMENT_DATA
Thanks in advance.

I have done it in this way... but this is not tested.. as environment is still not there...can any one test this for me...thanks
/* Note:
     Order or execution of scripts:
     1. temp_a
     2. temp_b
     3. sp_a_new.sql (or sp_a_new_2.sql)
drop table temp_a;
drop table temp_b;
create global temporary table temp_a (a_text varchar2(1000)) on commit preserve rows;
create global temporary table temp_b (b_text varchar2(1000)) on commit preserve rows;
CREATE OR REPLACE PROCEDURE sp_a_new (p_i_list VARCHAR2)
AS
v_name VARCHAR2(4000);
v_sql VARCHAR2(4000);
v_count NUMBER(10) := 1;
v_final NUMBER(10);
TYPE t_tab IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
v_mytab t_tab;
idx NUMBER(10);
v_start_pos NUMBER(10);
v_next_pos NUMBER(10);
v_fin_text VARCHAR2(1000);
CURSOR c_temp_b IS
SELECT b_text
FROM temp_b order by rowid;
CURSOR c_main IS
SELECT element_data FROM xbrl2 order by rowid;
BEGIN
IF p_i_list IS NOT NULL THEN
DELETE FROM temp_a;
DELETE FROM temp_b;
COMMIT;
v_start_pos := 1;
idx := 1;
LOOP
SELECT DECODE (INSTR(p_i_list, ',', v_start_pos, 1), 0, LENGTH(p_i_list), INSTR(p_i_list, ',', v_start_pos, 1))
INTO v_next_pos
FROM dual;
IF v_next_pos = LENGTH(p_i_list) THEN
v_mytab(idx) := SUBSTR(p_i_list, v_start_pos, (LENGTH(p_i_list) - v_start_pos + 1));
ELSE
v_mytab(idx) := SUBSTR(p_i_list, v_start_pos, (v_next_pos - v_start_pos));
END IF;
v_start_pos := v_next_pos + 1;
EXIT WHEN v_start_pos > LENGTH(p_i_list);
idx := idx + 1;
END LOOP;
FOR j IN 1..idx
LOOP
v_mytab(j) := RTRIM (v_mytab(j), ',');
-- dbms_output.put_line (v_mytab(j));
v_fin_text := v_mytab(j);
INSERT INTO temp_a VALUES (TRIM(v_fin_text));
END LOOP;
COMMIT;
INSERT INTO temp_b
SELECT element_data
FROM xbrl2, temp_a
WHERE UPPER(erp_fields) = UPPER(temp_a.a_text)
     ORDER BY b.rowid;
SELECT count(1)
INTO v_final
FROM temp_b;
FOR v_temp_b IN c_temp_b
LOOP
IF v_count = 1 THEN
IF v_final = 1 THEN
v_name := v_temp_b.b_text;
ELSE
v_name := v_temp_b.b_text || ', ';
END IF;
ELSIF v_count < v_final THEN
v_name := v_name || v_temp_b.b_text || ', ';
ELSE
v_name := v_name || v_temp_b.b_text;
END IF;
v_count := v_count + 1;
END LOOP;
v_sql := 'CREATE OR REPLACE VIEW vw_a_new2 (' || v_name || ' ) ' ||
'AS ' ||
'SELECT ' || p_i_list || ' FROM xbrl1 ' ||
               'ORDER BY xbrl1.rowid';
ELSE
SELECT count(element_data)
INTO v_final
FROM xbrl2;
FOR v_main IN c_main
LOOP
IF v_count = 1 THEN
v_name := v_main.element_data || ', ';
ELSIF v_count < v_final THEN
v_name := v_name || v_main.element_data || ', ';
ELSE
v_name := v_name || v_main.element_data;
END IF;
v_count := v_count + 1;
END LOOP;
DBMS_OUTPUT.PUT_LINE (v_name);
v_sql := 'CREATE OR REPLACE VIEW vw_a_new (' || v_name || ' ) ' ||
'AS ' ||
'SELECT * FROM xbrl1 ' ||
                    'ORDER BY xbrl1.rowid';
END IF;
EXECUTE IMMEDIATE v_sql;
END sp_a_new_2;
Exec sp_a_new('je_line_num,entered_dr');
select * from vw_a_new;

Similar Messages

  • Please help to re-write this query using exists or with

    Hi please help to re-write this query using exists or with, i need to write same code for 45 day , 90 days and so on but sub query condition is same for all
    SELECT SUM (DECODE (t_one_mon_c_paid_us, 0, 0, 1)) t_two_y_m_mul_ca_
    FROM (SELECT SUM (one_mon_c_paid_us) t_one_mon_c_paid_us
    FROM (
    SELECT a.individual_id individual_id,
    CASE
    WHEN NVL
    (b.ship_dt,
    TO_DATE ('05-MAY-1955')
    ) >= SYSDATE - 45
    AND a.country_cd = 'US'
    AND b.individual_id in (
    SELECT UNIQUE c.individual_id
    FROM order c
    WHERE c.prod_cd = 'A'
    AND NVL (c.last_payment_dt,
    TO_DATE ('05-MAY-1955')
    ) >= SYSDATE - 745)
    THEN 1
    ELSE 0
    END AS one_mon_c_paid_us
    FROM items b, addr a, product d
    WHERE b.prod_id = d.prod_id
    AND d.affinity_1_cd = 'ADH'
    AND b.individual_id = a.individual_id)
    GROUP BY individual_id)
    Edited by: user4522368 on Aug 23, 2010 9:11 AM

    Please try and place \ before and after you code \Could you not remove the inline column select with the following?
    SELECT a.individual_id individual_id
         ,CASE
            when b.Ship_dt is null then
              3
            WHEN b.ship_dt >= SYSDATE - 90
              3
            WHEN b.ship_dt >= SYSDATE - 45
              2
            WHEN b.ship_dt >= SYSDATE - 30
              1
          END AS one_mon_c_paid_us
    FROM  items           b
         ,addr            a
         ,product         d
         ,order           o
    WHERE b.prod_id       = d.prod_id
    AND   d.affinity_1_cd = 'ADH'
    AND   b.individual_id = a.individual_id
    AND   b.Individual_ID = o.Individual_ID
    and   o.Prod_CD       = 'A'             
    and   NVL (o.last_payment_dt,TO_DATE ('05-MAY-1955') ) >= SYSDATE - 745
    and   a.Country_CD    = 'US'

  • Who can help me? write this code?

    Write java code print prime number like this
    Sample Screen Print:
    Initial matrix with N = 37
    2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    31 32 33 34 35 36 37
    Intermediate results (after 1st iteration)
    2 3 5 7 9
    11 13 15 17 19
    21 23 25 27 29
    31 33 35 37
    Intermediate results (after 2nd iteration)
    2 3 5 7
    11 13 17 19
    23 25 29
    31 35 37
    Intermediate results (after 7th iteration)
    2 3 5 7
    11 13 17 19
    23 29
    31 37
    Final results
    2 3 5 7 11 13 17 19 23 29
    31 37
    How to write this code ?
    Please Help me!
    Thank you so muchhh ?????

    Looks like The Sieve of Eratosthenes.
    A google search for that should help you with some logic.
    Wikipedia has a really nice animation of how it works.
    Post back when you have some source code that you need help with.
    Thanks k???? lullzz???

  • Can someone help me re-write this Logo ?

    Hi all,
    I am new to this community but it looks like you try to help newbies like me.
    I am desperately trying to replace KOH with KONDOYO in this picture :
    I just cant find how to do so...And I'm a little in a hurry I must admit so if you could plz help me get something, it'd be the best, trully.
    Thanks in advance,
    Veerus

    This is the original jpeg that Im trying to modify. I dont have anything on Photoshop for now. And actually, the little time I have left is really ruining me...
    The dream would be that someone who's really good with Photoshop did the whole thing for me, I dont really care about the texture or the colour..
    I'd be very very very thankful !
    Stan

  • Please help me re write this query

    select case
    when MONTHS>=6 then YRS++
         else YRS
    end,
    from some_tab
    Edited by: user9027633 on Feb 25, 2010 1:44 AM

    Hi,
    It sounds like you want to round the length of service to the nearest year; the rounded figure may as much as 6 months more or less than the actual length of service.
    How to do that depends on your data.
    If you have 2 separate columns, months (a number, where 0 <= months < 12) and yrs (an integer) then you could say
    select  case
                when MONTHS >= 6 then YRS+1
                                 else YRS
            end     AS rounded_service_years
    from    some_tab
    ;but you might find it easier to say:
    select  ROUND (yrs + (months / 12))     AS rounded_service_years
    from    some_tab
    ;

  • I have a mac book pro and have already downloaded adobe flash player. However when i go to watch a video it says "Block Plug In". But my adobe is already up to date. Can someone help me to fix this so i can watch videos?

    I have a mac book pro and have already downloaded adobe flash player. However when i go to watch a video it says "Blocked Plug In". But my adobe is already up to date. Can someone help me to fix this so i can watch videos?

    If you're sure you've installed the latest version of Flash, take each of the following steps that you haven't already tried. After each step, relaunch Safari and test. For a "missing plug-in" error, start with Step 7. Back up all data before making any changes.
    Step 1
    You might have to log out or reboot before a Flash update takes effect.
    Step 2
    In the Safari preference window, select
    Privacy ▹ Remove All Website Data
    Close the window. Then select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Delete All. Close the preference pane.
    Step 3
    If you're only having trouble with YouTube videos, log in to YouTube and load this page. You may see a link with the text "Leave the HTML5 Trial." If so, click that link.
    Step 4
    If you get a warning of a "blocked" or "outdated" plug-in, then from the menu bar select
     ▹ System Preferences… ▹ Flash Player ▹ Advanced
    and click Check Now. Quit and relaunch the browser.
    If the warning persists, triple-click anywhere in the line below on this page to select it:
    /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources
    Right-click or control-click the highlighted text and select
    Services ▹ Open
    from the contextual menu.* A folder should open. Inside it, there should be a file named "XProtect.meta.plist". If that file is missing and you know why it's missing, restore it from a backup or copy it from another Mac running the same version of OS X. Otherwise, reinstall OS X.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combination command-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.
    Step 5
    Open this folder as in Step 4:
    /Library/Internet Plug-Ins
    Delete the following item, or anything with a similar name, if present:
    Flash Player (failing).plugin  
    You may be prompted for your login password.
    Step 6
    Re-download and reinstall Flash. Download it from the domain "get.adobe.com". Don't click a link from any other website, including this one, because you can't trust links. They may be an attempt to trick you into installing malware masquerading as Flash. Type the address into the browser window. Never download a Flash update from anywhere else.
    Step 7
    If you get a "missing plug-in" error, select
    Safari ▹ Preferences... ▹ Security
    from the Safari menu bar and check the box marked
    Allow (or Enable) plug-ins
    Then click the button marked
    Manage Website Settings...
    if present and make sure that the website is not blocked for Flash.
    Step 8
    Select
    Safari ▹ Preferences... ▹ Extensions
    from the Safari menu bar. If any extensions are installed, disable them.

  • Who can help me write this Java code show the prime number ???? PLEASEEEEEE

    Write java code print prime number like this
    Sample Screen Print:
    Initial matrix with N = 37
    2 3 4 5 6 7 8 9 10
    11 12 13 14 15 16 17 18 19 20
    21 22 23 24 25 26 27 28 29 30
    31 32 33 34 35 36 37
    Intermediate results (after 1st iteration)
    2 3 5 7 9
    11 13 15 17 19
    21 23 25 27 29
    31 33 35 37
    Intermediate results (after 2nd iteration)
    2 3 5 7
    11 13 17 19
    23 25 29
    31 35 37
    Intermediate results (after 7th iteration)
    2 3 5 7
    11 13 17 19
    23 29
    31 37
    Final results
    2 3 5 7 11 13 17 19 23 29
    31 37
    How to write this code ?
    Please Help me!
    Thank you so muchhh ?????

    h2. {color:#ff0000}Multiplepost{color}
    Replies here: http://forum.java.sun.com/thread.jspa?threadID=5241012&tstart=0
    There is a useful answer the original thread. Answer it, or ignore it as you like, but don't create multiple threads.

  • I have Mac OSX maxmini; Safari states "can't open server since starting with 'open-help-anchor'.  How do I get into the web site this is blocking?

    I have Mac Mini OSX 10.6.2; Safari states "can't open server since url starting with 'open-help-anchor'.  I didn't type this but possibly I was hijacked but it only occurs on the specific banking site I'm trying to get into.  How do I get into the web site I've always been able to get but now this is blocking it?   Is this related to cookies?

    https://discussions.apple.com/message/25085868#25085868
    I started a thread in safari maverics, I ment to put it in iOS Safari.  New Thread lists all the steps I've taken.  No I haven't tried another browser.  I've only ever used Safari on my iDevices.

  • Help me to solve this. select statement!

    hello alll
    is there any functional module which gives me the BELNR(of bseg) by passing the vbeln.
    yeah ...we can do tht by passing bseg table ,,,,but its taking loads of time to give me the output as its not a primary key or secondary key.....
    when i m using this condition in the prog i cannot use inner join as its a cluster table . if i m writing a condition it is effecting my prog performance
    this statement is really taking long time to process.
    in bseg table as vbeln is not primary key or seconday key, i guess thz the reason it is taking so much time ,,,
    can anyone help me to sort this out... ??
    any fun mod to get the data of bseg cluster table by giving vbeln?/
    or any other conditions to reduce the processing time?
    clear t_vbrkvbrp.
    sort t_vbrkvbrp by vbeln.
    loop at t_vbrkvbrp.
    at new vbeln.
    select bukrs belnr vbeln
    from bseg
    into corresponding fields of table t_temp
    where bukrs = t_vbrkvbrp-bukrs
    and vbeln = t_vbrkvbrp-vbeln.
    endat.
    endloop.
    SELECT bukrs belnr buzid koart shkzg dmbtr vbeln hkont kunnr werks
    FROM bseg
    INTO TABLE t_bseg
    for all entries in t_temp
    WHERE hkont IN s_hkont
    AND bukrs = t_temp-bukrs
    AND belnr = t_temp-belnr
    AND buzid = ' '
    AND koart = 'S'
    AND shkzg = 'H'.
    i need to get the g/l account number and belnr from bseg for the above condition type so i have to use bseg table
    as there is no apporpriate index it is scanning the full table ,,,, so can anyone tell me how to create a index or like wise to get the data faster??

    Don't use BSEG, use BKPF and fields AWTYP, AWREF which link a financial document to the application and document that generated it. (The "original document" under transaction like FB03)
    <i>Example: "RMRP" + invoice number for purchase invoice</i>
    In  some case you need an intermediate table
    <i>Example: from EKPO, EKBE, you get the MKPF records and from them the BKPF/BSEG</i>
    For a list of "referenced procedures" Look at TTYP (text table is TTYPT), you will get the code, structure used to build the key (if more than one field) and a function module used to display the origin
    <i>Example :  MKPF "Material document" structure MKPF_AWKEY function module MB_DOCUMENT_SENDER_MKPF</i>
    You can also look at your accounting documents found with the "slow" BSEG version of your program and establish a list of AWTYP used in you company/customer.
    An other way, used in some companies, is to append a structure with EBELN field to BSIS and BSAS table, these table are filled via a MOVE-CORRESPONDING statement, so the nesw records will be filled (You may write a program to update past records) then create an index on EBELN on these fields.
    Regards
    PS: BSEG is a cluster table, so the only real criteria are the primary keys, if you select via EBELN, the program read the whole table, may be correct in Development, but not in Production and there it will be more and more resources consuming. So NEVER select from BSEG vithout the primary keys, use the secondary tables : BSIS/BSAS, BSIM, etc.

  • Help me to solve this assignments...

    1. Write a program to print a triangle multiplication table as shown below:
    0
    0 2
    0 3 6
    0 4 8 12
    0 5 10 15 20
    0 6 12 18 24 30
    0 7 14 21 28 35 42
    2.Write a Java program that will display the factorial of the number 10.
    3.Write a Java Program to display a four by four identity matrix
    4.Write a program to calculate the sum of the odd integers between 1 and 99 using for loop.
    kindly help me to solve this assignment.

    Am I correct in all???
    class Assignment
         public static void main(String args[])
              //This is to print the numbers in triangle
              for(int i = 1; i < 8; i++)
                   for(int j = 0; j < i; j++)
                        System.out.print(" " + i*j);
                   System.out.println("");
              //print value for 10 factorial
              int factorialvalue=1;
              int f=6;
              for(int l=f;l>1;l--)
                   factorialvalue*=l;
              System.out.println("F values is "+factorialvalue);
              //4 x 4 Matrix
              for(int s=0;s<4;s++)
                   for(int m=0;m<4;m++)
                        System.out.print("("+s+","+m+") ");
                   System.out.println("");
              //sum of odd numbers up to 99
              int h=0;
              for (int b=1;b<10;b+=2)
                   h+=b;
              System.out.println("Sum is "+h);
    selva.

  • Mid 2007 iMac SSD in optical bay - cannot write to last block of device

    Hi All,
    I've just replaced my optical drive in my 20" mid 2007 iMac (Dual core, 2.4 Ghz, 2 Gb RAM running Mavericks) with a solid state drive (Crucial MX100). The plan is to transfer my boot disk to this drive while keeping my 1 Tb HDD for media and such.
    I followed the ifixit guide and it all went smoothly, however when I try to partition or erase the new SSD using Disk Utility, it tells me "Operation failed - cannot write to last block of the device". After googling, I found some answers here that suggested the optical bay cable may be faulty, so I bought a replacement and swapped it in, but no such luck, same problem. I also saw some threads suggesting that the boot disk should be in the original hard drive spot, but since this isn't the boot disk (yet) this shouldn't be the issue.
    My computer recognizes the new SSD but won't allow me to partition it. Any suggestions on how to proceed?
    Thanks!

    ds store wrote:
    3. The new disk is just bad.
    OK. If that's the case, I'll just get another disk.
    Lots of problems with that hybrid drives on Mac's on these forums, get another one that's 7,200 RPM and from Western Digital, not Seagate.
    With a 7,200 RPM you get more performance across the entire drive, not just what's cached in the small flash portion of the hybrid.
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents#/
    1. Hybrid drives: I'm on number 8 in 6 different machines, no problems at all, what happens when you try?
    2. The OP is not using a Hybrid.
    3. Lot's of problems with WD drives not booting on these forums though.

  • How to write this sql query in php code ?

    for example:
    insert into temp
    select *
    from testtable;
    after this, i will query data from sql below:
    select *
    from temp;
    how to write this php code ?
    who can help me ?
    thanks!

    Have a look at the manual to find out how to issue queries.
    http://us3.php.net/oci8

  • Help needed to write a dialog program

    Hello ABAP Gurus,
    I am very much new to ABAP Programming.
    Can anybody help me to write a simple Dialog Program ??
    I have a database table.
    I have created a screen with screen painter, and kept some input fields & a push button in it.
    I want to fill the database table with the data entered into the fields on the screen.
    When the user enters the data and  presses  the PUSH BUTTON then that data record should be stored into the Database table.
    So what kinda code I have to write in PAI (Process After Input),  to achieve this functionality ??
    The help will be greatly appreciated.
    Thanks in advance
    Best regards
    Ravi
    Edited by: Ravi Kiran on Oct 28, 2009 2:17 PM

    It's easy:
    In PAI you have do an insert into a database table, following the steps:
    1.on PAI  create a module: for exemple Zwrite_table.
    2. inside Zwrite_table code as follow:
    move var1 to wa_table-var1.
    move var2 to wa_table-var2.
    move var3 to wa_table-var3. etc etc
    insert table ztable from wa_table.
    P.s. ztable is a database table.
    wa_table is a structure that have the same structure of ztable.
    var1 var2 var3 etc is a variable inside your dynpro.
    regards,
    Roberto.

  • How can i combine a string array with a waveform array and write this to a file.

    I am trying to set my VI up so that I can enter test information (notes to myself) and combine that with the time and date then write this as well as the waveform data from the daq to a spreadsheet file.  I am sure this is a simple task but I am new to LabView so any help would be very appreciated.

    An XML file is not a spreadsheet-formatted file, so that's not likely to help...
    Simply call the Write To Spreadsheet File twice. The first time you wire in a 1D array of strings
    which is your test information. Then, you call it when you're writing out
    your data. Make sure you wire a True constant to the "append" input for
    that function.

  • Which planning function i have to use and how to write this planning fucnti

    Hi Bi Guru's,
    I have rolled out  BW SEM-BPS Planning Layout's for the Annual Budget in my organistaion.
    There are two levels of layout given for the each sales person.
    1)  Sales quantity to be entered Material and  country wise for all 12 months ( April 2009 to March 2010)
    2)  Rate per unit and to entered in second sheet, Material and country wise for the total qty entered in the first layout.
    Now i need to calculate the sales vlaue for each period and for the each material.
    Which planning function i have to use and how to write this planning fucntion.
    Please suggest me some solution ASAP.
    Thanks in Advance,
    Nilesh

    Hi Deepti,
    Sorry to trouble you...
    I require your help for the following scenario for caluclating Sales Value.
    I have Plan data in the following format.
    Country   Material    Customer    Currency    Fiscyear    Fiscper           Qty         Rate        Sales Value
    AZ          M0001      CU001          #             2009          001.2009        100.00                        
    AZ          M0001      CU002          #             2009          001.2009        200.00                        
    BZ          M0001      CU003          #             2009          001.2009        300.00
    BZ          M0001      CU003          #             2009          002.2009        400.00
    BZ          M0002      CU003          #             2009          002.2009        300.00
    AZ          M0001       #               USD          2009             #                                 10.00
    BZ          M0001       #               USD          2009             #                                 15.50
    BZ          M0002       #               USD          2009             #                                 20.00
    In the Above data the Rate lines are entered in the Second Layout, Where the user enters on the Country Material Level with 2009 value for FISCYEAR.
    I am facing problem with this type of data. 
    I want to store the sales value for each Material Qty.
    Please suggest some solution.
    Re
    Nilesh

Maybe you are looking for