Use USERID from DB and increment it using position() to create new USERID's?

I'm trying to do the following in XSQL:
<?xml version="1.0"?>
<database connection="test" xmlns:xsql="urn:oracle-xsql">
<xsql:include-request-params/>
<xsql:query id-attribute="" tag-case="lower" rowset-element="maxuserid" row-element="idnum">
SELECT MAX(USER_ID) AS "USERID"
FROM LKUP_USER
</xsql:query>
<xsql:insert-request table="LKUP_USER" transform="/dvd/xsl/admin/createusertransform.xsl"/>
</database>and XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<ROWSET>
<xsl:choose>
<xsl:when test="/request/parameters[not(row)]">
<xsl:for-each select="/request/parameters">
<xsl:call-template name="generate-rows"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="/request/parameters/row">
<xsl:call-template name="generate-rows"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</ROWSET>
</xsl:template>
<xsl:template name="generate-rows">
<ROW>
<FIRSTNAME><xsl:value-of select="firstname"/></FIRSTNAME>
<LASTNAME><xsl:value-of select="lastname"/></LASTNAME>
<PASSWORD><xsl:value-of select="password"/></PASSWORD>
<EMAIL><xsl:value-of select="user-email"/></EMAIL>
<ACCESSLEVEL><xsl:value-of select="accesslvl"/></ACCESSLEVEL>
<USER_ID><xsl:value-of select="/maxuserid/idnum/userid + position()"/></USER_ID>
</ROW>
</xsl:template>
</xsl:stylesheet>which returns the following:
<?xml version="1.0" ?>
- <!-- <?xml-stylesheet type="text/xsl" href="/dvd/xsl/admin/createeditdeleteuserconfirm.xsl"?>
-->
- <database>
- <request>
- <parameters>
<password>test</password>
<lastname>test</lastname>
<firstname>test</firstname>
<accesslvl>5</accesslvl>
<user-email>test</user-email>
</parameters>
- <session>
<access>1</access>
<emailparam>[email protected]</emailparam>
<adminfirstname>Malik</adminfirstname>
<adminlastname>Graves-Pryor</adminlastname>
</session>
- <cookies>
<JServSessionIdroot>57ta3u4mns</JServSessionIdroot>
</cookies>
</request>
- <maxuserid>
- <idnum>
<userid>17</userid>
</idnum>
</maxuserid>
- <xsql-error action="xsql:insert-request">
<message>'java.sql.SQLException: ORA-01722: invalid number ' encountered during processing ROW element 1. All prior XML row changes were rolled back. in the XML document.</message>
</xsql-error>
</database>You can see what I'm trying to do, but I can't figure out exactly how to implement it. I want to avoid the problem of conflicting USER_ID values in the Oracle DB, so I figured, pull out the max USER_ID before submission and use that when 'row-ifying' the data to create new USER_ID which are incremented based on the position() function.
Help? Is this even possible?
p.s.: I realize that I might not be able to do this because the query is not a "request". Is there another way of accomplishing this task?
p.p.s.: I don't have my XSLT book yet..
Malik Graves-Pryor

My book, Building Oracle XML Applications, has lots of XSLT material and examples :-)
You should use:
<xsql:set-stylesheet-param>
to accomplish this. Remember again that the XML that the <xsql:insert-request> sees is not the XML of your data page, but the POSTED XML. The posted XML document will not have the maxid value in it. So, instead just use a top-level stylesheet parameter in your stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Top level stylesheet parameter -->
<xsl:param name="maxid"/>
<xsl:template match="/">
Rest of template here.
Refer to value of maxid in any XPath expression
in the stylesheet with $maxid
</xsl:stylesheet>then in your XSQL page, you use <xsql:set-stylesheet-param> instead of <xsql:query> like this:
<xsql:set-stylesheet-param name="maxid">
select max(user_id) from lkup_user
</xsl:set-stylesheet-param>However -- and this is not an XSQL issue, but a general database thing -- you need to be careful about concurrency issues using the SELECT MAX() trick. If two requests come in simultaneously, they will both SELECT MAX() and get the same current maximum number, then both try to insert a new user. One will (presumably) violate your primary key constraint.
It's better to use database SEQUENCES instead, so the numbers are guaranteed to be unique. To use a sequence you would just change your SQL statement above to be:
SELECT yoursequencename.NEXTVAL FROM DUAL
instead of the SELECT MAX() query.

