Using a single sequence value over multiple scripts (in a variable?)

Hi all...
I'm writing a number of scripts that insert rows into tables.
To better explain my point, I'll paste a simple breakdown of the scripts here as that will be easier to understand...
Script 1:
INSERT INTO WORKGROUP_DEPARTMENTS(ID, DEPT_NAME, DEPT_TYPE)
VALUES (SEQ_WGDPT.NEXTVAL, 'Staff', 3);
Script 2:
INSERT INTO WORKGROUP_SECTIONS(ID, SECT_NAME, WGDPT_ID)
VALUES (SEQ_WGSEC.NEXTVAL, 'Staff 1',
(SELECT ID FROM WORKGROUP_DEPARTMENTS
WHERE DEPT_NAME = 'Staff'
AND DEPT_TYPE = '3')
Script 3:
INSERT INTO WORKGROUPS(NAME, UNIT_TYPE, WGSEC_ID)
VALUES ('Staff Room', 3,
(SELECT ID FROM WORKGROUP_SECTIONS
WHERE SECT_NAME = 'Staff 1')
As you can see, in scripts 1 and 2 a new value is produced from a sequence (SEQ_WGDPT & SEQ_WGSEC respectively). Then, in scripts 2 & 3 (respectively) these values are inserted into another table.
What I'm trying to figure out is: can I do the same thing here without having to include the horrible SELECT statements in scripts 2 & 3 in order to find the ID, which was produced by the sequence in the previous script?
Unfortunately they do have to be separate scripts, and as such I can't call Sequence.CurrVal from a different script as other users may have used the sequence since it was used initially in the previous script. I could call it from the original calling script, and save it intop a variable, but I have no idea how to - even if it is the right idea!
I tried to insert the sequence value into a variable a la PL/SQL so that I could call this variable from the next script, but failed miserably as I'm rubbish!
Any help would be great. Thanks.

You can use PL/SQL, for example:
SQL> desc t
Name                                      Null?    Type
ID                                                 NUMBER
NAME                                               VARCHAR2(10)
SQL> desc t1
Name                                      Null?    Type
ID                                                 NUMBER
NAME                                               VARCHAR2(10)
ID1                                                NUMBER
SQL> desc t2
Name                                      Null?    Type
ID                                                 NUMBER
NAME                                               VARCHAR2(10)
ID2                                                NUMBER
SQL> create sequence seq_1;
Sequence created.
SQL> declare
  2   prev_id number;
  3  begin
  4   insert into t values(seq_1.nextval,'A')
  5   returning id into prev_id;
  6   insert into t1 values(seq_1.nextval,'B',prev_id)
  7   returning id into prev_id;
  8   insert into t2 values(seq_1.nextval,'C',prev_id);
  9  end;
10  /
PL/SQL procedure successfully completed.
SQL> select * from t;
        ID NAME
         1 A
SQL> select * from t1;
        ID NAME              ID1
         2 B                   1
SQL> select * from t2;
        ID NAME              ID2
         3 C                   2
Rgds

Similar Messages

  • Can I use a single variable over multiple Scripts?

    Hi ,
    I wanted to create a single variable and then intend to use in multiple scripts(using maping that variable).
    Is it possible??
    I had tried it by adding that variable to the Library,but I am not able access it .
    any suggesions??
    Thanks
    Usoni

    Global VB variable is one option

  • Using a single itunes library with multiple iphones?

    My wife got an iPhone 3GS recently and I already have a 4S. I plan to use an existing iTunes install on a single PC to manage them both. I see that Apple support articles say it's worth keeping iTunes libaries separate (with separate Windows user accounts) when there are multiple iPhones using iTunes on one PC.
    I like to manually manage music, videos and podcasts in my iTunes library rather than use synching. I like the idea of having a shared pool of music, videos and apps for us both to use. I know apps that are purchased on my iPhone or my wife's are linked to a specific apple ID so that means if she transfers any apps that were bought on my phone originally, her phone will ask her for my apple ID password when they get updates. But sharing passwords with eachother isn't a problem.
    I can create a second user account for my wife easily, but I kind of have the feeling I'd prefer to share a single library as I say.
    Are there any other reasons I need to keep 2 user accounts and 2 iTunes libraries going when I manually manage the transfer of content?
    Cheers.

    MikeBelfast wrote:
    I can create a second user account for my wife easily, but I kind of have the feeling I'd prefer to share a single library as I say.
    Adn this can easily be done.
    Move your /Music/iTunes/ folder to a Shared directory (such as /Users/Public/ folder) and everyone can use this single library.
    Each user must quit iTunes before the other can open it.
    Just hold Shift, launch iTunes, select Choose library... and select the iTunes folder in the shared directory.
    The big advantage with separate Windows user accounts, data such as photos, calendars, emails, and everything else will be separate.

  • Single Class Split Over multiple non-consecutive Days??

    How do I setup in OLM  a class split over multiple days for Example:
    I have a Diversity Awareness Course and Offering. The Class is 2 days long, but not on consecutive days, they are a week apart.
    Do I create a Day1 Class and Day2 class under the same course and make it a prerequisite to attend day 1?
    From a reporting point of view this now shows as 2 classes when it is only 1; inflating the class figures.
    Or Can I split it into 2 sessions under the same class?
    What is the best way to do this?

    Hi!
    You can create a Class with two Sessions underneath it (one for each day).  Make the Start Date for the Class the day the Class begins and set the End Date to correspond to the last day.  Your Duration should be set to 2 Days.  Learners will be able to view details for each session, and you can assign different instructors and rooms for each day if you use Resource Bookings in OLM.
    Anne
    Anne Saulnier | Synergy Codeworks LLC
    [email protected]
    603-864-9942

  • Any way to span a single iTunes Library over multiple hard drives?

    I have a hard drive that is almost full and the only thing on it is my iTunes library. It is not feasible for me to get a larger hard drive as this one is already a 1TB hard drive. Now, I have seen I can create multiple libraries, with each library on a different hard drive if I wish. However, not only is most of the media in the library podcasts, using multiple libraries for a single iPod Touch would be a pain.
    So, is there a way for the iTunes Library to span over more than one hard drive, but yet be a single library? It would make it easier to sync my iPod Touch.
    Thanks in advance!

    I'm assuming that I would have to "import" my old drive into the library
    You don't import anything since your library is the same as it was. All those items are still in iTunes in the same location. The ONLY thing different is iTunes prefs -> Advanced.
    Or am I wrong and it will have my previous media folder still in the library, and anything new would be put in the new media folder?
    Yes & yes. Everything in iTunes will still be in iTunes, stay in the same location it is now and iTunes will use it from there.
    Anything new added to iTunes will go to the location you set in iTunes prefs -> Advanced.

  • How do I go from using a single Apple ID with multiple libraries to using home sharing?

    Until now my wife and I have opted to share our iTunes/Apple ID and use multiple libraries to manage our iPhones. This has become increasingly difficult...with issues such as having apps I've downloaded that she doesn't want automatically downloading to her library and even her phone. Now, add in the fact that I want to continue to manage my iTunes library from our PC and allow her to manage hers from her new MacBook Pro and we have good reason to move to home sharing with separate Apple IDs for each of us.
    My question is the logistics of doing so. Not only do we need to replicate her existing library on a new Apple ID, but then we need to migrate all the necessary files over to her MacBook Pro. Quite honestly, I don't even know where to begin. Is it possible to associate her existing library with her new Apple ID without having to create her library from scratch? Then is there anyway to migrate only the items in her library over to her MacBook Pro as opposed having to move all of our music & apps? Where do I begin?
    Thanks!

    Okay...I misunderstood and thought we needed separate ID's...but I see we actually need to use the same ID which simplifies things in my mind a bit. But still some followups...
    1) What do you mean by restore the library on her computer? Simply open her library file in iTunes?
    2) On our current machine...media is actually split between a couple folders but all under the My Music folder. But there are multiple subfolders (iTunes, Her iPhone, and Amazon MP3). I presume as long as I copy over the entire My Music folder there shouldn't be any access issues when the library is opened on her machine?
    3) Is there any easy way to get rid of all the extra files that she doesn't have in her library? For instance, all my music and apps that she doesn't actually want, is there any easy way of separating those out from the files that are actually linked to in her library? Vice versa for me...once we've go her library set up on her machine, any easy way to purge all the extra files from my PC that aren't actually in my library?
    Thanks!

  • Sharing (synchronizing) a single iTunes library over multiple computers

    Okay, i've been looking all over for a simple answer to this problem for a while and haven't found a solution that doesn't involve paying for third-party software or a lot of seemingly unnecessary hassle. Here's my situation:
    I have an older 12" PowerBook G4 and a brand new MacBook Pro. I also have a Time Capsule and a 30 gig iPod, but i'm not sure whether they will be helpful or not for my situation. When i got my MacBook Pro, i let Leopard transfer all my info, so now both computers have the same login information, music library, iPhoto library, etc... But not for long, naturally. I want to use my MBP at home primarily and will spend most of my time on it, but i will also frequently be out and will be taking my PowerBook along as it is both more portable and less of a concern if something happens to it. What i want to do is to set things up so that my iTunes library (including playlists, ratings, and other metadata) is kept synchronized across both computers (perhaps via the Time Capsule?) and that any changes made on either mac will at least eventually be mirrored on the other without causing duplicates or loss of any files. I don't need to keep separate versions or sizes of iTunes libraries either; the hard drives are each large enough to hold the entire thing.
    On a side note, the iPod only needs to be able to sync from the MBP, i think, though it would be nice to have the option to sync from either. Sadly, it’s not large enough to hold the whole library, so i can’t use that to go back and forth or anything.
    Also, i wouldn’t mind if the library were only stored on the TC and the PB, since the MBP should be able to access the TC 99% of the time, but in that case the PB would have to compare its own library and metadata to that of the TC, while i’m not sure how the MBP would store its iTunes database on the TC and not its own drive. I imagine that, with the current implementation of iTunes at least, it would have to be all on the MBP and the PB, with the TC version merely a backup. In most cases, i should be able to reach both my TC and my MBP from the road over the internet, but i still want to have the library on the PB hard drive for when i don’t have a connection.
    I wouldn’t mind a “master, slave” type setup either, with the MBP being the master, since with the only working optical drive and a faster connection, it will be doing most of my importing- but it’s important that the playlists and everything are the same and it sure would be nice if i didn’t have to remember not to make any changes from the PB. I don't plan on buying any music from the iTunes store and my entire library is DRM free, so that won't be a problem. Both systems are running the latest versions of all software and operating system (though i hear this may change with Snow Leopard...?)
    And while we’re at it, doing the same or similar to my iPhoto, iCal, Addressbook, Documents, etc. would be nice. Perhaps something can be done with the entire Home folder that would accomplish all of this? I’m not sure if the fact that one is Intel and the other is PowerPC would put a hitch in that method though. There are some settings, such as the totally different trackpads, etc. that will not be the same, plus i’ll be using a lot of programs solely on the MBP, which is why cloning the drive is not an option.
    I’d like to find a way to set this up using just Automator and maybe some Applescripts if possible, but if i do have to bend and go third-party, it would need to be solid.
    I know my situation is unique (I’ve found a lot of people trying to synchronize libraries, say, with a spouse, etc. WITHOUT syncing the metadata- or people wanting different libraries on different computers to feed into the same pool, but those are very different cases, obviously) but i’m sure there are plenty of people out there with several different macs of their own who could benefit from this solution. Any help you can give towards this would be appreciated. Thanks!

    I have a similar problem. Wish I had an answer but am struggling with a similar problem. My situation is this: I have a Imac and a Macbook Pro. I have the same 4 accounts on both and I sync them through '.mac'. It works fairly well. My goal is to get one Itunes library accessible from the 2 computers and the 4 accounts per computer. I am also using Time Capsule/Machine as well. I currently keep the Itunes library on an external drive (not TCapsule). So, my problem is this:
    1. How to update from multiple accounts accross the two machines?
    2. How to access Itunes store from all of the accounts on machine 2?
    I am now trying to set up individual Itunes libraries for each account on machine 1 and share to machine 2.
    In any case, this is not pretty and needs to be reachitected to support a multiple user environmet.

  • How to use/sync single data (file) across multiple instances of same application

    Currently we have an application (a diagram editor), that have the ability to save and load (serialize) its state in a xml file.
    Now we want this application to behave like Microsoft OneNote application. Where multiple users have the ability to access the same file.
    Later we may also need to enhance with other things like, (1)what is changed and who changed it, (2)option to resolve conflicts if any.
    I came to know about sync framework to resolve this. so far, i have not tried it.
    All i want is,
    Virtually single file should be edited by multiple instances of same application.
    We need a dll (sync framework) that does following
    It takes complete responsibility of file handling.
    Using this dll, each instance of the application will notify their own changes.
    Each instance of the application should have the ability to detect the changes that is recently made (when, who, what are the changes).
    My question:
    Will sync framework be suitable for this requirement?
    If so, is there a demo application that represents this?
    - Jegan

    Seems like I have found the solution.
    In the taskflow there is a property named data-control-scope and I set it to isolated instead of the default (shared) and this seemed to do the trick.
    I can now have two instances of the same taskflow running with different ApplicationModules
    Cheers,
    Mark

  • Using a Single HTTP Server for Multiple APEX Instances

    Our company's DBA Manager has asked if it would be possible to externalize the HTTP server portion of APEX from the DB Servers. In other words, he would strongly prefer that the DB Servers *only* run Oracle Database software.
    We know that we can install the HTTP server on another box but, in thinking about how to do this, we were wondering if it is really necessary to create a separate HTTP server installation for each APEX instance. What we'd really like to do is have one HTTP server for all our our Dev boxes and several (but, not one to one) for each of our upper environments; staging, qa, prod, etc.
    Right now, each instance have a single dads.conf file on each DB box. So, if we we're to attempt to consolidate them, we'd need some way to embed multiple dads files and to associate each instance with the correct one.
    Has anyone ever done this or (preferably) have some examples?
    Thanks,
    -Joe

    Joe,
    I don´t know a specific reference for it, I remembered it because when I was looking the documentation on the site, I saw the reference "Support for multiple database connections" in the URL: APEX Listener New Features 2.0</title><meta name="Title" content="APEX Listener New Features 2.0…
    I´ve tried to use APEX listener some time ago, but in a earlier version together with glassfish. So, since for me was only one database, I created the necessary amount of DAD´s on my database, each one for a specific port.
    Check the link and you´ll see the same information I saw.
    Thanks.
    José Valdézio
    "Neo, everything that Oracle told me, became true, except extinguish bugs in a first release."

  • Using a Single Registered UDO for multiple Transactions

    Dear Experts,
    We are developing a Expense Booking System by using SAP B1 SDK. in .NET
    The scenario is like this.
    Need to book the expenses independently by using an Expense Booking Screen, and also from a Transaction screen (Sales) where the user enters the expenses details incurred during the sales activity.
    Data from both the screens should be saved in a single User defined table.
    ie, The Expense Booking Screen uses the table for direct saving and the Sales screen uses the same table as the child table of the transaction where the parent (header) table holds the details of Sales activity.
    The table object is registered for the Direct Expense Booking screen.
    Can I use the same object for the Sales Expense booking screen?
    Is it possible?
    If so, how can I implement it?
    Please advice..
    Thanks in advance
    Regards,
    Toms

    Sure
    Generic services are using to maintain UDO table using SDK. You no need to assign values to datasource items. You can simple collect the values from the form items / user data sources and update the UDO table accordingly.
    First you go to this link
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d04b34b5-68cf-2b10-bc98-806feb4299ba
    and download the DI GENERAL SERVICE SAMPLES
    Applications with full source code is available for
    1. Master Data UDO maintenance
    2. Master Data UDO + Child Tables Maintenance
    3. Document Data UDO maintenance
    4. Document Data UDO + Child Tables Maintenance
    Thank you
    Anoop

  • Same sequence value for multiple targets

    Hello
    In my mapping, I have 4 target tables. The primary key of the first table is filled by a sequence. Now I should use the same value to fill in the 3 other tables.
    I was trying to use the sequence in the joiner and in the splitter but when I validate the mapping, I get the following error:
    "VLD-1800: Illegal use of sequence operator(s) in a complex mapping."
    How do I resolve this problem?
    Thank you for your answer.

    Hi
    A possible solution for your problem would be to populate your main table (Main_TL) with everything including the Sequence Number and have your other target a temporary table (Temp_TL) which has a common column (Natural Key) populated.
    Do another mapping joining the Main_TL and the temporary table (Temp_TL) using the Natural key joining condition and populate the remaining 3 targets to the output of the join.
    Hope this helps.
    Cheers,
    Sharad

  • Can I export using a single dump directory to multiple locations in oracle

    I'm trying to do a full database export using expdp utility in oracle 10g. I have a single dump directory that is mapped to a particular file location say /export/dump. I don't want the entire dump file to be stored in the above path. Instead I want the dump to be distributed among multiple files. I know that this can be done using FILESIZE parameter which will distribute the contents to multiple files according to the size we have specified.
    My problems comes here, I want to export my data to multiple locations, the path is different than what I mentioned above, say /first/dump. Now my question is should I create multiple dump directories for each location before exporting or can I omit directory attribute in expdp and specify the complete path in the FILE parameter itself.

    No. EXPDP needs the server component LOGICAL DIRECTORY. If you don't specify the directory, it will go to the default EXPDP path which will be mostly /rdbms/log. It's defined by the parameters DATA_PUMP_DIR.
    You will have to specify directory attribute if you want to point your dumpfile to go to any specific location and you cannot give the directory path in the file name in EXPDP (unlike conventional exp)

  • Sequence number over multiple adobe form calls

    Dear all
    I posted this question in another subforum - http://forums.sdn.sap.com/thread.jspa?threadID=1997461 - three days ago,
    but nobody could answer, so I try to post it here.
    We would like to have a sequence number for each page.
    The Adobe Form gets called more than once, so the second call doesn't know, how many pages were printed already, thus it cannot continue the sequence number.
    Do you have any ideas?
    Of course, I would prefer not to publish an SAP-service only for this purpose...
    (The transaction is HRFORMS, we would like to print a sequence number bar code, so that the packing machine to the envelope senses, if two pages are stuck together.)

    Hi,
    I have a problem in printing current page number of an adobe form.
    My requirement is that , my form got 2 pages. On first page i am not printing page numbers and excluded from numbering.
    Numbering starts from second page. The second page needs to be repeated twice.
    In this case my page printing should look like :
    First page - no page number
    second page - 1 of 1
    Third page - 1of 1 (as it is a copy)
    IF second page extends to multiple pages (eg.. 2)
    First page - No Page no
    First instance of second page - 1of 2 , 2 of 2
    Second instance of second page - 1 of 2 , 2 of 2 . Presently it is printing like : 3 of 2 , 4 of 2. I need to initialize current page count. I could able to set the total page count 2 via variable from print program. But while printing the second instance, I am not able to initialize the current page count.
    I have seen the following thread which exactly talks about my problem but with out any solution.
    http://forums.sdn.sap.com/thread.jspa?messageID=10601698&#10601698
    I have tried initializing the current page count in the initializing event and tried assigning the initial value when the second copy starts but for entire no of pages the same initialized value is coming.
    Can anyone help me in this regard.
    Thank You,
    Regards,
    Naresh.

  • Running a single action, separately, over multiple folders

    Hello all,
    First time for me using this forum, therefore i apologise if this is listed incorrectly. I am trying to speed up my work flow by automating repetitive tasks. Now that I am getting more work to do, I’m trying to tie up some loose ends in my actions that I haven’t previously been able to figure out.
    I shoot a lot of school photography and i use Photoshop to automate the process of adding each student’s image to a proof card which is printed and dispatched to the school. Now this process is really easy when it’s just a single shot per proof card. But for nurseries there are four different images per proof card. The action i currently use (proof card template would be open in Photoshop) asks me to open the four images, which then copies each of the images and pastes them into the designated area of the proof card, then asks me to save it, then removes the four images so that the proof card template is ready to accept another four images when the action is run again.
    The issue i have is that I have to manually select the four images every time i run the action. It’s become a tedious, time consuming process as some of these schools have up to 200 proof cards to be made.
    I’m looking for tips as to someway i can create an action that selects the first four images in a designated folder automatically, plays the action above, saves it automatically as basic file name (even "Proof1" would do!) Then automatically selects the next four images in the folder, runs the action, and automatically saves as 'proof2' and carries on going until its completed every image in the folder.
    I’m not sure if this would be possible to divide each student’s four images into subfolders and use the batch tool run the action?
    Any help would be appreciated.

    I have a similar problem. Wish I had an answer but am struggling with a similar problem. My situation is this: I have a Imac and a Macbook Pro. I have the same 4 accounts on both and I sync them through '.mac'. It works fairly well. My goal is to get one Itunes library accessible from the 2 computers and the 4 accounts per computer. I am also using Time Capsule/Machine as well. I currently keep the Itunes library on an external drive (not TCapsule). So, my problem is this:
    1. How to update from multiple accounts accross the two machines?
    2. How to access Itunes store from all of the accounts on machine 2?
    I am now trying to set up individual Itunes libraries for each account on machine 1 and share to machine 2.
    In any case, this is not pretty and needs to be reachitected to support a multiple user environmet.

  • Using a single iTunes library with multiple logins.

    I've setup my iMac to have multiple logins for everyone in my family. I'd like everyone to use the same iTunes library, though, so that all purchases and playlists can be seen and used by everyone. I have it so that everyone has the same files, but not the same library. That is, the playlists don't come through on the other logins, and purchases made from one login don't translate to another.
    I'm not trying to rip anyone off, I just want my whole family to have the same library.
    Is this possible?

    padrepablo wrote:
    Thanks much, but I've done that. That method shares FILES but not the LIBRARY
    Then you missed a step or two.
    The steps above share the entire iTunes library (media, artwork, playlists, library file, Genius files, everything).
    In the Music/iTunes folder on everyone's login is a file called iTunes Library.itl.
    Yes, and holding Option and selecting Choose library allows you to select which iTunes library you want to use.
    THAT is the file I want to share, but I can't seem to move it.
    The steps above will do exactly what you want.
    All users will use the exact same iTunes library.
    You need to hold Option and select Choose library (notice is says, "Library").
    Once you copy your /Music/iTunes/ folder to /Users/Shared/ folder, everyone can delete /Username/iTunes/ folder.

