Sequence using merge or other alternative
Hello
I have the following table, wherein a SUBS_ID is unique but INDEX_ID is not and REQUEST_ID is initially null for all records.
The table can be large (~ 1 M lines) and even though there might be several SUBS_ID with INDEX_ID even - most of the records have 1 to 1 relationship.
CREATE GLOBAL TEMPORARY TABLE SUBS_HIERARCHY_TEMP ( SUBS_ID NUMBER(10) NOT NULL, INDEX_ID NUMBER(10) NOT NULL, REQUEST_ID NUMBER(10) ) ON COMMIT DELETE ROWS;
I have the code which assigns a unique number (REQUEST_ID) to each separate INDEX_ID using a sequence (this code can run in parallel and I REQUEST_ID must be unique in the world):
... cursor Request_id_cur is select distinct INDEX_ID from SUBS_HIERARCHY_TEMP; ... begin ... -- fill SUBS_HIERARCHY_TEMP with records, doesn't matter how, REQUEST_ID remains NULL -- populate REQUEST_ID with a sequence for SUB in Request_id_cur LOOP v_UniqeIndex := SEQ_REQUEST_ID.nextval; Update SUBS_HIERARCHY_TEMP set REQUEST_ID = v_UniqeIndex where INDEX_ID = SUB.INDEX_ID; END LOOP; ... end;
It works - but obviously not very efficient. If all the records are 1-1 going to run updates of 1 M, but I can't use a simple update in case somewhere SUBS_ID INDEX_ID even therefore need to have the same REQUEST_ID.
I tried to do it in one go using a merge statement, but apparently the sequences are not allowed in the USING clause of the merger:
merge into SUBS_HIERARCHY_TEMP tab using (select INDEX_ID, SEQ_REQUEST_ID.nextval as REQUEST_ID from (select distinct INDEX_ID from SUBS_HIERARCHY_TEMP) )tmp on (tab.INDEX_ID=tmp.INDEX_ID) when matched then update set REQUEST_ID=tmp.REQUEST_ID;
ORA-02287: sequence number not allowed here
Any ideas how to make in a single statement and avoid the loop?
I'm on 11.2.0.3 RHEL6 64bits.
Thanks in advance.
drop table SUBS_HIERARCHY_TEMP purge; CREATE GLOBAL TEMPORARY TABLE SUBS_HIERARCHY_TEMP ( SUBS_ID NUMBER(10) NOT NULL, INDEX_ID NUMBER(10) NOT NULL, REQUEST_ID NUMBER(10) ) ON COMMIT DELETE ROWS; drop sequence seq; create sequence seq; drop type tt_subs_rec / create or replace type t_subs_rec as object( SUBS_ID NUMBER(10), INDEX_ID NUMBER(10), REQUEST_ID NUMBER(10) ) / create type tt_subs_rec as table of t_subs_rec / create or replace function sub_hierarchy_update return tt_subs_rec pipelined as l_subs_rec t_subs_rec := t_subs_rec(null,null,null); prev_INDEX_ID SUBS_HIERARCHY_TEMP.INDEX_ID%type := -9999999; l_request_id SUBS_HIERARCHY_TEMP.REQUEST_ID%type; begin for rec in ( select subs_id, index_id, request_id from SUBS_HIERARCHY_TEMP order by index_id ) loop if prev_INDEX_ID < rec.index_id then prev_INDEX_ID := rec.index_id; l_request_id := seq.nextval; end if; l_subs_rec.subs_id := rec.subs_id; l_subs_rec.INDEX_ID := rec.INDEX_ID; l_subs_rec.request_id := l_request_id; pipe row(l_subs_rec); end loop; return; end sub_hierarchy_update; / insert into SUBS_HIERARCHY_TEMP select level, mod(level-1,3)+1, null from dual connect by level <= 9; select * from subs_hierarchy_temp;
SUBS_ID | INDEX_ID | REQUEST_ID |
---|---|---|
1 | 1 | |
2 | 2 | |
3 | 3 | |
4 | 1 | |
5 | 2 | |
6 | 3 | |
7 | 1 | |
8 | 2 | |
9 | 3 |
select * from table(sub_hierarchy_update);
SUBS_ID | INDEX_ID | REQUEST_ID |
---|---|---|
4 | 1 | 1 |
1 | 1 | 1 |
7 | 1 | 1 |
2 | 2 | 2 |
5 | 2 | 2 |
8 | 2 | 2 |
3 | 3 | 3 |
6 | 3 | 3 |
9 | 3 | 3 |
Tags: Database
Similar Questions
-
How to lock the filter radiation bevel/gradient? or other alternatives?
Hello
I'm using the filter bevel to add some kind of radiation gradient 1 to my symbol, but when I turn the symbol of changes in bevel if I flip it. How keep/lock the filter bevel at the same place no matter how I rotate? If this isn't the case, are the other alternatives?
I also tried radiation gradient tool, but it will not change now when I turn ityou will need to use actionscript to do. because the bevel "angle" property, you will need to reassign as the object rotates.
-
My pro iPad connects to the WIFI, but loses connectivity to drops in use. My other IOS devices (iPhone, macbook, etc.) do not have this problem. Ideas to solve?
Hello BrooklynWM!
I definitely want my iPad to stay connected to the Wi - Fi connection while I use it. Thanks for posting that other iOS and OS X devices have no problem with the connectivity dropping. We can try a few things.
Would first go through the steps listed in this article: If your iPhone, iPad or iPod touch connects to a Wi-Fi - Apple Support Network
Then if it does not help, you can check network settings with this: recommended for the WiFi routers and access - points Apple supported
After trying those, if you still see the drop connectivity, make sure the iPad Pro is updated with iOS 9.3.2 and check to see if the connection when you are in a certain place, time, or one event happening elsewhere in the House.
Best regards.
-
I want to add a new application to the list right click on file-> open with
and also reorder the list so my search app is first / top of the list.
I know that I can use open with-> other and select any application, but it takes too long I should use my intended application in this way several times a day.
Basically, I'm looking for a configurable way configure open with, something more to send to Windows.
Thank you very much for all the advice offered.
The operating system, not you, not control that open with the menu command.
-
Perform a sequence using the new method of execution
Hi ppl,
I use the Engine.NewExecution method in LabVIEW to perform a sequence using sequential process model. I have been successful in this attempt.
Now when I tried to pass arguments to the sequence with this method I could not do
From the help file, I found to pass property to the sequenceArgsParam in the Engine.NewExecution. I used the Engine.NewPropertyObject to create a new property object. My problem started here. I was not able to define the parameters for the property object I created. When I created an object of type container property, newExecuion method returned an error indicating that the type is the string even if the setting for my sequence was a container. When I created a method of setValString string property object returned error saying unable to find settings where the look of string upward was parameters.x
Please help me some body. I'm stuck with this upward. can someone give me an example of program that passes parameters to the sequence when running via the NewExecution method.
Hello
It is not the Engine.NewPropertyObject method to pass parameters
I used to sequence method before running the sequence
try to replace the step Engine.NewExecution of this VI
the values are in a cluster table: parameter is the name of the parameter in your sequence, the value is the value to pass
A2
Note 1: there is only the string in this VI, it is possible to change with integer...
Note 2: If you have a container, the parameter name is "container". "" The name of the parameter.
-
DirectSound resources such as the level of priority were already in use by an other appellant - have no sound - no audio device
Hi CindySantonas,
· You have made any changes recently?
This problem can occur if your sound card is not configured in the Panel as default device for sound playback.
Method 1: Follow the below mentioned article and see if it helps.
Method 2: Run automated troubleshooting and check if it helps.
-
Can be used dash in other countries except USA or the Canada?
Can be used dash in other countries except USA or the Canada?
What it the question...Laughing out loud
http://www.KB.Sony.com/selfservice/documentLink.do?externalId=C1017668
"The failure to authorize: missing Mode XAPI Service error message appears on the display of the dash personal Internet Viewer if the device detects that the network connection is from outside of the United States or the Canada."
At that time, the Dashboard Viewer is not taken in charge outside the Canada and the United States. »
-
How can I configure Messenger to record my conversations, record them and send them to a location I can read and save when you use Messenger on other computers than mine?
original title: Live MessengerHi Nicoliani,
To start saving your Conversations in Windows Live Messenger
1. connect to your window Live Messenger and click on 'Tools' or click on your display name.
2. scroll down to "Options", a window should appear. When he does very well and click on "Messages".
3. locate "historical Message". After that, check the box that says, "automatically keep a history of my conversations.
4. below that you will see "save my conversations in this folder."
5. to side of her you will see change, make sure that it is a file that you can access and watch later.
6. If you are on a network, you can save it in a directory which you have access, or you can save it to a location and later mailed to yourself and access it later.
Where chats are saved is given below.
1. to access the Conversations go to the start bar and click My Documents. Then click on "my received files."
2. There should be a folder with your name on it. Click the folder, then you will be in another folder called history. Continue
3. by clicking on the folder, now you should see all your saved conversations.
Hope this information is useful.
Amrita M
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think. -
When I click on the hp webcam icon... its opening not... but wen I use it in other social networking sites, it will open... .the he only opens online not offline... Wen I troubleshooted the problem he says this hp webcam is not useful... If shud wat that I do to solve my problem
If the webcam is built in, see the help pages of HP support, for your template, or the HP forums.
How its configuration / controlled is a HP issue, not a win, one
-
Hi, I have four images purchased with a license standard Adobe, used for book covers. If I want to use images for other things like mugs, T-shirts and so on, I need a license and how to buy that? I see an option on my page for the "license again", which is the one to use?
Hello
Please see the frequently asked questions, Adobe Stock
Hope that helps!
Kind regards
Sheena
-
I use Acrobat DC and I'm unable to open a PDF file on a Web site. Whenever I click the link it says that my drive is not updated. I've updated the player several times now and it always used open. Other documents open on this Web site. http://www.cic.gc.ca/english/pdf/kits/forms/IMM1344E.pdf
It is an XFA file that is not detected by the PDF viewers in the web browser.
Please right click on this link http://www.cic.gc.ca/english/pdf/kits/forms/IMM1344E.pdf & select ' Save As... ', now, to save the PDF file to your desktop & open with Adobe Reader.
I'm sure that it will work as it worked on my end.
Kind regards
Nicos
-
Anyone know if there is no CC or BC apps or other alternatives that allow a way to create an online survey consisting of 3 questions for the participants to a trade appear to fill out and submit for the purposes of data collection? Offline data collection is a must. Ability to export data to Excel would be an added bonus. Thanks for the tips.
Hi Nathan,
This link might help: Create PDF fillable, creative forms of PDF form. Adobe Acrobat DC
Kind regards
Sheena
-
When you use cc peuvent, others see what I'm getting?
When you use cc peuvent, others see what I'm getting?
Yes, if they are somehow nearby (standing on a video phone, etc.) and show you their as you work on it they can see - if they cannot see the machine screen while they cannot see what you are working on. All Cloud applications are installed on your machine is no different than if you used a non-Cloud application.
-
I need to clarify how I can use adobe as a host for my site for free. I see where BusinessCatalyst is supposed to be temporary as it is recommended to use as the best alternative to launch my site of muse. But then I have to use the long extension of "businesscatalyst" in addition to the domain name, I would have preferred. Exactly how can I live? do I have to use a third party to accommodation?
Hello
Once you are done with your SeasonFive, click on publier publishing in Muse, select New Site from the drop down, it will ask for a name for your site, which will be used for the url of the site, you will get a url like mysite.businesscatalyst.com, then the browser and connect to the admin panel, mysite.businesscatalyst.com/admin and dashboard Click the launch site. This will push your live site, and then you can add your custom domain.
Also, make sure that you have performed all these actions mentioned here
Let me know if you have any question.
-
How to merge any other InDesign layouts?
I have a document that has, thanks to the importation of various pages from other documents, finished with pages of the same size through FIVE other layouts.
How can I merge these other layouts in one?
In your paragraph Panel, right click on the black triangle on top of one of the sections that you want to merge with the hand. Choose numbering and Section Optionsand UN-heck Section start.
Maybe you are looking for
-
iMac by making a noise when I turn it on. What's wrong?
What can I do to stop the noise when I turn on my iMac?
-
iPhone 6 keeps freezing after patch 9.3.1
iPhone 6 more, 128 GB iOS 9.3.1 (13E238) Firmware 4.71.00 My iPhone screen keeps freezing from time to time since the last update of the 9.3.1. The gels were occasionally at first, but are more common. It freezes randomly on: Home screen on an applic
-
How can I associate pictures in 1 bubble?
I'm trying to turn about 50 photos in 1 bubble at the bottom so I can easily move the bubble instead of having to move a group of 50 photos. How to combine the 50 individual bubbles which are at the bottom, so they just 1 bubble?
-
Briefcase can be uninstalled? I do not use it.
-
Chromebox CXI-i38GKM is HDMI 2.0?
Chromebox CXI-i38GKM is HDMI 2.0? Thank you!