create new tab with the name of the pass and the data type of the tab & ranks on the b tab

Hello

I'm really struggling with this.
Have two tables A and B
A is a table with columns, tag_label, tag_colmn code
-------------------------------------------------------------
CODE | TAG_LABEL | TAG_COLMN_NAME
-----------------------------------------------------------
023. Registration | CHAR_TAG1
023. Contract number | NUM_TAG1
023. Agency | NUM_TAG2

B is an operating table with code, CHAR_TAG1, CHAR_TAG2, NUM_TAG1, NUM_TAG2...
----------------------------------------------------------------------------------------------------------------------------
CODE | CHAR_TAG1 | CHAR_TAG2 | NUM_TAG1 | NUM_TAG2......
----------------------------------------------------------------------------------------------------------------------------
023. 420/09 | -- || 100023 | 1002
021 | -- || 400030 | -- || --
023. 450/10 | -- || 100025 | --


I need to create a dynamic new table or view C from these two with
----------------------------------------------------------------------------------------------------------------------------
CODE | REGISTRATION | CONTRACT NUMBER | AGENCY NUMBER
----------------------------------------------------------------------------------------------------------------------------
023. 420/09 | 100023 | 1002
023. 450/10 | 100025 | --

That's when my Jdeveloper, I will be able to get a view with table C object.
If you see C, there new column names, derived from the Tag_label of the table A column names and the lines are filled with the values from table B corresponding to the tag_column_name of the column of table A

Is it possible to do so. This is very important because it is the main part of my project and I'm stuck on this.

Kind regards.

Published by: user10264958 on August 21, 2010 22:28

Try this:

CREATE OR REPLACE PROCEDURE MAKE_VIEW
IS
    L_SQL VARCHAR2(32767);

    TYPE A_TAB_TYP IS TABLE OF A%ROWTYPE;
    A_TAB A_TAB_TYP;

    L_COMMA varchar2(10);
BEGIN
    SELECT * BULK COLLECT INTO A_TAB FROM A;
    IF SQL%NOTFOUND THEN
        RAISE_APPLICATION_ERROR( -20999, ' Table A is empty ' );
    END IF;
    L_SQL := 'CREATE OR REPLACE VIEW C AS SELECT';

    L_COMMA := ' ';
    FOR I IN A_TAB.FIRST .. A_TAB.LAST
    LOOP
        L_SQL := L_SQL || L_COMMA;
        L_SQL := L_SQL || A_TAB( I ).TAG_COLMN_NAME ||
              ' "' || A_TAB( I ).TAG_LABEL || '" ';
        L_COMMA := ',';
    END LOOP;
    L_SQL := L_SQL || ' FROM B WHERE ';

    L_COMMA := ' ';
    FOR I IN A_TAB.FIRST .. A_TAB.LAST
    LOOP
        L_SQL := L_SQL || L_COMMA;
        L_SQL := L_SQL || A_TAB( I ).TAG_COLMN_NAME ||
              ' IS NOT NULL ';
        L_COMMA := ' OR ';
    END LOOP;
    EXECUTE IMMEDIATE L_SQL;
END MAKE_VIEW;

DROP VIEW C;
EXECUTE MAKE_VIEW;

SELECT * FROM C;

 DROP VIEW C succeeded.
anonymous block completed
Registration AGREEMENT NUMBER       Agency
------------ ---------------------- ----------------------
 420/09      100023                 1002
450/10       100025                                        

Tags: Database