Maybe you are looking for

  • Apache FOP Capabilities

    Hi all, When using Apache FOP, is it possible to achieve any of the following : 1. Enable printing at the page level rather than at reports region ? 2. If the report contains some images is it possible that these appear in the PDF output as well? 3.

  • Question about FTP class

    Hi, I'm new in java and i use an ftp class tha someone else has developped. I just want to know if it's possible to chek if a known file exists on the ftp server (before download or upload a new one with the same name) Tanks a lot in advance

  • Pass additional parameters to AII

    Hi, Is it possible to pass additional parameters for Serial Number Request through Name Value pair in a xml? If so then please cite an example. The scenario requirement is 3rd party non SAP systems will be requesting Serial Numbers from AII via SAP X

  • Where is the proper location to store brushes or brush presets?

    Illustrator has a user section. Photoshop CS5 will display your custom brushes in the preset manager. I use a Mac OSX 10.8. When I download brushes and install them in the User/Application Support/PS/Presets/Brushes they will appear in the preset man

  • Referencing single cells in formulas

    Hello there. Let us assume the following expression: =$D$4 What I am doing: 1. Select a cell and tap twice to show the keyboard. 2. Tap = 3. Tap cell D4. The input panel shows D4 with an arrow. 4. Tap the arrow and select Start: preserve row and pres