Can i create a sequence using java?

Hi,
I have a problem here.
I have to update records to my oracle9i database.
One of the fields in my tables has to be auto number, meaning whenever i add records to this table, this fields will automatically be updated jus like a counter.
I am told that i could do this by writing a sequence. can any1 help me out?
Thanks a million!

To create a sequence in Oracle you can use this (with SCHEMA being replaced by whatever Schema that you are adding the Sequence to)...
CREATE SEQUENCE SCHEMA.SEQUENCEGENERATOR
START WITH 1 INCREMENT BY 1 MINVALUE 1 CACHE 20 NOCYCLE NOORDER ;
From a stored procedure or java code you could
then use the following to get the next available number
SELECT SEQUENCEGENERATOR.nextval INTO v_record_id from dual;
This may or may not work for your needs. Everytime the Select statement is executed a number will be "used". As an alternative you could use something like .... Select Max(number) from Table (this could be table that contains your "auto number" or a seperate support table.

Similar Messages

  • Can I create Oracle Database using Java ???

    HI ...
    Can I create a Database using Java... ? If yes can any one tell me how ? I mean provide some codeing help... ???

    If you mean a table yes, since the create table statement is exactly that, an SQL statement, if you mean an SID then I would have to say (AFAIK) no.

  • Can not create i.war using java -jar ords.war static

    C:\glassfish4\ords>java -jar ords.war static "c:\app\sybrandb\apex_4.2.6\apex\im
    ages"
    WAR Generation complete
    WAR location     : C:\glassfish4\ords\i.war
    Context path     : /i
    Static resources : c:\app\sybrandb\apex_4.2.6\apex\images
    Ensure the static resources are available at path: c:\app\sybrandb\apex_4.2.6\ap
    ex\images
    on the server where the WAR is deployed
    I downloaded ORDS from OTN yesterday
    Needless to say this directory does exist (it works when I run the listener standalone, providing this path)
    Why is everything which Oracle releases in this area always broken and badly documented?
    HELP!
    Sybrand Bakker
    Senior Oracle DBA

    To create the manifest, you use the constructor
    JarOutputStream(OutputStream out, Manifest man).
    However, I am having problems with creation of my files and I came here to look for answers. No .war file i have created has been deployable.

  • Can't create a sequence within a pl/sql block with execute immediate.

    Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
    Thanks,
    Mark

    In a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
    There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
    Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
    You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
    And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
    Justin

  • Creating aVirtual directory Using java

    Hai ,
    I am Using windows XP Operating system, I know how to create a directory using java,
    can you please suggest me a procedure to create a virtual(web share ) directory using java.
    waiting for your reply
    Thanks & Regards,
    Naga Raju

    Virtual Programmer is in the to share the directory
    over the Internet.No, that's a file/web server. :) I see, it's a Microsoft term.

  • How can i create splash screen using netbean?

    how can i create splash screen using netbean?

    Welcome to the Sun forums.
    gabbyndu wrote:
    how can i create splash screen..Java 6 offers a splashscreen functionality. See [New Splash-Screen Functionality in Java SE 6|http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/splashscreen/] *(<- link)* for details.
    [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp] has offered splash screens to applications since Java 1.2. See [How can I provide my own splash screen?|http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/faq.html#206] in the JWS FAQ for more details.
    .. using netbean?We don't support Netbeans here. Ask that on a [Netbeans forum|http://forums.netbeans.org/].

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • How to create a TOOLBOX using Java  - a real CHALLENGE for U

    Hello,
    I want to create a Toolbox using Java which will contain different components of my interest.I should be able to select one component and paste it in a frame also be able set the property of individual component after placing in the frame,just like VB toolbox.
    Can anybody suggest with code samples??
    Regards,
    Suraj.

    You are essentially asking how to write an IDE (Integrated Development Environment). This is a big question. You might start by looking at existing IDE's (JBuilder, Forte...) and see how they do it. If you want source, there is probably an open source IDE you can lift most of your code from.

  • Want To create Zip file  using java,And Unzip without Java Program

    I want to create a zip text file using java, I know Using ZipOutputStream , we can create a zip file, , But i want to open that zip file without java program. suppose i use ZipOutputStream , then zip file is created But for unZip also difftrent program require. We cant open that zip file without writing diff java program.
    Actually i have one text file of big size want to create zip file using java , and unzip simply without java program.Its Possible??
    Here is one answer But I want to open that file normal way(
    For Exp. using winzip we can create a zip file and also open simply)
    http://forum.java.sun.com/thread.jspa?threadID=5182691&tstart=0

    Thanks for your Reply,
    I m creating a zip file using this program, Zip file Created successfully But when im trying to open .zip file i m getting error like "Canot open a zip file, it does not appear to be valid Archive"
    import java.io.*;
    import java.util.zip.*;
    public class ZipFileCreation
         public static void main (String argv[])
         try {
         FileOutputStream fos = new FileOutputStream ( "c:/a.zip" );
         ZipOutputStream zip = new ZipOutputStream ( fos );
         zip.setLevel( 9 );
         zip.setMethod( ZipOutputStream.DEFLATED );
    //     get the element file we are going to add, using slashes in name.
         String elementName = "c:/kalpesh/GetSigRoleInfo092702828.txt";
         File elementFile = new File ( elementName );
    //     create the entry
         ZipEntry entry = new ZipEntry( elementName );
         entry.setTime( elementFile.lastModified() );
    //     read contents of file we are going to put in the zip
         int fileLength = (int)elementFile.length();
         System.out.println("fileLength = " +fileLength);
         FileInputStream fis = new FileInputStream ( elementFile );
         byte[] wholeFile = new byte [fileLength];
         int bytesRead = fis.read( wholeFile , 0 /* offset */ , fileLength );
    //     checking bytesRead not shown.
         fis.close();
    //     no need to setCRC, or setSize as they are computed automatically.
         zip.putNextEntry( entry );
    //     write the contents into the zip element
         zip.write( wholeFile , 0, fileLength );
         zip.closeEntry(); System.out.println("Completed");
    //     close the entire zip
         catch(Exception e) {
    e.printStackTrace();
    }

  • How to create sql database using java frame or appelet?

    hi ! i am working on database project i want to create a database using java frame or applet where it asks user to select the location for database to be created , after user have specified the path then the programs creates the database, again i want that database to be read and write by another frame or applet but as user select the path how do i make the connectivity. i just have basic knowledge on java. please give me idea how can i process further.
    thanks a lot

    While duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
    See http://hsqldb.org/
    I've not used it yet (but soon though), and I can't really advise anyone about it.
    However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.

  • How to create a Folder using java.

    Hi All,
    I have a doubt. I want to create a folder using java.
    Inputs are the destination where the folder should be created and the name of the folder. Plz help me in this regard.
    thanks and regards,
    Vincent .R.

    check out javadoc for java.io
    File reldir=new File("NewDir");//relatively where your program runs
    reldir.mkdir();
    File absdir=new File("C:/NewDir");//absolute path
    reldir.mkdir();
    File newdir=new File(absdir,"SubDir");//defines another dir under absdir
    newdir.mkdir();
    Gil

  • HT5071 Can I create a book using the IBooks Author word processing software, save it as a PDF, then have it professionally printed by an offset press to sale in brick and mortar stores? If so, is this procedure free me from any IBooks restrictions?

    Can I create a book using the IBooks Author word processing software, save it as a PDF, then have it professionally printed on an offset press to sale in brick and mortar stores? If so, is this procedure free from any IBooks restrictions?

    It's your content, under your control.
    If you output as an .ibooks file, and you want to sell it, the store is the only outlet, otherwise, you can do as you wish.

  • How do I increase the maximum number of images I can acquire in a sequence using the IMAQ 1424 with 80 MB of onboard memory and a Duncan Tech camera?

    I've increased the maximum number of buffers to higher than I need, but I still cannot acquire more than 139 images with the Duncan Tech digital video camera before I get a memory lock error. Is there any way to increase the number of images I can acquire in a sequence using the IMAQ 1424 with 80MB of onboard memory?

    It sounds like you are already bypassing the onboard memory. If you weren't, you would only be able to acquire about 20 images.
    If I understand correctly, you do not convert the images until after you acquire them. This means each acquired image is 4.13 MB, and 139 images will take 574 MB of memory. I wouldn't be surprised if that was all the free memory available on a 1 GB machine. The operating system, LabVIEW and any other software running probably take up the rest of the memory. You might want to put your computer on a diet and minimize the number of other programs and utilities running. The only other option I see is getting more memory if possible.
    Is there a way that you can reduce the number of images you need to acquire? Pe
    rhaps skipping every other frame? Do you really need more than 139 images?
    Is it possible to acquire the images in monochrome? That would triple the number of images that you could acquire.
    Bruce
    Bruce Ammons
    Ammons Engineering

  • Can't Create New Sequence

    FCS2 Upgraded and updated yesterday.
    For some reason starting today I can't create new sequences. New Sequence doesn't make a new sequence in any of the bins (but doesn't crash - just nothing happens), whether from the File menu or right-clicking in a bin.
    Importing XML (from Color or even via Color > Send to FCP) doesn't create a sequence either.
    Creating a new project gives me an empty project, with no sequences in it either.
    Anyone?

    And, as always, FCP Rescue can make backing up or trashing your preferences nice and easy.
    http://fcprescue.andersholck.com/
    Once you've got a functioning preference set, you can back it up to restore later in case this happens again.
    --Tex

  • How can i create slaes order using BAPI

    hi all,
    i didnt work on BAPIS .how can i create sales order using BAPI here i should pass Z values.
    Moderator message : FAQ, search for available information. Thread locked.
    Edited by: Vinod Kumar on Sep 13, 2011 12:22 PM

    Hi!
    There are a lot of answered threads regarding your question. Try searching first. Below is a sample link.
    BAPI_SALESORDER_CREATEFROMDAT2
    Regards,
    Steph
    Edited by: stephquion on Sep 13, 2011 8:25 AM

Maybe you are looking for

  • Forecast splitting not working correctly

    Hello I have a problem with the forecast splitting not working correctly.  We are using 2M->W     2 MONTH IN WEEKS     0  GLEI and most of the time this appears to work fine but there are occasions where the forecast is split for May, did not split J

  • Iweb update wont install

    When I chatted with Tech Support because my website that I have been running for 3+ years wouldn't publish they had me download iweb update 3.0.2 When I downloaded it and tryed to install it I get the following error in the Destination Select portion

  • AAA Server IP Pool based on AAA Client

    Hi, I have a scenario where I need to be able to allocate an IP address to a user group from a pool on the AAA server based on the AAA client that the user authenticates against. So for example if the user comes in on CPE1 they get assigned an addres

  • Sessions Not Closed After 'Execute Unix/Linux SSH Script' Activity

    Hello, Wondering if anyone out there has some experience with running "Execute Unix/Linux SSH Script" activities against a "Unix/Linux System" target and able to help? We have a process that runs an ssh script on a Unix/Linux target and in the 'Targe

  • Newbie File Management - with a focus on Backup/Archive

    Hi, I apologize if this question is a "stupid" one... but I'm a "newbie" to a lot of the professional-level issues addressed here. I'm VERY interested in LR as a way of moving up from iPhoto as my image management application. I've gotten a lot more