Similar Messages

  • Use LSMW to create new MMR.

    Hi All,
    When using LSMW to create new MMR, for example material 202851 was created. However, when using MM03 to display this material, it says"The material 202851 does not exist or is not activated"
    What does this mean?
    Thanks.
    Jason

    I am doing migration project for more than 11 years. I load all kind of material masters with its individual depth in one go.
    But I usually use IDOC method instead of the batch input.
    Because most of my projects are migration projects from SAP to SAP. But it works either way, anyway.
    Please tell in detail where your problems are, You say you loaded it, but SAP says you did not.  You have to trust SAP.
    It does not find your data. It is just a program that tells you it does not find your values, so there are no emotions in the game.
    In most cases the error is already in the source file.
    But you have to know has well how the source file has to look to make your migration succesfull.
    Search the forum, There have been many links to well documented LSMW documentation that show how the source file looks and what you need to do in batch input, to make it work.
    By the way, SAP has issued a very good book on LSMW. Even it costs a lot bucks, it is worth. As well the SAP documentation at service.sap.com/lsmw is worth to be read.

  • Could i use 'HR_MAINTAIN_MASTERDATA' to create new employee ?

    Dears
    it seems using PA40 to create new employee.
    i just want to create simple person with infotype 0000, but when i using 'HR_MAINTAIN_MASTERDATA' it will automitically jump into new screen of new infotype such as 0001 without push saving button the same as i use PA40.
    How could i control the screen sequence ?

    Hi,
    You cannot create  Employees using this FM HR_MAINTAIN_MASTERDATA. This FM can be used to maintain infotypes AFTER an employee/applicant has been created in SAP(pa40).
    i think there are no FMs to create Employees. There are FM's to create,update,delete,delimit etc other infotypes but IT0000(actions) Need to be performed either using PA40 or thru other mass data entry precedures like LSMW etc. where Recording of a transaction is performed.
    and coming to the jumping of screens u mentioned, it is initiated by Infogroups, where the sequence of infotypes to be maintained while performing an action are defined.
    you can remove the infotypes you dont want to maintain by identifying the infogroup and deleting it from there.
    also for this FM 'HR_MAINTAIN_MASTERDATA' the important import parameter itself is PERNR? how are u using this FM to create an employee?
    any special reason why u wanna use a Function module to create an employee?
    Message was edited by:
            Hruser

  • How to Use iSetup to create new environment in copy of clean master.

    Hi,
    I want to use iSetup to create a complete new environment. No manual setup has been done yet in the copy of the master (no Business Group, No OU, no Chart of Acc: nothing). Source environment is being setup rightnow by functional consultants
    Can one please provide me with a manual or guideline how to start this challenging job. Maybe a best practise can be used ?
    In the end we want to setup an environment based on a clean master.
    ( practical data: eBS 12.1.2 on linux )
    Thanks in advance
    Guido

    Hi Guido,
    You can get in touch with [email protected] who is the product manager for iSetup. He would able to assist you to go forward in the right direction.

  • CMP Beans from Tables: Why does the Container try to create new tables?

    I'm trying to develop an EJB application using JDeveloper on 9iAS. I have several CMPs and have my tables that I want my CMPs to be based on already defined in my DB schema. I want to use CMP but I don't want the Container to create the tables, rather I want the Container to map my CMP EJBs to the already existing tables.
    The issue is:
    While creating these CMP EJBs in JDeveloper I chose the "New Enterprise Java Bean" EJB creation wizard using the option labeled "Container-managed Entity Beans from Tables". My assumption is that this does what I want, because the wizard prompts for a schema and table you want to map to. Then it creates the attributes & getter/setter methods, PK class, etc. all based on the table defintion automatically. Great. So why when I try to run my application do I get error messages for each EJB such as:
    Auto-creating table: create table STREET_TYPE (PK_STYP_ID NUMBER(8), STREET_TYPE VARCHAR2(20), primary key (PK_STYP_ID, STREET_TYPE))
    Warning: Error creating table: ORA-00955: name is already used by an existing object
    Huh?? I thought the idea is that the CMP EJB is mapped to the existing table in my schema. Why is the Container trying to create new tables?? Is this possible? Or am I missing something fundamental about how Containers create and manage CMPs? Or is this just a JDevelop container issue? TIA

    I presume you are getting the problem on application
    deploy? This happens when upon initialization of the application using the built-in OC4J container/app server that is part of JDeveloper. Here is the full messaging:
    [Starting OC4J using the following ports: HTTP=8989, RMI=23892, JMS=9228.]
    C:\OraHome1\jdk\bin\javaw.exe -ojvm -classpath C:\OraHome1\j2ee\home\oc4j.jar com.evermind.server.OC4JServer -config C:\OraHome1\jdev\system\oc4j-config\server.xml
    [waiting for the server to complete its initialization...]
    Copying default deployment descriptor from archive at Q:\CBTCOF\COF_APPLICATION\COF_Project\classes/META-INF/orion-ejb-jar.xml to deployment directory C:\OraHome1\jdev\system\oc4j-config\application-deployments\current-workspace-app\classes...
    Auto-deploying file:/Q:/CBTCOF/COF_APPLICATION/COF_Project/classes/ (No previous deployment found)...
    Auto-creating table: create table STREET_TYPE (PK_STYP_ID NUMBER(8), STREET_TYPE VARCHAR2(20), primary key (PK_STYP_ID, STREET_TYPE))
    Warning: Error creating table: ORA-00955: name is already used by an existing object
    [...OTHER SIMILAR ERROR MESSAGES]
    done.
    Oracle9iAS (9.0.2.0.0) Containers for J2EE initialized
    If so, in the application.xml file of you
    OC4J instance the is a setting autocreate-tables,
    which by default is true!
    Set it to false as below and that should clear up
    your problem.
    <orion-application autocreate-tables="false"
    default-data-Hmm. I found at least a dozen or so files with that name and set everyone that had this attriute to "false", restarted the OC4J server and still got these errors.

  • HT201240 I forget my password and hint . How can I create new password ?

    I forget my password and hint in MacBook Air 11-inch mid 2012 . How can I create new password .

    Reset Password
    OS X 10.7 Lion /10.8 MountainLion
    Follow the instructions in the first and the third boxes.
    http://pondini.org/OSX/Password.html
    Note
    Keychain
    http://support.apple.com/kb/PH10623
    Best.

  • When in phone and I add dialed number to create new contact, I cant find it in with my contacts.  Why is this?

    How come when i am on the phone or in phone app, I add number to "create new contact".  But when I go back to contacts to look it up, its not there?

    Some mail programs, including Apple Mail, can reduce the size of images that are attached to a message. It's happening at the sender's end, and all you can do is ask the sender for a larger image.

  • Restoring a catalog from backup and incremental backups on external Hard drive

    Hello!
    I recently bought a new computer where I installed again Elements 8 (that's the one I'm currently using). From my old computer, I have an initial complete catalog backup which was saved in a folder (I called this folder "Complete catalog backup") on an external hard drive. I also made then subsequent incremental backups which were saved in different folders called "Incremental backup 1", "incremental backup 2" etc. on the same external hard drive. Apparently in Element, I discovered that incremental backups can't be saved in the same folder as initial complete backup!
    How should I proceed now to restore my catalog on my new computer? I know how to do it when one has only a complete initial catalog backup, but now I have also several incremental backups (contained in folders "incremental backup 1", "incremental backup 2" etc.), I just don't know how to proceed.
    Some help would be very much appreciated.
    Thanks a lot

    First and foremost: Forget re-importing. You would loose all your edits. Importing is strictly only for images that have never been imported before.
    The remedy for "missing" photos is to re-link them.
    In Lr / Grid View right-click the top-most folder in the folders panel. By "top-most" I mean the parent folders of all folders. If you have several parent folder right-click one of them.
    Then select <Find Missing Folder>, navigate to the corresponding folder on your new drive E and select it. Do this for every other parent folder. If the folder names and structure haven't changed Lr will find the sub-folders on its own.
    For more see here: http://www.computer-darkroom.com/lr2_find_folder/find-folder.htm

  • Restore User Archives from Full and Incremental backups

    Ok Groupwise 8. User's keep their archives under the main users folder on a Novell Server. Groupwise is running from Linux server, so the main post office and domain are backed up nightly on the Linux server, the user archives are backed up nightly on that server.
    I have had to restore current messages a user accidentally deleted from their mailbox, Reload handled that as those were current. But now I have one user who didn't know what the folder GWArchive was and blew it away. It was his archives. He needs them back. So I have restored them from the Novell server backup, first from the last full backup and then the two incremental backups that cover up to the point he deleted the folder. The incrementals were restored to separate folders because I didn't want those to overwrite the main files as these are incremental.
    How do you "merge" all these together to rebuild that archive index? Is it just a matter of moving all the .000, .001, .002, etc. files over, then the *.db files, and the index files? Or something different?
    Thanks in advance - I wish there was someplace that describes all these file types, what they are, etc. a really technical level explanation so I understand this a lot better.
    Kind regards,

    * iliadmin,
    when you do incremental backups, it's very useful to have an option to restore a certain point in time and let the backup app collect the data which was in place at that point in time. Else copy back the base, then *overwrite* with the first incremental, then the second etc., moving up to the latest backup you have.
    Which file is which is pretty well explained in the manual. The files are the same as in the live PO, just for only one user when you look at an archive.
    HTH
    Uwe
    Novell Knowledge Partner (NKP)
    Please don't send me support related e-mail unless I ask you to do so.

  • How do I know I'm accessing my complimentary amount of iCloud that came from somewhere and have not just set up a new paid account on my new iPhone?

    Hmm, thought that field was all I got to type in.  First post here, sorry.
    Some time ago, a techie set up something that gave me a complimentary amount of iCloud to go with my iMac.  Maybe that went with the wireless box I got? I guess it works.  I just got a new iPhone and was just encouraged to sign in to (activate?) iCloud, which I did and the settings now identify my email address in iCloud.  I want to know if doing this will access the complimentary account or is it actually signing me up to a new paid account for iCloud.  Which I don't want.
    I've already had two emails over the last couple of months from "Apple", completely without identification or logo telling me I will need to pay for an iCloud account.  No idea what that was about. Thought it was phishing, actually.  Contacted Apple through this website, I think. No reply.
    Anyway, I just want my free iCloud "place" to synch my iMac, iPad and now my iPhone.  Don't need more space.  Don't need more emails from "apple."  Are things safely going to my complimentary iCloud account?
    Thanks.

    If you used the same Apple ID as previously then you are using the same iCloud account.

  • Imported favorite bookmarks from IE and now all links are to BBC news

    I downloaded and installed Firefox, imported favorites/bookmarks from IE running Windows 7, and now all the bookmarks that seemed to have been imported point to BBC news link.
    Any suggestions?

    Open the Firefox SafeMode and select '''Delete all bookmarks except for backups''', then Continue in SafeMode. <br />
    http://support.mozilla.com/en-US/kb/Safe+Mode
    Then close Firefox. Open IE and use '''File > Import/Export - Export to HTML file''' and save that file to the Desktop. Close IE.
    Then open Firefox and open '''Bookmarks > Organize Bookmarks -> Import & Backup - Import HTML... = From HTML file ''and select that file you saved on the Desktop'' '''.
    Hopefully that method will work better.

  • [SOLVED] Use clonezilla, or create new partitions then copy?

    I'm migrating my Arch for the first time. What would you recommend for a complete newb in this area, cloning the disk with some tool like clonezilla, or creating partitions manually and copying everything over?
    I saw a few threads on how to make partitions and copy stuff over, but they all leave me with uncertainties. Would cloning the hard drive be an easier option?
    Last edited by trusktr (2012-04-01 21:50:09)

    trusktr wrote:
    Hey graysky thanks for the answer. Could you also provide some insight into why not using clonezilla?
    For a someone doing this for the first time ever (like me), creating the new Linux partitions seems kind of tricky. The only time I've ever created partitions was from the Arch Install CD which made them automatically. I'd imagine that I would create each partition with the same size, except for the putting all the extra space of the new hard drive into the home partition.
    Best for learning now.  Making a partition is easy to do.  Just be sure you carefully keep track of drive letters when doing it.  Plus, the last time I looked, clonezilla wasn't updated for several years and didn't support ext4.  This may have changed though.
    Advice: draw out on paper your partition scheme, sort of like a map. ie
    / 15 GB /dev/sda1
    /boot 200 MB /dev/sda2
    /var 10 GB /dev/sda3
    /home <<rest of drive>> /dev/sda4
    Then use a util like fdisk or gptdisk to do the partitioning itself.  If using GPT, make sure to have an empty 1 MB partition for the BIOS!
    https://wiki.archlinux.org/index.php/GPT
    Here is a nice walk through using GPT --> https://wiki.archlinux.org/index.php/SS … DED_METHOD

  • The co-op have withdrawn the iPad 3 from sale and it will be replaced by a new iPad. Does anyone know if there is an issue with the iPad 3 that would have led to the upgrade? Thanks Mark

    Is there an issue with the latest iPad (3)? Why has it been replaced by an upgrade?

    No, there's absolutely no issue.  I guess the co-op just thought that now that the new iPad is available, and costs the same as the iPad 3 used to cost, it might as well offer the latest.

  • Use Automator to create new subfolders in a selected folder

    This seems like it should be easy to accomplish, but I have had no luck.
    I want to be able to select a folder, and then run an Automator Service to create a specific set of subfolders within the selected folder.
    I am able to set up automator to create the subfolders, but it does so in the folder containing the selected folder.
    Any suggestions on how to accomplish this simple task?

    Which type of variable should I choose? I tried "text" but there's no way to set it to "input"? There are many Variables in the Library.
    Here's how I have things set up now, I thought the "Service receives selected 'folders' in 'Finder'" (at the very top of the workflow area) would pull in the selected folder.
    Thanks!

  • Read character 3+4 from filename and move to other position

    Hello,
    I need a javascript to read my filename (I have the one for the full filename) and especially the 3rd and 4th position of the filename.
    The characters on position 3 and 4 must be moved to the position just before the extension.
    Example:
    4PEN12345.pdf (old name) should be 4P12345_EN.pdf
    Now I have the following script to extract all pages in an existing pdf file to separate pages with all the same suffix before the extension
    /* Extract Pages to Folder */
        var re = /.*\/|\.pdf$/ig;
        var filename = this.path.replace(re,"");
            for ( var i = 0;  i < this.numPages; i++ )
            this.extractPages
                nStart: i,
                nEnd: i,
                cPath : filename + "_page_" + (i+1) + "_EN.pdf"
    Can anybody help me to set me on the right direction?

    Now I have the file 4PBG12345-1.pdf (7 pages included in the pdf).
    Your script as I filled in:
    /* Extract Pages to Folder */
        var re = /.*\/|\.pdf$/ig;
        var filePath = this.path.replace(this.documentFileName, "");
        var oldFileName = this.documentFileName;
        var suffix = oldFileName.substring(2,4);
        var newFileName = oldFileName.substring(0,2) + oldFileName.substring(4).replace(".pdf", "_"+suffix+".pdf");
        var newFilePath = filePath + newFileName;
            for ( var i = 0;  i < this.numPages; i++ )
            this.extractPages
                nStart: i,
                nEnd: i,
                cPath : newFilePath
    Result:
    1 file ==> 4P12345-1_BG.pdf (7 pages included in the pdf)
    Of course, because the syntax for extracting and adding automatic pages is not filled in. So, that was my question, how must I nest to add the right:
    Filepath+oldfilenamesubstring(0,2)+oldfilenamesubstring(4)+_page_i++_+suffix+.pdf in the extract section
    So, my example must result in 7 pdf's:
    4P12345-1_page_1_BG.pdf (with content of page 1)
    4P12345-1_page_2_BG.pdf (with content of page 2)
    4P12345-1_page_3_BG.pdf (with content of page 3)
    4P12345-1_page_4_BG.pdf (with content of page 4)
    4P12345-1_page_5_BG.pdf (with content of page 5)
    4P12345-1_page_6_BG.pdf (with content of page 6)
    4P12345-1_page_7_BG.pdf (with content of page 7)

Maybe you are looking for