Similar Questions

  • srvrmgr syntax: How can I create subsystem named with the name and Description of the values?

    Looking through the library, he did discuss are of syntax that allows you to include the value of name and the named value of the Description of a subsystem/Profile Configuration.  In the screenshot, the circled values were created with the server online order Manager.

    NamedSubsystems.gif

    On the other hand, pouvez create a definition of the element with a name (full name) and a Description.

    For CompDef, it works:
    create the CompDefTest1_enu component definition for the type of component AppObjMgr component fins group run mode interactive full name 'Test Comp Def Test 1' description 'Test 1 CompDef Manager object.

    For named Subsytem, it does NOT work:
    create named subsystem Test5 subsystem EAITransportDataHandlingSubsys full name 'Test 5' description 'Test 5 Description'

    Someone can tell me if there is a good for a named subsystem, syntax to include the name and Description of the values in the command line, or is the only way to create it manually in the UI?

    Hello

    I spent reviewing aid to create the order in srvrmgr, it does not give the full name and description as parameters for the creation of subsystem. However, as you noted these settings are available for creating components definition:

    srvrmgr > help to create

    Create {component group | compgrp}

    [full name: ]

    [{description | desc} ]

    create {definition component: compdef}

    for {component type | comptype}

    {Component group | compgrp}

    run in mode {batch | interactive | background}

    [full name: ]

    [{description | desc} ]

    [with [ param =[, =...]]]

    [[fixparam =[,...]]]

    create the subsystem named for

    subsystem with = [,...]

    Shelf also has an example of creation of subsystem that doesn't include no description, name and first name:

    http://docs.Oracle.com/CD/E14004_01/books/StoreFwdMsg/StoreFwdMsg_InstallConfig14.html#wp1351472

    In this case I suggest that allows you to create a ticket on My Oracle Support to confirm this srvrmgr does not support the creation of a new subsystem with the full name and description settings and request an enhancement for these settings include request in create statement for new subsystems when using srvrmgr.

    It will be useful,

    WSiebel

  • Server data store will automatically get updated when the new file (with the same name) is placed in the landing area


    Hi guys,.

    The data store server-side will get automatically updated when a new file with the same name is loaded in the landing area?

    for example

    1 data store created for server-side get the file named UK.xls (he has 5 rows)

    2 snapshot created for the above data store

    3. created with the snapshot process

    After that if I remove 2 lines from the same file and load again to the landing (with the same name). So by re-running the process will take the last file OR do I need to reload the file in the data store every time when there is a change in the file. We also tried with option to work but the last file was not picking up.

    Any help will be really appreciated.

    Please lets us know your updates.

    Please advice

    Thank you

    VT

    Hello

    When you create a snapshot, you create a snapshot whose task (provided that you use a data store server-side) can be run from a job. To refresh the data, run the snapshot in a job task. If you create a task at the time the snapshot and the processes that use it, they will automatically connect and will be 'upstream' data through the snapshot in the process. You can then choose whether it would be appropriate to write the snapshot or not (for the effectiveness of performance if you want to do the straight through processing) by activating or deactivating the bucket of data staged that the snapshot written to. The snapshot in the work task means that the data is refreshed.

    For the work of design to the Director, you can refresh the snapshot by running again it manually in the context menu.

    Kind regards

    Mike

  • Problem with 'Create new Extrusion of the selected layer' CC 2014

    Hello, I am experienced with Photoshop but I'm new to 3D text in Photoshop.  I type the text and convert it to a form.  When I choose to create new Extrusion of the selected layer I get the dialog, I don't see in tutorials.  It says "you are about to create a 3D layer.  You want to switch to the 3D workspace?  Yes/No, do not display again. "Which one should I use for the 3D text?

    If I choose Yes, all the panels disappear and the content in the tool options bar (Ribbon?) just under the menu bar disappears.  I have to restart Photoshop to get back on the tool options.  What could I do it wrong?

    Thanks - Dave

    I just chose 'No' and don't look at back.  I love my workspace, just as it is and doesn't prefer Photoshop to change for me in this case especially.

    You bring up the 3D Panel yourself via the window - 3D.  I think it's a good alternative for the Actions Panel, because I don't have any currently working in the 3D world.

    You'll want to see easily if you are working on 3D are 3D Panel and panel properties, among a few others.

    Regarding return your workspace as you like it...  Note the small switch near the upper right of the main window of Photoshop.  That can be used to select a workspace.  I suggest that you experiment and familiarize yourself with the concept of workspaces.  You can set your own and save it with a name, and that can really be useful.

    -Christmas

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • Windows 7 unable to create new folder on the desktop, the names are automatically names of birds, pigeon, hawk and Turkey

    someone had this problem and how to fix it?

    N ° hold it down. I bet you use a software called ALZip?
    If so, while the software is name these new folders with bird names...
    Read here: http://www.altools.com/Support/faq.aspx?&articleIdx=43&m=3

    Beep beep

  • I need to update the screenshots for a new version of an app existing Itune application to download a new version. Since I did not create the original version, can you guide me how to create a new version with the new version number?

    I need to update the screenshots for a new version of an existing iTunes Connect App asks me to download a new version. Since I did not create the original version, can you guide me how to create a new version with the new version number?

    You must call the assistance of the company and ask them to help you with this. You can find contact information by logging on http://digitalpublishing.acrobat.com/ and looking at the Middle at the bottom of the page.

    Neil

  • How to create two employees with the same name as the vendor record?

    Hi all

    We must create a vendor for the employee record, so that we can issue pretty invoice for cash payment. If there are 2 employees with the same name, how can we create records of supplier for these 2 employees? The system does not have the name of the provider in duplicate.

    Please notify.

    Kind regards
    HY

    Hello

    In R12, it is possible to create 2 employee with the same name but with a different number.
    And it is also possible to create these 2 employees as suppliers in Payables.

    HTH,
    Vik

  • Create new files at the beginning of each hour

    I'm writing a VI to store data in text file. To avoid a too large file, I want to store data in different files. I want these files must be created at the beginning of each hour. How could I achieve this?

    Thanks in advance!

    Many people like to have a timestamp in their file name.  What makes it unique and gives information on the time of creation of the file.  Here's some code that will create a new file with timestamp name every hour on the hour.  It checks every second to see if the part of the minutes of the time string is '00 '.  If so, it then creates a file name.  The date string sole custody from day to day.

    Oops. Just noticed a flaw.  The code creates a new file name every second as long as the record is 00.  Changing the value of within one minute (60000) should solve the problem.

  • How to restore backup rman to the new host with the structure of the various files on windows?

    Here are the steps that I follow...

    1 oradim create new instance

    2 startup nomount pfile = 'C:\inittest.ora'

    3. restore conrolfile of 'c:\name.bak '.

    I found this file control point to the oradata folder as directed by the original host

    4. Alter database mount

    Mounted DB.

    5 restore database completed with error

    switch to the previous backup

    RMAN-00571: ==================================================

    RMAN-00569: = ERROR MESSAGE STACK FOLLOWS =.

    RMAN-00571: ==================================================

    RMAN-03002: failure of the restore command at the 12:17:55 08/12/2014

    RMAN-06026: some targets not found - abandonment of restoration

    RMAN-06023: no backup or copy of the file 4 found to restore

    RMAN-06023: no backup or copy of datafile 3 found to restore

    RMAN-06023: no backup or copy of datafile 2 found to restore

    RMAN-06023: no backup or copy of datafile 1 found to restore

    So, it is possible to restore and recover the rman backup to the new host with the structure of different file...?

    Hello

    Try to rename the log file to roll forward online to the desired path on the destination server, and then open with resetlogs.

    SQL > alter database file rename ' G:\APP\ORADATA\HOOP\REDO01. JOURNAL "to"";

    Kind regards

    Shivananda

  • I'm trying to migrate data from a server to a new one with the file permissions of the files of users and records lost.

    original title: robocopy

    I'm trying to migrate data from a server to a new one with the file permissions of the files of users and records lost. So far, that's what I did, I used \\server1\share \\server2\share/sec /mir robocopy and robocopy \\server1\share \\serve2\share/e/s /copyall. It seams like they copied all files with the permissions of the user for the files, but not files. For example, if a user makes a folder with the files in the folder appear them have permissions appropriate for them but not the root folder or subfolders, they did... How can I fix this and what is the difference between / s /mir and/e/s /copyall?

    Hello

    You can find the Server forums on TechNet support, please create a new post at the following link:

    http://social.technet.Microsoft.com/forums/en/category/WindowsServer/

  • I can't see changes in a folder unless I go up a level and then re-enter folder, for example, create new folder, rename the folder, rotate the image etc. Can someone please?

    I do not see changes within a folder, except if I go up a level and then again enter the folder, for example, create new folder, rename the folder, rotate the image, etc..

    By pressing the "F5" key would probably be to refresh the folder.

    See if this article helps you with this problem:

    "List of the files in the Windows Explorer folder is not refreshed after that you create, move, or delete files"
      <>http://support.Microsoft.com/kb/823291 >

    HTH,
    JW

  • on windows xp, my system restore to a previous restore point. have you tried many restore points & creating new ones but the system does not restore. all the solutions out there?

    on windows xp that my system restore to a previous restore point, I tried many restore points & created new ones but the system displays "could not be restored", any help out there.

    Let see... What do we know about your system environment:

    It's windows xp.

    If we knew more, you would probably now.

    What is the problem that you are experiencing this thing you System Restore will be remedied?  System Restore is not a time machine.

    The system restore already worked successfully in the past?

    Thank you MS Answers, allowing the resolution of simple problems like frustrating and a lot of time as possible by asking only not for any information system when a new question is asked.

    Provide information on your system, the better you can:

    What is your system brand and model?

    What is your Version of XP and the Service Pack?

    Describe your current antivirus and software anti malware situation: McAfee, Symantec, Norton, Spybot, AVG, Avira!, MSE, Panda, Trend Micro, CA, Defender, ZoneAlarm, PC Tools, Comodo, etc..

    The question was preceded by a loss of power, aborted reboot or abnormal termination?  (this includes the plug pulling, buttons power, remove the battery, etc.)

    The afflicted system has a working CD/DVD (internal or external) drive?

    You have a true bootable XP installation CD (it is not the same as any recovery CD provided with your system)?

    If the system works, what do you think might have changed since the last time it did not work properly?

    Some tools Anti Virus 'protect' your system so that they will not allow a restore of the system work properly.
    For example, if you use Norton/Symantec products, you will see a message like this:
    Restoration incomplete. Your computer cannot be restored...
    It is also a popular Symantec problem (well, I'll be polite and call an "undocumented feature"...), they wrote an article about it:
    According to what you use for malware protection, you may need to disable the product temporarily, do the system restore and then turn the products light up again when the system restore is complete.
    Sometimes you need start your system in Mode safe and so that your protection programs are not running, and then do the system restore.  Tips from Microsoft in some of their articles that if the system restore does not restore your computer, start in Safe Mode, and then run the system restore.  It works for some configurations.
    System Restore is sometimes so afflicted or Restore Points are suspicious, the best solution is to reinstall your system restore.  This will remove the old Restore Points, but sometimes it's the only way to fix a broken system restore.  You don't have to reinstall XP, only the part of system restore.
    That can leave you with your problem of unspecified origin that you hope the system restore will fix (using a system restore is usually not equivalent to fixing the problem though).
    Give these ideas some consideration if they apply to you.
    Sometimes malicious will afflict your system restore to prevent you to find and remove malware.  It would much rather you trick into thinking that you need to repair or reinstall your XP when it is not necessary.
    No matter what you use for protection against malware, I do so and then only begin to solve any problems:
    Download, install, update and do a full scan with these free malware detection programs can solve any problems:
    Malwarebytes (MMFA): http://malwarebytes.org/
    SUPERAntiSpyware: (SAS): http://www.superantispyware.com/
    It can be uninstalled later if you wish.
    The scans by operating clean, reboot, test and we can fix any other issues.
  • tried to create an account with xbox (software on my computer) and it won't let me download anything from there. Is there a setting I need to change or take it back to the store?

    I just bought a new laptop about 4 days ago. It came with 10 Windows. The problem I have is, it does not download anything. I tried to share a youtube video, and it wouldn't let me. I tried to create an account with xbox (software on my computer), and it won't let me download anything from here. Is there a setting I need to change or take it back to the store?

    Thank you

    Michelle

    Hi Michelle,

    Thanks for posting your query on the Microsoft Community.

    According to the description, I understand that you are unable to download anything.

    I would like to know some information.

    1. You are connected to the internet?

    2. You get no matter what error code or error message?

    Please check the date and time system and check if it is up-to-date.

    If it is not set correctly, please follow the link to change the date and time:

    http://Windows.Microsoft.com/en-us/Windows-8/clock-out-of-sync

    I suggest you follow the steps to run the internet connection Troubleshooter:

    Follow the steps below:

    (a) affects Windows and x together and select Control Panel.
    (b) click on troubleshooting.
    (c) click show all in the left side panel.
    (d) click on Internet connections.
    (e) follow the on-screen instructions to resolve this problem.

    Hope this information helps. Please let us know if you need any other help with Windows in the future. We will be happy to help you.

  • What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    Mr President.

    What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    --SL_CUSTOMERS table data
    
    
    INSERT INTO SL_CUSTOMERS VALUES(1,'Kamrul Hasan',NULL,NULL,'Moghbazar', 'Dhaka','0456789123',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(2,'Rabiul Alam',NULL,NULL,'Motijheel', 'Dhaka','0567891234',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(3,'Shahed Hasan',NULL,NULL,'2-G/1,2-2,Mirpur', 'Dhaka','0678912345',NULL,NULL,NULL,'Y',NULL);
    
    
    
    

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG 
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"   
    FOR EACH ROW   
    BEGIN   
    IF :NEW.CUSTOMER_ID IS NULL OR :NEW.CUSTOMER_ID < 0 THEN  
      SELECT SL_CUSTOMERS_SEQ.nextval   
        INTO :NEW.CUSTOMER_ID  
        FROM DUAL;   
      END IF;   
    END;   
    /
    
    
    
    

    When I try to insert several records with the seq.nextval it gives error

    violation of primary key.

    INSERT INTO "ALIZA"."SL_CUSTOMERS" (CUSTOMER_NAME) VALUES ('sdfsd')
    ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    One error saving changes to table "ALIZA"."SL_CUSTOMERS":
    Row 4: ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    
    
    
    

    Concerning

    Mr President.

    I find the solution by creating a function before the triiger

    as below

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    CREATE OR REPLACE FUNCTION get_SL_CUSTOMERS_vId RETURN VARCHAR2 AS
    BEGIN
       RETURN SL_CUSTOMERS_SEQ.NEXTVAL;
    
    END;
    /
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"
    FOR EACH ROW
    DECLARE
    dummy VARCHAR2(200);
    BEGIN
      dummy := get_SL_CUSTOMERS_vId();
      :NEW.CUSTOMER_ID := dummy;
    END;
    /  
    

    It works very well

    Thank you all for the suggestions.

    Concerning

  • How to compare the new values with the old values in triggers.

    Dear all,

    Please tell me how to compare the new values with the old values in triggers.

    Hi, the employee example is in the document. You'd better read yourself.

    CREATE OR REPLACE TRIGGER Print_salary_changes
      BEFORE DELETE OR INSERT OR UPDATE ON Emp_tab
      FOR EACH ROW
    WHEN (new.Empno > 0)
    DECLARE
        sal_diff number;
    BEGIN
        sal_diff  := :new.sal  - :old.sal;
        dbms_output.put('Old salary: ' || :old.sal);
        dbms_output.put('  New salary: ' || :new.sal);
        dbms_output.put_line('  Difference ' || sal_diff);
    END;
    /
    

Maybe you are looking for