Generate unrest of the declaration

It's been a long day and although I am sure that this shouldn't be too hard, I'm currently completely blocked.
In short:
All this boils down to: transform a bunch of strings separated by commas in instruction, but all the trees make it impossible for me to see the forest.
I know it can be done in several ways, but I'm afraid, as I am currently on the wrong path and/or missing the point.

Simplified example, this time I got the chance to use the version of database 11.2.0.3, so the latest integrated features can be used:
-- generating sample data:
with t as (
select  'TAB1,TAB2,TAB3,TAB4,TAB5' tabs
,       'PK1,PK2,PK3,PK4,PK5' pkeys
,       'FK1,FK2,FK3,FK4' fkeys
from    dual
)
--
select * from t;
Desired resultset (should be just a string, but I've indented for readability):
merge into tab5 e
using ( select d.fk4
        from   tab1 a
        ,      tab2 b
        ,      tab3 c
        ,      tab4 d
        where  a.pk1 = b.fk1
        and    b.pk2 = c.fk2
        and    c.pk3 = d.fk3
      ) q
on    (e.fk4 = q.fk4)
when matched then update set e.pk5 = e.pk5
delete where e.fk4 = e.fk4;
I started to split strings, juggling rownum, piece it all back, still the concatenation in keywords, etc, but nothing helped.
Here's my starting point sofar, but I now doubt, if this is the correct starting point:
select rownum rn2
,      t.*
from ( select rn
       ,      regexp_substr(tabs, '[^,]+', 1, rn)||' '||upper(chr(rn+96)) tabs
       ,      regexp_substr(pkeys, '[^,]+', 1, rn) pkeys
       ,      regexp_substr(fkeys, '[^,]+', 1, rn) fkeys
       from   t
       cross join ( select rownum rn
                    from ( select max(length(regexp_replace(tabs, '[^,]+'))) + 1 mx
                           from   t
                         )
                    connect by level <= mx
                  )
       order by rn desc
     ) t;
All pointers are more than welcome, thanks in advance!

Kind regards
Hoek

A version of brute force may be

with t as (
select  'TAB1,TAB2,TAB3,TAB4,TAB5' tabs
,       'PK1,PK2,PK3,PK4,PK5' pkeys
,       'FK1,FK2,FK3,FK4' fkeys
from    dual
),
a_from as
(select ' from '||ltrim(sys_connect_by_path(regexp_substr(tabs,'[^,]+',1,level)||' '||upper(chr(level + 96)),','),',') the_from
   from (select tabs,pkeys,fkeys,regexp_count(tabs,',') cnt
           from t
        )
  where connect_by_isleaf = 1
 connect by level <= cnt
),
a_where as
(select regexp_replace(sys_connect_by_path(upper(chr(level + 96))||'.'||
                                           regexp_substr(pkeys,'[^,]+',1,level)||' = '||
                                           upper(chr(level + 1 + 96))||'.'||
                                           regexp_substr(fkeys,'[^,]+',1,level),
                                           ' and '
                                          ),
                       'and','where',1,1
                      ) the_where
   from (select tabs,pkeys,fkeys,regexp_count(tabs,',') cnt
           from t
        )
  where connect_by_isleaf = 1
 connect by level <= cnt - 1
)
select 'merge into '||regexp_substr(tabs,'[^,]+',1,cnt + 1)||' '||upper(chr(cnt + 1 + 96))||chr(10)||
       'using (select '||upper(chr(cnt + 96))||'.'||regexp_substr(fkeys,'[^,]+',1,cnt)||chr(10)||
       (select the_from from a_from)||chr(10)||
       (select the_where from a_where)||chr(10)||
       ') q'||chr(10)||
       ' on ('||upper(chr(cnt + 1 + 96))||'.'||regexp_substr(fkeys,'[^,]+',1,cnt)||
       ' = q.'||regexp_substr(fkeys,'[^,]+',1,cnt)||') '||chr(10)||
       'when matched then update set '||upper(chr(cnt + 1 + 96))||'.'||regexp_substr(pkeys,'[^,]+',1,cnt + 1)||' = '||
                                        upper(chr(cnt + 1 + 96))||'.'||regexp_substr(pkeys,'[^,]+',1,cnt + 1)||chr(10)||
       'delete where '||upper(chr(cnt + 1 + 96))||'.'||regexp_substr(fkeys,'[^,]+',1,cnt)||' = '||
                        upper(chr(cnt + 1 + 96))||'.'||regexp_substr(fkeys,'[^,]+',1,cnt)||chr(10)
       the_merge
   from (select tabs,pkeys,fkeys,regexp_count(tabs,',') cnt
           from t
        )

THE_MERGE
--------------------------------------------------------------------------------
merge into TAB5 E
using (select D.FK4
 from TAB1 A,TAB2 B,TAB3 C,TAB4 D
 where A.PK1 = B.FK1 and B.PK2 = C.FK2 and C.PK3 = D.FK3
) q
 on (E.FK4 = q.FK4)
when matched then update set E.PK5 = E.PK5
delete where E.FK4 = E.FK4                                                      

Concerning

Etbin

Tags: Database

Similar Questions

  • How to translate the declaration C++ and C

    Hello

    I have a DLL that I want to use in a program developed by CVI (FDS version 8.5.1). DLL comes with documentation including a file include (* .h), where all function declarations are given. So usually I would just include this header file, unfortunately, this file was written for C++ and contains the declarations of functions of the following type:

    empty typedef (__stdcal * fp SOMETYPE) (double &, double &, long &, long).

    The compiler and I are confused by the '&' I know 'double' and ' double *', but not "double &'..." The same for the CVI that complains with an error of syntax, found '&' expected ')'.

    Then of course I have to manually translate this C++ C style header file - but I have no idea how to proceed... Maybe someone could help me? Thank you!

    It's been a while since I've done any C++, but as far as I know, you can again declare the function as:

    empty typedef (__stdcal * fp SOMETYPE) (double *, double * long *, long)

    in the header and call it from your code by passing the variables or pointers "address of".

    In this case, '&' in the function statement means "by reference."  It's a bit like pointers in C, but allowing the error checking (for example - cannot be NULL, cannot be re-assinged, etc.) and probably makes the compiler optimizations.  If you are interested in, search google for References C++, or you can check out wikipedia:

    http://en.Wikipedia.org/wiki/reference _ (C %2% B 2 B)

  • Line break WCF in the header/footer of the declaration

    Hello

    y there is it possible to force line breaks in headers or footers of the declaration? I'm on the way to develop my own report and you want to customize the header/foot a little more my way...

    Thanks and greetings

    Oliver

    I found the solution for me...

    Create your own text rendering engine and new lines of support set to true, now you can set line breaks with a normal entry in your text...

    If you know how, then, it's really easy...

    Thanks and greetings

    Oliver

  • How can I access the recipient "subordinate" in the expressions for the participant to ApprovalTask generator type "by the expression" value?

    Hello

    How can I access the recipient "subordinate" in the expressions for the participant to ApprovalTask generator type "by the expression" value?

    I can access some details of the beneficiaries of the workload, but how to access direct subordinates?

    TIA

    Leo

    Well, as I said, if you need to get a list of all rollover (for whatever logic you have), making calls to IOM to find the list of users whose Manager is the person in your composite.

    Sorry if I am wrong again.

  • How to set a partialTriggers for the declarative component

    12.1.3 jdev

    I try to set partialTriggers for my component declarative.

    From another forum, people suggested using one different name other than partialTriggers to avoid override a final method in RichDeclarativeComponent.

    Then, I set this:

    < afc:attribute >

    < afc:attribute - name > myPartialTriggers < / afc:attribute - name >

    < afc:attribute - class > java.lang.String [] < / afc:attribute - class >

    < / afc:attribute >

    and

    "< af:selectOneChoice id = simple =" #{attrs.simple "dc_droplist_soc"} "readOnly =" #{attrs.readOnly} "disabled =" #{attrs.disabled} ' "

    value = "#{uploading." "Value}" label = "#{attrs.label}" binding = "#{dropListComp.selectOneChoice}".

    "autoSubmit =" #{attrs.autoSubmit} "required =" #{attrs.required} "visible =" #{attrs.visible} ' "

    valueChangeListener = "#{dropListComp.handleValueChangeListener} '"

    partialTriggers = "#{attrs.myPartialTriggers} ' / >"

    But it does not work. I don't see a partialTriggers work.

    Any suggestions?

    Thank you.

    Hello

    try to use PartialTrigger on the declarative component and then reference it from

    partialTriggers = ' #{uploading. '. PartialTriggers}' / >

    Frank

  • How to define an attribute of the declarative component with the list of options

    12.1.3 jdev

    I'm trying to define a declarative component UOM. It has a text box with a selectOneChoice of the optional codes for this type of unit of MEASURE.

    I have uomType as one of the attributes of my unit of MEASURE. It may be of WEIGHT, VOLUME, LENGTH, etc. Is it possible to provide a list of the channels supported for my uomType? So, when the user uses this component, they can select a type they want in the list, instead of typing in themselves.

    < afc:attribute >
    < afc:attribute - name > uomType < / afc:attribute - name >
    < afc:attribute - class > java.lang.String < / afc:attribute - class >
    < afc: required > true < / afc: required >
    < / afc:attribute >

    Thank you.

    Hello

    Unfortunately the lists are not an option with the declarative elements

    Frank

  • "Not able to generate thumbnails for the article, it may be damaged or requires a more recent version of Muse.

    Hey guys,.

    I wonder if you have had this problem with the widget library (some widgets work again some of them don't; all in all I can't add more widgets on my page):

    "Not able to generate thumbnails for the article, it may be damaged or requires a more recent version of Muse.

    I have the latest version of Muse, I'm not sure of what is happeneing...

    Help, please!

    Screen Shot 2016-05-06 at 11.36.10 AM.png

    Hello

    I just tried this widget to my and and he is able to create a thumbnail in my library panel. Seems that there is a corruption with the files in the local library.

    I suggest you remove this widget in the library panel (select the item in the library panel and click on the trash can at the bottom right) and then add it back by double-clicking the file .mulib for the widget.

    Let me know if the problem persists.

    Kind regards

    Vivek

  • How to activate the keys to generate and view the AWR reports Developer SQL

    Version: 4.0.3.16

    Build: HAND - 16.84

    S/n > (sid) > Performance > AWR report viewer

    I am able to select the start and end ID, but the following buttons are disabled:

    • Entries Toggel
    • Generate the report
    • Save to file
    • Open in browser

    What needs to be done to enable these buttons?

    Hello

    After entering start Id and the Id of the end, the button "report" will be activated, and then after that the report generated (by clicking the report generate) rest buttons button is activated. As shown in the image below.

    Hope it will be useful.

    Kind regards

    Sanjaya

  • partial trigger on the declarative elements

    Hello

    I have a declarative component with many facets and a high component < af:panelGroupLayout >. I would like to refresh the entire component with PPR. In my page, I have a selectOneChoice with autoSubmit = 'true', but now I have to set the property partialTriggers to the declarative elements.

    So I created a new myPartialTriggers to attribute for declarative components as a string and changed the top element to < af:panelGroupLayout partialTriggers = "#{attrs.myPartialTriggers}" >. So now I can define the component property myPartialTriggers declarative the ID of the SelectOneChoice. It is not work that I get an exception:

    Error occurred: Houston-29000: Unexpected exception caught: java.lang.IllegalArgumentException, msg = cannot convert: c42:iflt9:dc_r2:dc_c2:naturalPersonSoc of type java.lang.String class at class [Ljava.lang.String;

    Thank you

    JDev 11.1.2.4

    Essentially, you surround the declarative component with a container and the container ppr. Read the whole story http://www.oracle.com/technetwork/developer-tools/adf/learnmore/005-how-to-bind-decl-comp-169123.pdf

    Timo

  • Anyone had any chance to get the 'Chat line' to answer a question, not to mention that the declarant is unavailable...

    Anyone had any chance to get the 'Chat line' to answer a question, not to mention that the declarant that it is not available at this time?

    Nevermind, I got a refund.

  • CC of Dreamweaver generates one of the 3 error messages when you use find and replace on 8.1 Win 64 bit.

    CC of Dreamweaver generates one of the 3 error messages when you use find and replace is used more than twice in a row. "While executing onLoad in bc_afterSave.htm, the following JavaScript error occurred: at line 188 of file C:\Program Files (x 86) \Adobe|. Adobe DreamweaverCC | Configuration | Shared | ' BC\JS\bc_sites.js': out of memory.

    or

    When executing RunCommand in File_Save.htm, a JavaScript erroroccurred.

    or

    While exciting getDynamicContent inAdressURL.htm, an erroroccirred of Javascript.

    Any thought - I find myself CBWMS of closing and reopening. Will work for the other two find and replace once again before the popup of messaged\s error.

    Cough, cough, cough - 38 500 pages? !  Really?  It's a big site!

    I'm not surprised, that you are short of memory.  Try to limit your F & R records or select files rather than the entire Site.

    Nancy O.

  • How to use the declarative component without deployed as JAR

    Hi all
    I want to create a reusable component (declarative component) for PanelHeader with default features packed in I want to use in my application. Because this component will be used only in my project, I don't see a use to go through the process of creating a jar and deploying it before using it. Is it possible to use this component without creating a JAR.

    Thank you
    -Srini.

    User 895137,

    your welcome to ignore the best practices in the development of the ADF. The declarative elements are deployed in the libraries of the ADF. If you keep the declarative component in the application then project you will have a chance to deploy independent of the application (which means that your ADF library contain more than just the source of the component (which is where your nightmare begins)). Therefore, best practices

    1. create the declarative component in a new project in JDeveloper. Follow

    http://download.Oracle.com/docs/CD/E21764_01/Web.1111/b31973/af_reuse.htm#BABJBFDD

    2. If you don't ant to deploy components in a tag library, use declarative dynamic components (will not deploy-able in many applications, as you mentioned your future plan is), as shown here

    http://download.Oracle.com/docs/CD/E21764_01/apirefs.1111/e12419/tagdoc/af_declarativeComponent.html
    http://download.Oracle.com/docs/CD/E21764_01/apirefs.1111/e12419/tagdoc/af_componentDef.html
    http://download.Oracle.com/docs/CD/E21764_01/apirefs.1111/e12419/tagdoc/af_xmlContent.html

    Frank

  • How to generate XSD to the basic service in CC &amp; B

    Anyone know how to generate XSD to the basic service in CC & B? Any suggestion would certainly help me. Thank you

    Take a look at the XAI best practices whitepaper that you can find on the Oracle Support under 942074.1

    Note that it is not recommended to use the schema editor to define the XSD for maintenance Object Services. Rather consider using Config tools.

  • 3.0 generated statement adds the column

    Hello

    usually, we have our data model changed in the Oracle Designer and the database is then passed under the generated script.

    Currently a developer asked me to make a quick change to a table, so it could test a code. That's why I used SQL Developer. The dialog box is simple, but I was expecting to see the generated code in the SQL tab I see in other tools. What follows is not very useful if you want to copy the code to run it again in the other plans ;-)
    var sql;
    if (prompt1 == 'NUMBER' && prompt1.length>0 && prompt3.length>0 ) {
      sql = 'alter table "' + OBJECT_OWNER + '"."' + OBJECT_NAME +'" add('+prompt0 + ' ' + prompt1 + '(' + prompt2 + ','+ prompt3 + '))';
    } else if ( ( prompt1 == 'NUMBER' && prompt1.length>0 && prompt3.length==0) ||  prompt1 == 'VARCHAR2' ) {
      sql = 'alter table "'+OBJECT_OWNER+'"."'+OBJECT_NAME+'" add('+prompt0+' '+prompt1+'('+prompt2+'))';
    } else {
      sql = 'alter table "'+OBJECT_OWNER+'"."'+OBJECT_NAME+'" add('+prompt0+' '+prompt1+')';
    }
    dbutil.execute(sql);
    Concerning
    Marcus

    Yes, using the built-in script. I need to change that to show the final sql script in use vs.

    -kris

  • Error message 'missing; before the declaration 24 "

    Hello

    I get the error message "missing; before the declaration 24 "in the following script:

    Create a variable to hold the document object

    var StartDate = (xfa.form.form1.page1.signature.StartDate.rawValue);
    var EndDate = (xfa.form.form1.page1.signature.EndDate.rawValue);
    var assocName = (xfa.form.form1.page1.signature.assocName.rawValue);
    assocID var = (xfa.form.form1.page1.subForm1.assocID.rawValue);
    var assocEmail = (xfa.form.form1.page1.subForm1.assocEmail.rawValue);
    var assocExt = (xfa.form.form1.page1.subForm1.assocExt.rawValue);
    var assocDept = (xfa.form.form1.page1.subForm1.assocDept.rawValue);
    var mgrName = (xfa.form.form1.page1.subForm1.mgrName.rawValue);
    var mgrEmail = (xfa.form.form1.page1.subForm1.mgrEmail.rawValue);
    var salariedHourly = (xfa.form.form1.page1.subForm1.salariedHourly.rawValue);
    directReports var = (xfa.form.form1.page1.subForm1.directReports.rawValue);
    var perfRating = (xfa.form.form1.page1.subForm1.perfRating.rawValue);
    var howLongWorking = (xfa.form.form1.page1.request.howLongWorking.rawValue);


    PRESENT DATE
    If (StartDate == "") then
    xfa.host.messageBox ("Please enter a shipping Date");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.StartDate");

    HIRE DATE
    ElseIf (EndDate == "") then
    xfa.host.messageBox ("Please enter a hire Date");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.EndDate");

    NAME OF PARTNER
    Else if (assocName == "") then
    xfa.host.messageBox ("Please enter your name");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.assocName");

    PARTNER ID
    ElseIf (assocID == "") then
    xfa.host.messageBox ("Please enter your ID");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.assocID");

    EMAIL PARTNER
    Else if (assocEmail == "") then
    xfa.host.messageBox ("Please enter your email address');
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.assocEmail");

    EXTENSION ASSOCIATE
    Else if (assocExt == "") then
    xfa.host.messageBox ("Please enter your extension number");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.assocExt");

    DEPARTMENT ASSOCIATE
    Else if (assocDept == "") then
    xfa.host.messageBox ("Please enter your Department");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.assocDept");

    NAME OF THE MANAGER
    Else if (mgrName == "") then
    xfa.host.messageBox ("Please enter your name of");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.mgrName");

    E-MAIL MANAGER
    Else if (mgrEmail == "") then
    xfa.host.messageBox ("Please enter e-mail address of your manager");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.mgrEmail");

    HOURLY EMPLOYEES
    Else if (salariedHourly == "") then
    xfa.host.messageBox ("Please enter if you are salaried or hourly");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.salariedHourly");

    DIRECT SUBORDINATES
    ElseIf (directReports == "") then
    xfa.host.messageBox ("Please indicate if you have any direct report");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.directReports");

    PERFORMANCE RATING
    Else if (perfRating == "") then
    xfa.host.messageBox ("Please certify your last performance rating");
    xfa.host.setFocus ("xfa.form.form1.page1.subForm1.perfRating");

    HOW LONG WORK
    Else if (howLongWorking == "") then
    xfa.host.messageBox ("Please indicate how long you think that this scheme of work");
    xfa.host.setFocus ("xfa.form.form1.page1.questions.howLongWorking");

    on the other
    Button6.execEvent ("Click");
    Page2.presence = "visible";

    EndIf

    I have been hunting for several hours and can't seem to find or correct the problem. Can anyone help?

    Thank you

    MDawn

    It would be easier if I cpoudl see the form in action... .a you send it to [email protected] and include a description of how to reproduce the problem.

    Paul

Maybe you are looking for

  • How to turn on the fast user switching feature

    Some laptops running XP Pro where the user-defined function is not allowed... click closing of session start and only guests to not log users to switch... In Control Panel under user accounts there is no option to "change the way users log on or off?

  • How to disable messages on monitor HP 2010?

    So I plug the monitor hp 2010 to my PS3 with a HDMI cable to DVI. The monitor only supports the resolution of 1600 x 900. Apparently, the PS3 can only produce in 720 p or 1080 p. When I select 1080 p, the picture seems clearer and sharper on 720 p. I

  • Save and send audio

    Is it possible to record with player and simaltaneously sending data to the server using UDP in BB recorded? How the data can be treated before committing? Us should he custom datasource or circularbytebuffer for these? Bufferring seems to be the onl

  • PC crashed. install lightroom on the new computer.

    Hello.My old pc crashed. I had installed 5 Lightroom on this pc. I installed the program with cd and a serial number.I was not able to uninstall on my old pc. My new windows computer doesn't have a cd-room. So I tride install adobe lighroom throug cl

  • ESXi 5 Syslog

    HelloI have configured syslog to use a syslog host remote kiwi. Is this possible with the 5 for esxi set the remotehost only for errors and warnings?I know it's possible with esx (not i).Which is implemented in the esxi 5 too?Thank youFrank