Need to query the database to get the last sequence number

Hi all
I am trying to get the last sequence number of the last row inserted into my Oracle database. Please could someone give me the SQL which would allow me to do this - using Oracle SQL Explorer I have confirmed that there is a sequence on the table which is called: XYZ_SEQ and the code for this is:
CREATE SEQUENCE "MY_USER_NAME"."XYZ_SEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 NOORDER NOCYCLE ;
My Java application is inserting a row into my table and to insert a new row I need to have the last sequence inserted +1 so the new row can be added.
Any help would be much appreciated.

Hi,
Welcome to the forum!
If you are using a sequence just do (example):
INSERT INTO TABLE_NAME
   (COL1,
    COL2)
VALUES
   (SEQUENCE_NAME.NEXTVAL,
    OTHER_VALUE);to obtain (and use) the next number in the sequence when you are inserting.
If you have a sequence to use for a specific table, you should use it when your insert new data (no matter your are doing that: java application, procedure, etc). Doing this you avoid some problems when you have the sequence 'out of date' about the associated data.
Regards,
Edited by: Walter Fernández on Sep 19, 2009 10:08 AM
Edited by: Walter Fernández on Sep 19, 2009 10:10 AM

Similar Messages

  • I need the code to delete record in the database not in the form???

    I need the code to delete record in the database not in the form...
    because when i execute a form always insert the datas in the data base but i want insert value on a text file and delete in the data base the record whith this value of text file.
    i'm spanish an my english is bad sorry.
    thank, javier

    Well, I fail to understand why you want to complicate easy things, but anyway you can do that by using TEXT_IO within Forms to create text file (see Forms builder help), and UTL_FILE package to read it within Pl/Sql : you could create a stored procedure, and call it from Forms passing the file name as parameter. See UTL_FILE documentation

  • I downloader all the Adobe Presenter, looks like everything downloaded but when I open the program I get the following message: The file archive part of Presenter is missing. You need all parts in the same folder

    I downloadedall the Adobe Presenter, looks like everything downloaded but when I open the program I get the following message: The file archive part of Presenter is missing. You need all parts in the same folder

    HI There,
    It seems that Presenter is not fully downloaded. Please check you have downloaded .exe and .7z files successfully. In case you are still facing the issue then please click on the following link to chat with the support :  Chat
    with an Expert
    Regards,
    Mayank

  • Query on 0TCT_MC01 to get the last used date of a query

    Dear All,
    I tried to create a query on 0TCT_MC01 to get the last used date of a query.
    Since we do not have readily available key figure for Last used date, could any one help me out to achieve this result?
    I am interested to find the old queries which are not being used anymore.
    Thanks in advance.

    You can get the info from the below tables
    if you are working with BW 3.5 you can look in table RSDDSTAT in BI 7.0 it is RSDDSTAT_OLAP.
    Make a selction on the infocube and the OLAP Statistic Object which is the query ID and execute. Then you should see how often the query was executed, by whom and which date/time.
    in field Statistics Object Name Query ID you type in the tech name of the query
    from the Counter for statistics event calls -- will give the count... no of times the query used least the count lesser the query is used.
    Regards
    KP
    Edited by: Konduru Prashanth. on Dec 22, 2011 2:44 PM

  • I need to  know the name of the database table and the fields in that table

    hi,
    i need to I need to  know the name of the database table and the fields in that table for the following fields of the front end .
    1) incident details.
    2) ownership details
    3) injury type
    4) % of investigation completed withen 7 days.
    5) count of incident type
    6) cost of workers compensation claim.
    7) injury resulting from for workers compensation claim
    8) investigation free text.
    9) investigation contribution factors.
    10) investigation root cause.
    11) investigation root cause free text
    12) employee risk assesment
    13) protential infrigment notice issued
    14) actual infrigment notice issued.
    15) actual infrigment notice reference number.
    16)vehicle damaged text.
    18) when the incident occured.
    thanks and regards,
    pronoy .

    Hello,
    Check CCIHT* under se16 and search for relevant information
    Thanks
    Jayakumar

  • Could the Database Trigger get a forms variable value

    Hi All
    We have an ERP which connect all users of the system with a single schema (Database user name), We create a record for each user in the ERP itself to specify the privillages for each user
    I would like to make a database trigger to Audit a table , by storing the user name, action (Insert,delete,update) on an audit table.
    The problem is the user name i want to store is not the schema name, but it's stored in a database table and read in a global variable.
    Can i get the user name (which stored in the global variable) in the database trigger ???
    Thanks
    Mostafa Abolaynain

    If this global variable lives inside Forms (which the title of your post seems to indicate), then no.
    A database trigger can only reference "stuff" that lives inside the database session at the database server, not "stuff" that lives inside the proces at the client device.
    You should ask your ERP vendor: there might very well be something (eg. a variable inside a database package) that you can use.

  • I got an unused Adobe After effects CS6 from an ebay seller.He said the disc was cracked and sent me the 24 digit number key.Do I still need the disc to get the program?And where do i input the 24 digit key?Also do I have to sign up for CC I can't afford

    I got an unused Adobe After effects CS6 from an ebay seller.He said the disc was cracked and sent me the 24 digit number key.Do I still need the disc to get the program?And where do i input the 24 digit key?Also do I have to sign up for CC I can't afford that monthly charge.

    You can download from the page linked below:
    CS6 - http://helpx.adobe.com/x-productkb/policy-pricing/cs6-product-downloads.html

  • Is it possible to query a collection and get the last logged on user?

    Hi
    Is it possible in SCCM to query a collection to get the computer names and the last logon user for each computer? I cant seem to find how to do this?
    Thank you

    try this out
    Select distinct   
    v_R_System.Netbios_Name0 AS [Computer Name],  
    v_GS_COMPUTER_SYSTEM.UserName0 AS [User Name]
     from v_R_System
    left join v_GS_COMPUTER_SYSTEM on (v_GS_COMPUTER_SYSTEM.ResourceID = v_R_System.ResourceID) 
    inner join v_fullcollectionmembership as b on (b.ResourceID = v_R_System.ResourceID) 
    left join v_GS_SYSTEM_CONSOLE_USAGE_MAXGROUP ON v_GS_SYSTEM_CONSOLE_USAGE_MAXGROUP.ResourceID = v_R_System.ResourceID
            inner join v_GS_SYSTEM e on e.resourceid = b.resourceid
     Where
    b.CollectionID = @collectionid
    Blog: http://theinfraguys.com
    Follow me at Facebook
    The Infra Guys Facebook Page
    Please remember to click Mark as Answer on the answer if it helps you in anyway

  • I did a pre-order on a music album then I did not realize you needed to check the email to get the album so by accident I canceled it now I lost my album please help

    I did a pre-order on a music album then I did not realize you needed to check the email to get the album so by accident I canceled it now I lost my album please help

    In list view, select the album column. To choose which columns appear, select an item on the left side of the window (a playlist, for example), choose View > View Options, and select the information you want to see. You can also Control-click a column heading to select columns to display.
    The column selected determines how tracks are displayed.  For example, clicking the "Name" column displays all tracks in alphabetical order; clicking the "Album" column displays the tracks in album order; clicking the "Date Added" column displays the tracks in the order that they were imported into your library.  Columns also have a disclosure arrow at the right of the column (when selected) that you can click to reverse the order.

  • Enterprise Manager is not able to connect to the database instance. The state of the components are listed below.

    Dear all,
    I have trouble to connect em console to database instance. My database is 11.2.0.3 and before this I did the patching from version 11.2.0.1, and now i cannot get fully functionality of em console.
    error is:
    Enterprise Manager is not able to connect to the database instance. The state of the components are listed below.
    It shows that agent is connected, database and listener is up.
    I did recreation, dropping and recreating with emca, but no success.
    Did anyone have similar problems with em console?
    Regards,

    You need to first of all, Connect to the Database as SYSDBA (because your were not connected), then start the database (because it is not started).
    If you already used the username and password in the command prompt and you are sure that the database is already stared, then you need to set the ORACLE_SID before you open SQLPlus. This is because if SQLPlus does not know the SID you are connecting to, it simply thinks it is not up or has no service hence the message "Connected to an idle instance".

  • Error: 28005, Severity: 16, State: 2...An exception occurred while enqueueing a message in the target queue. Error: 15517, State: 1. Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impe

    I've seen some similar questions, but want to make sure I can get an answer quickly and how to fix.
    Thanks,
    Paul
    spid24s     Error: 28005, Severity: 16, State: 2
    spid24s     An exception occurred while enqueueing a message in the target queue. Error: 15517, State: 1. Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated,
    or you do not have permission.

    Hi Paul,
    I also had the same error on one of my servers, and it was because the user that created the database no longer worked for the company.
    So when his AD account got deleted, the database had NULL as owner
    Using the following query I asked for the owners of the databases:
    select name, suser_sname(sid) from master.dbo.sysdatabases
    So changing the owner of the databases that had a NULL owner solved the issue for me.
    use <databasesname>
    go
    exec sp_changedbowner 'sa'
    Thanks for triggering the solution.
    Peter

  • Is there anyway to tell what is the database column behind the form field (

    Is there anyway to tell what is the database column behind the form field (in Oracle financials).

    If you are lucky, it can be simple, but if you are unlucky, it can be very complicated.
    Using Help > Diagnostics > Examine when in the field will give you the name of the field.
    Help > Diagnostics > Examine (Block: SYSTEM / Field: LAST_QUERY) will give you the query for the last block queried, which may or may not be the block you want, depending on how the form is defined (ie Master Detail relationships). If this is for the correct block and the field name is one of the columns returned by the query, then that is probably your answer.
    If the Last Query is not for the correct block, using Help > Record History will give you the table or view that the block is based on (only where there is already a record in the block).
    If the field name matches a column name in the table or view, then that is probably where it comes from. If there is no matching column name in the table or view, then the field is probably not queried directly from the database as part of the main query - it is probably populated by logic in the form, like the POST-QUERY trigger on the block. This means you need to open the form in Forms Builder to find what is populating your field (Program > Find and Replace PL/SQL is very handy for this).

  • I am working on a file I created in Indesign CC 2014 and when I try to rearrange pages in the Pages menu or try to package the file, I get the spinning wheel for 20 mins. then it crashes. What should I do?

    Can anyone help? I started a 24 page document in Indesign CC 2014 and have been using the file off of a dropbox acct on my two machines (desktop and macbook pro). I need to rearrange some of the pages but when I try to drag and drop the pages in the Pages menu, I get the ominous spinning wheel...for about 20 mins at times. then It will just crash. The document doesn't have a tone of images. I've also tried to collect and package the file but get the same thing.
    What should I do?? Help!

    try the script at Adobe Community: InDesign 6 is crashing when attempting to open a particular document. All others are opening OK.
    I'd also try moving the pages to a new file, though I suspect that will crash too. Divide and conquer might work -- tray one of your operations on half the document at a time, then repeat by dividing any piece that fails, and so on, until you isolate a page, then use the same method to isolate an object (though it's possible you have a corrupt page).

  • I accidentally quit my CC on my Macbook pro and now the cloud icon is grayed out and every time I hover over it with the mouse I get the spinning beach ball of death on the icon. I have no idea how to open it because when I use spotlight search to open it

    I accidentally quit my CC on my Macbook pro and now the cloud icon is grayed out and every time I hover over it with the mouse I get the spinning beach ball of death on the icon. I have no idea how to open it because when I use spotlight search to open it it gives me a message saying "Creative Cloud is not open anymore" help!

    Since you didn't include any pertinent info such as the Mac model and OS version you are running, here is some general information:
    Mac OS X: Gray screen appears during startup
    Depending on which OS yours came with originally - and which OS you are now running - you would either need your original install disks - you can call Apple for replacements by giving them your serial number. Or you may be able to reinstall the OS by using recovery (again, depends on which model/which OS).

  • Error -1074384569; NI-XNET: (Hex 0xBFF63147) The database information on the real-time system has been created with an older NI-XNET version. This version is no longer supported. To correct this error, re-deploy your database to the real-time system.

    Hello
    I have a VeriStand-Project (VSP) created with my Laptop-Host (LTH) which works with my PXI, while
    deploying it from my LTH. Then I have installed the whole NI enviroment for PXI and VeriStand use on a
    industrial PC (iPC). I have tried to deploy my VSP from the iPC to the PXI but the following error
    message arose on my iPC:
    The VeriStand Gateway encountered an error while deploying the System Definition file.
    Details: Error -1074384569 occurred at Project Window.lvlibroject Window.vi >> Project
    Window.lvlib:Command Loop.vi >> NI_VS Workspace ExecutionAPI.lvlib:NI VeriStand - Connect to System.vi
    Possible reason(s):
    NI-XNET:  (Hex 0xBFF63147) The database information on the real-time system has been created with an
    older NI-XNET version. This version is no longer supported. To correct this error, re-deploy your
    database to the real-time system. ========================= NI VeriStand:  NI VeriStand
    Engine.lvlib:VeriStand Engine Wrapper (RT).vi >> NI VeriStand Engine.lvlib:VeriStand Engine.vi >> NI
    VeriStand Engine.lvlib:VeriStand Engine State Machine.vi >> NI VeriStand Engine.lvlib:Initialize
    Inline Custom Devices.vi >> Custom Devices Storage.lvlib:Initialize Device (HW Interface).vi
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * • Unloading System
    Definition file... • Connection with target Controller has been lost.
    The software versions of the NI products (MAX/My System/Software) between my LTH and the iPC are
    almost the same. The only differences are:
    1. LabView Run-Time 2009 SP1 (64-bit); is installed on LTH but missing on iPC. The iPC has a 32-bit system.
    2. LabView Run-Time 2012 f3; is installed on LTH but missing on iPC.
    3. NI-DAQmx ADE Support 9.3.5; something strage on the LTH, because normally I am using NI-DAQmx 9.5.5 and all other DAQmx products on my LTH are 9.5.5. That means NI-DAQmx Device Driver 9.5.5 and NI-DAQmx Configuration 9.5.5.. On the iPC side all three products are 9.5.5.. That means NI-DAQmx ADE Support 9.5.5, NI-DAQmx Device Driver 9.5.5 and NI-DAQmx Configuration 9.5.5..
    4. Traditional NI-DAQ 7.4.4; The iPC has this SW installed. On the LTH this SW is missing.
    In order to fix this problem I have formatted my PXI and I have installed the following SW from the iPC:
    1. LabVIEW Real-Time 11.0.1
    2. NI-488.2 RT 3.0.0
    3. NI_CAN 2.7.3
    Unfortunately the above stated problem still arose.
    What can I do to fix this problem?
    I found a hint on http://www.labviewforum.de/Thread-XNET-CAN-die-ersten-Gehversuche.
    There it is written to deploy the dbc file againt.
    If this is a good hint, so how do I deploy a dbc file?
    I would feel very pleased if somebody could help me! :-)
    Best regards
    Lukas Nowak

    Hi Lukas,
    I think the problem is caused by differenet drivers for the CAN communication.
    NI provides two driver for CAN: NI-CAN and NI-XNET.
    NI-CAN is the outdated driver which is not longer used by new hardware. NI replaced the NI-CAN driver with NI-XNET some years ago, which supports CAN, LIN and the FLEXRAY communication protocol.
    You wrote:
    In order to fix this problem I have formatted my PXI and I have installed the following SW from the iPC:
    3. NI_CAN 2.7.3
    NI CAN is the outdated driver. I think that you should try to install NI-XNET instead of NI-CAN on your PXI-System, to get rid of the error message.
    Regards, stephan

Maybe you are looking for

  • How do I get HDD 2 of my mac mini server to show up on my network?

    I can see the "Server" hard drive and its contents from any other computer on my network.  I can't see the second drive.  How do I get the second drive to appear on the network?

  • Same error message no matter what I do!

    I get the error message, "The software required for communicating with iPods and mobile phones was not installed correctly. Do you want iTunes to try to repair this for you?" every time I open iTunes. Regardless of whether I say yes or no in the dial

  • Missing files and other issues

    Hello everyone, We are in the process of performance testing a 2 piece workflow where a fax server places the received fax into a watched folder endpoint, a process picks it up separates the pages and pushes the single pages to another process for va

  • IPhone 3G - OS 4.0.1 tested

    Tested and it's perfect full operator signal full wifi signal and software response time too fast. Thank you apple you are the best keep it up.

  • Safari is constantly crashing.Ver 5.05

    This is the report I keep getting. " Process:         Safari [657] Path:            /Applications/Safari.app/Contents/MacOS/Safari Identifier:      com.apple.Safari Version:         5.0.5 (6533.21.1) Build Info:      WebBrowser-75332101~1 Code Type: