Creat Sequence / Auto generate No

I created a from with master and detail block
In master block I assigned a field (FRNO) autogenerated
written the following code in pre-insert.
declare
          v_sr number(4):=0;
     begin
          select max(frno) into v_sr from fabric_rec ;
          if v_sr is not null or v_sr<>0 then
               :fabric_rec.frno:=v_sr+1;
          else
               :fabric_rec.frno:=1;     
          end if;
     exception
          when no_data_found then
          :fabric_rec.frno:=1;
     end;
it is working successfully.
I want to also create autogenerate no in detail block
first it check table, find Max NO then increament with it,
if I use above code that is not working becauase when I enter first record in frist row it will fetch Max record+1 and when I will go on 2nd row if will fetch same although I need
in first row Max+1
and row wise increament and save in database
Message was edited by:
Kami

Dear Uzair AOA
Your code is OK. but not for my situation.
I am using master and detail block. master in form and detial in tabular.
in MAster block it is working proerply, but in detail block It can not. I want that check the max no from detail block and add+1 with the row, if I inserted in detail 5 row that will generate recored accrodingly.
like. max(srno) = 5
I inserted 5 more record in detail
then replace with 6,7,8,9,10 like that.
see my following code.
I used the following code in detail block when create record
declare
          v_sr number(4):=0;
     begin
          select max(ojobno) into v_sr from sub_fabric_rec ;
                              if v_sr is not null or v_sr<>0 then
               :sub_fabric_rec.ojobno:= v_sr + :SYSTEM.cursor_record;     
                    else
          :sub_fabric_rec.ojobno:=1;     
          end if;
     exception
          when no_data_found then
          :sub_fabric_rec.ojobno:=1;
     end;
it is working but if I inserted 5 record in detail block first 2 rows Auto No are same??
and after 2nd row other reocords working accrodingly.
like
16
16
17
18
19
20 etc

Similar Messages

  • How to Create a Auto Generated number with some preceding text in Sharepoint 2010

    I am trying to create a auto generated number field in Sharepoint 2010 list item. My requirement is to have the following format number generated when new request is created in Sharepoint using form. Auto generated Ticket ID should be in the following format
    "IR13000" "IR13001" "IR13002"....... Please let me know how to get this done. I tried to use combination of default ID and Characters but its not working for new requests, its only reflecting for existing uploaded requests. I
    am trying this for taking up Ticket requests by filling up some fields in the form. Any quick help is much appreciated.
    Thanx

    Here are the steps:
    1 - Open your SharePoint site in SP Designer 2010.
    2 - Click Workflows and add a List workflow. Associate this workflow on the list where you want the Random Text to be generated.
    3 - Inside the workflow editor, select the Action "Update list item"
    4 -  Select 'Current Item'.
    5 - Click Add.. and select the field which needs to be updated with the Random Text. Make sure this column is not of type "Calculated" type, otherwise you won't see it in the list of the fields within the workflow.
    6 - Click "..." button in the next textbox which will open String Builder dialog box.
    7 - Type IR and then click 'Add or Change Lookup and select ID column from "Field from source". Hit OK.
    8 - It should look like IR[%Current Item:ID%]
    9 - Hit OK.
    10 - Save and publish the workflow. (Please note that currently this workflow is not set to auto run on creating new items. That's because we want to test it at this point of time).
    11 - Go to your list in SharePoint and create a new item. After creating, select the item and click Workflows and then run this workflow.
    12 - You should be able to see the text "IR1" in the designated column.
    13 - Once you see that it's working, go to SPD and set the workflow to run automatically on creation of the new item. Save and publish and then return to your list in SharePoint.
    14 - Create a new item there and you should see the Random value in the column.
    15 - You will also see the column in the New form. In order to remove it, go to List settings > content types > Item content type > and select Hidden for this column so that it doesn't showup in any form.
    Try it and let me know how it goes.
    Thanks,
    Ashish

  • Script to drop/re-create sequences is generated with errors

    Hello,
    I'm migrating an Oracle 10g instance running on Solaris 10 to an Oracle 11g instance running on RedHat Linux. I'm following the "Platform Migration" White Paper ( URLhttp://www.oracle.com/technology/deploy/availability/pdf/maa_wp_11g_platformmigrationtts.pdf ).
    In the appendix, there's the code for a script that's supposed to generate an SQL script that drops and re-creates the sequences on the target machine:
    set heading off feedback off trimspool on escape off
    set long 1000 linesize 1000 pagesize 0
    col SEQDDL format A300
    spool tts_create_seq.sql
    prompt /* ========================= */
    prompt /* Drop and create sequences */
    prompt /* ========================= */
    select regexp_replace(
    dbms_metadata.get_ddl('SEQUENCE',sequence_name,sequence_owner),
    '^.*(CREATE SEQUENCE.*CYCLE).*$',
    'DROP SEQUENCE "'||sequence_owner||'"."'||sequence_name
    ||'";'||chr(10)||'\1;') SEQDDL
    from dba_sequences
    where sequence_owner not in
    (select name
    from system.logstdby$skip_support
    where action=0)
    spool off
    I have run it on my Solaris machine, and it generates a file that looks like this:
    /* ========================= */
    /* Drop and create sequences */
    /* ========================= */
    CREATE SEQUENCE "MDSYS"."TMP_COORD_OPS" MINVALUE 1000000 MAXVALUE 2000000 INCREMENT BY 1 START WITH 1000000 NOCACHE NOORDER CYCLE
    CREATE SEQUENCE "MDSYS"."SDO_TOPO_TRANSACT_SUBSEQ" MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE ORDER NOCYCLE
    I don't have any "drop sequence" commands, and there is no semicolon (;) at the end of the "create sequence" lines, so those are not executed.
    I'm not at all familiar with PL/SQL, could somebody point me to the error?
    Thank you,
    Adrian

    Why do you need the "REGEXP_REPLACE ()" function?
    This would be simpler:
    SET long 32000 longc 80 pages 0 lin 80 trims on
    COL ddl wor
    SELECT    'DROP SEQUENCE "'
           || sequence_owner
           || '"."'
           || sequence_name
           || '";'
           || CHR (10)
           || DBMS_METADATA.get_ddl ('SEQUENCE', sequence_name, sequence_owner)
           || ';'
           || CHR (10) DDL
      FROM dba_sequences
    WHERE sequence_owner NOT IN (SELECT NAME
                                    FROM SYSTEM.logstdby$skip_support
                                   WHERE action = 0);
    /:p

  • Creating an auto-generating menu for fluxbox

    Fluxbox is one of the best wms for linux. If there's something that could replace any desktop, with low resources consumption, still being accessible and handy, than that's Fluxbox. The thing is when you install Fluxbox for the first time you feel something is lacking. That thing is the possibility of an auto-generating menu. Of course there's
    fluxbox-generate_menu
    and other likewise possibilities  but they kinda fail in doing what they should.   I'm a bit new to programming and even fresher when it comes to scripting in linux but I've though of a script that could do just that as it follows:
    #!/bin/bash
    while true
    do
    men="ArchSoft"
    ver=$(grep "$men" ~/.fluxbox/menu | sed 's/.*(//; s/).*//' | tail -1)
    if [ $men == $ver ]
    then
    data="$(date +%Y-%m-%d\ %k:%M)"
    data2="$(grep "$data" /var/log/pacman.log | grep installed | sed "s/\[//g; s/\].*//g" | tail -1)"
    if [ "$data" == "$data2" ]
    then
    nr="$(grep "$data" /var/log/pacman.log | grep installed | wc -l)"
    int=$(seq 1 $nr)
    for i in $int
    do
    ch=$(grep "$data" /var/log/pacman.log | grep installed | sed 's/.*installed//g; s/(.*//g; s/ //g' | head -$i | tail -1)
    chr=$(grep "$ch" ~/.fluxbox/menu | sed 's/.*(//; s/).*//' | tail -1)
    chb=$(ls /usr/bin | grep "$ch" | sed "s/.*$ch.*/$ch/" | tail -1)
    la=$(ls /usr/share/icons/hicolor/48x48/apps | grep $ch | sed "s/.*$ch.*/$ch/"| tail -1)
    lb=$(ls /usr/share/pixmaps | grep $ch | sed "s/.*$ch.*/$ch/" | tail -1)
    if [ $ch == $chb ]
    then
    if [ $ch == $chr ]
    then
    echo "there's already a menu entry"
    else
    if [ $ch == $la ]
    then
    sed -i "/^\[submenu\] ($men)$/a[exec] ($ch) {$ch} </usr/share/icons/hicolor/48x48/apps/$ch.png>" ~/.fluxbox/menu
    sleep 1
    fluxbox restart
    elif [ $ch == $lb ]
    then
    sed -i "/^\[submenu\] ($men)$/a[exec] ($ch) {$ch} </usr/share/pixmaps/$ch.png>" ~/.fluxbox/menu
    sleep 1
    fluxbox restart
    fi
    fi
    fi
    done
    fi
    rdata="$(grep "$data" /var/log/pacman.log | grep removed | sed "s/\[//g; s/\].*//g" | tail -1)"
    if [ "$data" == "$rdata" ]
    then
    nrem="$(grep "$data" /var/log/pacman.log | grep removed | wc -l)"
    inrem=$(seq 1 $nrem)
    for i in $inrem
    do
    rem=$(grep "$data" /var/log/pacman.log | grep removed | sed 's/.*removed//g; s/(.*//g; s/ //g' | head -$i | tail -1)
    remr=$(grep "$rem" ~/.fluxbox/menu | sed 's/.*(//; s/).*//' | tail -1)
    if [ $rem == $remr ]
    then
    sed -i "/$rem/d" ~/.fluxbox/menu
    sleep 1
    fluxbox restart
    else
    echo "no menu entry to remove"
    fi
    done
    fi
    else
    sed -i "/^\[begin\] (Fluxbox)$/a[submenu] ($men)\n[end]" ~/.fluxbox/menu
    fi
    clear
    sleep 7
    done
    Explanation:
    I've used
    whilde true
    do
    sleep 7
    done
    to create an endless loop where "sleep" was used so it could take a break, therefore reducing hardware consumption
    men="ArchSoft"
    ver=$(grep "$men" ~/.fluxbox/menu | sed 's/.*(//; s/).*//' | tail -1)
    if [ $men == $ver ]
    then
    else
    sed -i "/^\[begin\] (Fluxbox)$/a[submenu] ($men)\n[end]" ~/.fluxbox/menu
    fi
    This checks if the submenu where everything should automatically be added as entries  are already there, if not it creates them under the beginning of fluxbox menu script with the name ArchSoft. 
    data="$(date +%Y-%m-%d\ %k:%M)"
    data2="$(grep "$data" /var/log/pacman.log | grep installed | sed "s/\[//g; s/\].*//g" | tail -1)"
    if [ "$data" == "$data2" ]
    then
    fi
    this compares the actual data from the system clock with the data of the installed apps shown in pacman .log and if it finds a similar data of the installed apps it procedes to further steps
    nr="$(grep "$data" /var/log/pacman.log | grep installed | wc -l)"
    int=$(seq 1 $nr)
    for i in $int
    do
    ch=$(grep "$data" /var/log/pacman.log | grep installed | sed 's/.*installed//g; s/(.*//g; s/ //g' | head -$i | tail -1)
    chr=$(grep "$ch" ~/.fluxbox/menu | sed 's/.*(//; s/).*//' | tail -1)
    chb=$(ls /usr/bin | grep "$ch" | sed "s/.*$ch.*/$ch/" | tail -1)
    la=$(ls /usr/share/icons/hicolor/48x48/apps | grep $ch | sed "s/.*$ch.*/$ch/"| tail -1)
    lb=$(ls /usr/share/pixmaps | grep $ch | sed "s/.*$ch.*/$ch/" | tail -1)
    if [ $ch == $chb ]
    then
    if [ $ch == $chr ]
    then
    echo "there's already a menu entry"
    else
    if [ $ch == $la ]
    then
    sed -i "/^\[submenu\] ($men)$/a[exec] ($ch) {$ch} </usr/share/icons/hicolor/48x48/apps/$ch.png>" ~/.fluxbox/menu
    sleep 1
    fluxbox restart
    elif [ $ch == $lb ]
    then
    sed -i "/^\[submenu\] ($men)$/a[exec] ($ch) {$ch} </usr/share/pixmaps/$ch.png>" ~/.fluxbox/menu
    sleep 1
    fluxbox restart
    fi
    fi
    fi
    done
    Here  because in pacman.log, the data of installed apps is shown in this manner YY-MM-DD hh:mm I had to consider using "for do", because in a minute a lot of applications can be installed using only a single "$pacman -S apps" command. Therefore I had to add somehow every app installed in a minute, separately to ~/fluxbox/menu. If the data of the installed apps in pacaman.log was show in this manner YY-MM-DD hh:mm:ss, therefore including seconds things would had been a lot more easier and precise, but I had to find a solution to that matter, and that solution was using "for do" .
    Also here it checks if the installed program shows as an executable in /usr/bin and if it has an icon in  /usr/share/icons/hicolor/48x48/apps/ or in /usr/share/pixmaps/, and only than it procedes in adding an entry to fluxbox menu for that app. This was necessary because not all programs installed, that have executables in /usr/bin are meant to be displayed as a fluxbox menu entry. Checking for an icon being a filter and at the same time something kinda useful for the overall aspect of the menu.
    rdata="$(grep "$data" /var/log/pacman.log | grep removed | sed "s/\[//g; s/\].*//g" | tail -1)"
    if [ "$data" == "$rdata" ]
    then
    nrem="$(grep "$data" /var/log/pacman.log | grep removed | wc -l)"
    inrem=$(seq 1 $nrem)
    for i in $inrem
    do
    rem=$(grep "$data" /var/log/pacman.log | grep removed | sed 's/.*removed//g; s/(.*//g; s/ //g' | head -$i | tail -1)
    remr=$(grep "$rem" ~/.fluxbox/menu | sed 's/.*(//; s/).*//' | tail -1)
    if [ $rem == $remr ]
    then
    sed -i "/$rem/d" ~/.fluxbox/menu
    sleep 1
    fluxbox restart
    else
    echo "no menu entry to remove"
    fi
    done
    fi
    This part of the script removes the data from the menu entry pretty much in the same manner it was added, so I won't give further explanations.
    The Trouble:
    Most applications are added and removed just fine in the fluxbox menu entry, but some like chromium are added more than once and after pacman -R app they aren't removed. The script has still a lot of flaws, most of them because I'm new to scripting, but if someone can improve it or give suggestions it would be highly appreciated. Also if anybody that finds the script worthy enough, wants to develop it as his own I have nothing against it, just tell what changes and improvements you have brought as I wanna learn too.
    Also my goal is to make a daemon out of it, any suggestions in this direction would be highly appreciated.
    Thanks for your time and understanding, mostly thanks to those that helped me a bit in understanding the syntax, like  @Karol & @falconindy. You rule, 'cause  you make linux  seam like one big happy family
    George
    Last edited by I'mGeorge (2011-06-20 19:43:08)

    This is an awesome idea. I've wanted to do something like this for a little while, though not in bash...
    Since I'm not great in bash, I may make one in C (for learning) or Python (ditto) and comment on your implementation.
    If I understand right, you're building a menu first, then deleting parts of it as you go. Would it not be smarter to create a function for adding entries and call it only after you've decided whether an app belongs in the menu? Something like this:
    function add_to_menu() {
    # echo whatever to the config file
    if (app is on system && has an icon somewhere in /usr/share or /opt) {
    add_to_menu(foo)
    Personally, I would approach this by using a definition or grouping list (so you can make submenus) and organize your apps that way. I'd probably use an sqlite db or an ini file or some other way to store the heirarchy, then generate the menu. It looks like you've already put a lot of effort into this, though, so I wish you luck on it!

  • How to create sequence

    How to create sequence(Auto generated no in oralce) with out using Triggers?
    If i create trigger sequence of numbers are getting generated but in case if i want to include explicit sequence no at the end of the table say like '9999'...it is not getting updated
    Pls help very urgent..

    user2134711 wrote:
    How to create sequence(Auto generated no in oralce) with out using Triggers? Sequence is an oracle object used to create unique number sequence. It has no connection with trigger.
    Generally Sequence is used in a Trigger to generate some column value automatically. Something like the IDENTITY column used in SQL Server.
    If i create trigger sequence of numbers are getting generated but in case if i want to include explicit sequence no at the end of the table say like '9999'...it is not getting updated This totally depends on how you have written the trigger. If you can show your trigger code we can help you out.

  • Auto Generated No with Date and year

    I m using this method to create a auto generated no.
    in pre-insert trigger
    declare
              v_l varchar2(10);
         begin
              select max(doc_no) into v_l from Table ;
              if v_l is not null or v_l<>0 then
                   :table.doc_no:= v_l+1;
              else
                   :table.doc_no:=1;     
              end if;
         exception
              when no_data_found then
              :table.doc_no:=1;
         end;I want to generate auto generate no|| month||year
    please guide me

    Kame wrote:
    I want to generate auto generate no|| month||year
    please guide meYou can get an auto-generated number using SEQUENCE in Oracle.
    Do you have a specific date column in your table from which you need to get the MONTH and YEAR Data?
    To get MONTH, you can use something like:
    TO_CHAR(your_date_column, 'MONTH')To get YEAR, you can use
    TO_CHAR(your_date_column, 'YYYY')your_date_column should contain data of date datatype.
    Examples:
    SQL> CREATE SEQUENCE SEQ
      2     MINVALUE 1
      3     MAXVALUE 999999999
      4     START WITH 1
      5     INCREMENT BY 1
      6  /
    Sequence created.
    SQL> SELECT SYSDATE FROM Dual
      2  /
    SYSDATE
    10-JUN-09
    SQL> SELECT TO_CHAR(sysdate, 'MONTH') FROM Dual
      2  /
    TO_CHAR(SYSDATE,'MONTH')
    JUNE
    SQL> SELECT TO_CHAR(sysdate, 'YYYY') FROM Dual
      2  /
    TO_C
    2009
    SQL> SELECT      TO_CHAR (SEQ.NEXTVAL)
      2           || TO_CHAR (SYSDATE, 'fmMONTH')
      3           || TO_CHAR (SYSDATE, 'YYYY')
      4              auto_gen
      5    FROM   DUAL
      6  /
    AUTO_GEN
    1JUNE2009
    SQL> /
    AUTO_GEN
    2JUNE2009
    SQL> /
    AUTO_GEN
    3JUNE2009
    SQL> /
    AUTO_GEN
    4JUNE2009
    SQL>Hope this helps.
    Regards,
    Jo
    Edit: Corrected Query

  • Numbers-Auto Generating a numbered list in a column of cells

    Having trouble creating an auto-generating numbered list in a single column. In text inspector I choose bullets>numbers>start at 1. The first cell is filled in with a "1", but when I hit return or down arrow the 1 disappears. If I go back and type a "1" again, two "1's" appear in the same cell. I'm trying to make a table with 250 rows. Not sure what I'm missing, as I'm new to iWork.

    Numbers can fill a column or row of cells with a pattern. Type the first two numbers in the first two cells, select both cells, then click on the small circle at the lower right of the second cells & drag down to fill however many cells you want. You can see in this picture that it works for other patterns, not just consecutive numbers. I've also used it to fill across month names or dates.

  • How to auto generate a sequence.

    Dear all
    The entity Object "OrderEntryEO" has an attribute called"OrdNumber" that indicates the reference number of the order number. the order number is compose be a sequence on the year. For example 1/2011 , 2/2011 , 3/2011 and so on..
    this sequence must be auto generated when pressing save button.
    I have generated the entityImpl java class "OrderEntryEOImpl.java . with accessors , DO_DML method and create method.
    these are the methods
    {code}
    protected void create(AttributeList attributeList) {
    super.create(attributeList);
    {code}
    {code}
    protected void doDML(int operation, TransactionEvent e) {
    super.doDML(operation, e);
    {code}
    Can any one please help me how to Implement this in java code
    Regards

    I wanted to clear up what I consider to be some misinformation on this thread.
    Database sequences, regardless of what magic you try (including setting the cache size to 1) can and will, by their very design have gaps. I don't care if you are doing a web app, a client server app, an SOA app, or any other newfangled or old-fashioned, red screens, green screens, blue screens - DATABASE SEQUENCES IN ORACLE CAN AND WILL HAVE GAPS.
    There is only one way to ensure gap-free sequence numbers upon insert:
    * You must lock the table or use some other device to serialise inserts.
    Any other technique you want to use will not work in a multi-user environment. I'm not going to go through the proof of it here because it's been discussed ad-infinitum (search on asktom.oracle.com if you want to see all of the crazy failed attempts to do it without serialisation). You can also read on asktom about some other techniques (such as assigning the numbers after the fact) that you could consider.
    Bottom line to remember however, Oracle Database Sequences are not and cannot be gap free (at least as of today, the 4th of April, 2011 AD at 08:48 GMT +1)
    John

  • HOW TO GET AUTO GENERATED PRIMARY ID KEY BACK FROM AN INSERT STATEMENT IN .

    Just recently I ran into a problem with what seems to be a deficiency in the Oracle Database. When trying to return an auto-generated key as is done in Microsoft's SQL database, it seems Oracle for whatever reason didn't add this capability, the key couldn't be passed back to the .Net call. After tinkering with the .Net software and talking with the Oracle techs, a decent work around to the problem (presented here) comes fairly close. Two things have to be done first before this will work. A sequence has to be created on the Oracle DB. Also a trigger has to be created against the table the keys are going to be returned from.
    The class works by passing to the function 'update_datasets_return' a DataSet with as many tables as you want. The function spins through the tables and put the keys in each row inserted. It's assumed the first row will either be the primary key or some numeric value. This can be changed by modifying the: dt.Columns(0).ColumnName
    Notice the word Inserted. On Updates and Deletes the key value is ignored because it's already present. The routine just updates the database as usual.
    So in other words you could send a table to the function with rows inserted, deleted, or updated and it will take care of them all. One routine for all.
    ' ======================================================================
    ' Created by SEF and Oracle SR: 5607364.993 This is a complete Redo
    ' of the initial concept. SEF...
    ' Sample of sequence and trigger at bottom.
    ' Uses the ODP.NET data provider.
    ' update_datasets_return: Goes thru each table in the dataset and
    ' updates, deletes, or inserts as needed.
    ' If inserting, a 'sequence counter' and a 'trigger'
    ' using the 'before insert' must be present. The sequence
    ' counter is set to auto increment by 1 starting at 1.
    ' The trigger is specific to the table.
    ' Create the trigger and sequence in the database or run the samples
    ' below in PL/SQL. Be sure the logon with a user that has enough rights.
    ' Routine assumes the first column is going to hold the sequence
    ' number. Actually any column could be used. Just change the
    ' dt.Columns(0).ColumnName to whatever you want or leave as default.
    ' The da_RowUpdated sub is where the 'sequence number' gets returned
    ' on each row that is inserted into a table. Routine is ignored on
    ' deletes and updates. SEF...
    ' =======================================================================
    Imports System
    Imports System.Data
    Imports Oracle.DataAccess.Client
    Imports Oracle.DataAccess.Types
    Public Class OracleUpdate
    Private Shared m_conn As OracleConnection
    Private Shared da As New OracleDataAdapter
    Private Shared dt As DataTable
    Private Shared conn As New OracleConnection
    Private Shared dr As DataRow
    Private Shared astep As Long
    Private Shared rwIndex As Integer = 0
    Private Shared tblIndex As Integer = 0
    Public Shared Function update_datasets_return(ByVal constr As String, ByVal ds As DataSet) As DataSet ''ByRef ds As DataSet)
    Dim selectstmt As String
    m_conn = New OracleConnection(constr)
    Try
    m_conn.Open()
    Catch ex As Exception
    Throw New ArgumentException(" Error: connection lost." & ex.Message)
    End Try
    For Each dt In ds.Tables
    ''Uncomment the code only if auto numbering
    ''is NOT turned on for the table being updated. SEF...
    ''rwIndex = 0
    ''For Each dr In dt.Rows
    '' Try
    '' Select Case dr.RowState
    '' Case DataRowState.Added
    '' astep += 1
    '' ' =======================================================
    '' ' This "Try Catch" section created only if auto numbering
    '' ' is NOT turned on for the table being updated. SEF...
    '' ' It's a crude attempt at creating a unique number.
    '' ' A more serious approach would be to use a GUID.
    '' ' Use only if you decide not to have a sequence and a
    '' ' trigger for the table.
    '' ' =======================================================
    '' Try
    '' 'ds.Tables(tblIndex).Rows(rwIndex).Item(0) = astep
    '' Catch
    '' ' ignore the error corrected integer identity so don't randomize it
    '' End Try
    '' dr.Item("createdDate") = Now
    '' dr.Item("changedDate") = Now
    '' Case DataRowState.Modified
    '' dr.Item("changedDate") = Now
    '' End Select
    '' Catch ex As Exception
    '' conn.Close()
    '' conn.Dispose()
    '' Throw New ArgumentException(" Error: update_datasets " & ex.Message)
    '' End Try
    '' rwIndex += 1
    ''Next
    selectstmt = "SELECT * From " & dt.TableName & " Where " & dt.Columns(0).ColumnName & " = " & 0
    da = New OracleDataAdapter(selectstmt, m_conn)
    Dim bldr As OracleCommandBuilder = New OracleCommandBuilder(da)
    AddHandler da.RowUpdated, New Oracle.DataAccess.Client.OracleRowUpdatedEventHandler(AddressOf da_RowUpdated)
    Dim insCmd As OracleCommand = Nothing
    Try
    insCmd = CType(bldr.GetInsertCommand(), OracleCommand)
    Catch ex As Exception
    Throw New Exception("")
    End Try
    insCmd.CommandText += " returning " + dt.Columns(0).ColumnName + " into :seqno"
    insCmd.Parameters.Add(New OracleParameter("seqno", OracleDbType.Int16, _
    4, ParameterDirection.Output, False, CType(0, System.Byte), CType(0, _
    System.Byte), dt.Columns(0).ColumnName, DataRowVersion.Current, Nothing))
    da.InsertCommand = insCmd
    Try
    ' ===========================
    da.Update(ds, dt.TableName)
    ' ===========================
    Catch ex As Exception
    Throw New ArgumentException(" Error: update_datasets_return " & ex.Message)
    End Try
    Next
    m_conn.Close()
    m_conn.Dispose()
    Return ds
    End Function
    Friend Shared Sub da_RowUpdated(ByVal sender As Object, ByVal e As OracleRowUpdatedEventArgs)
    If e.StatementType = StatementType.Insert Then
    e.Row(0) = Int64.Parse(e.Command.Parameters("seqno").Value.ToString())
    End If
    End Sub
    ' ================================================================================
    ' Notes:
    ' =================== How To -- Sample section for PL/SQL ==================================
    ' myTrigger, myTable, mySequence, and myColumn are values you need to supply.
    ' Note: A trigger needs to be created for each table.
    ' A sequence needs to be created only once and referenced each time
    ' in the trigger(s). Or you could create a new sequence each time you
    ' create a trigger. Sort of a waste of effort.
    ' Explanation:
    ' myTrigger = The name you are giving this trigger.
    ' If a trigger with same name already
    ' exist, it will be overwritten.
    ' myTable = Table you want to add the sequence numbers to.
    ' mySequence = Sequence counter you created. Whatever name you called it.
    ' myColumn = The column to update with the sequence number.
    ' =================================================================================
    ' -- Run in PL/SQL or create at DB. --
    ' create or replace trigger myTrigger
    ' before insert on myTable for each row
    ' begin
    ' select mySequence.nextval into :new.myColumn from dual ;
    ' end;
    ' -- Run in PL/SQL or create at DB. --
    ' create sequence mySequence
    ' MINVALUE 1
    ' START WITH 1
    ' INCREMENT BY 1
    ' NOCACHE; can be set to CACHE but sequence may contain gaps.
    ' Explanation of CACHE from: http://www.techonthenet.com/oracle/sequences.php
    ' With respect to a sequence, the CACHE option specifies how many sequence
    ' values will be stored in memory for faster access. The downside of creating
    ' a sequence with a CACHE is that if a system failure occurs, all cached
    ' sequence values that have not be used, will be "lost". This results in
    ' a "gap" in the assigned sequence values. When the system comes back up,
    ' Oracle will CACHE new numbers from where it left off in the sequence,
    ' ignoring the so called "lost" sequence values.
    ' Note: To recover the lost sequence values, you can always execute an
    ' ALTER SEQUENCE command to reset the counter to the correct value.
    ' NOCACHE means that none of the sequence values are stored in memory.
    ' This option may sacrifice some performance, however, you should not encounter
    ' a gap in the assigned sequence values.
    End Class
    C#:
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    public class OracleUpdater2
    private static OracleConnection m_conn;
    private static OracleDataAdapter da = new OracleDataAdapter();
    private static OracleConnection conn = new OracleConnection();
    public static DataTable load_it(string constr, string strqry, string tblName)
    // =====================================================================
    // constr = User Id=myUser;Password=myPass";Data Source=myDataSource
    // strqry = Select * from something?
    // tblName = The table name to fill.
    // =====================================================================
    conn = new OracleConnection(constr);
    conn.Open();
    da = new OracleDataAdapter(strqry, conn);
    OracleCommandBuilder bldr = new OracleCommandBuilder(da);
    DataTable dt = new DataTable(tblName);
    da.Fill(dt);
    conn.Dispose();
    return dt;
    public static DataSet update_datasets_return(string constr, DataSet ds)
    //'ByRef ds As DataSet)
    string selectstmt = null;
    m_conn = new OracleConnection(constr);
    try
    m_conn.Open();
    catch (Exception ex)
    throw new ArgumentException(" Error: connection lost." + ex.Message);
    foreach (DataTable dt in ds.Tables)
    selectstmt = "SELECT * From " + dt.TableName + " Where " +
    dt.Columns[0].ColumnName + " = " + 0;
    da = new OracleDataAdapter(selectstmt, m_conn);
    OracleCommandBuilder bldr = new OracleCommandBuilder(da);
    da.RowUpdated += new
    Oracle.DataAccess.Client.OracleRowUpdatedEventHandler(da_RowUpdated);
    OracleCommand insCmd = null;
    try
    insCmd = (OracleCommand)(bldr.GetInsertCommand());
    catch (Exception ex)
    throw new Exception("" + ex.Message);
    insCmd.CommandText += " returning " + dt.Columns[0].ColumnName + " into
    :seqno";
    insCmd.Parameters.Add(new OracleParameter("seqno", OracleDbType.Int16, 4,
    ParameterDirection.Output, false, System.Convert.ToByte(0),
    System.Convert.ToByte(0), dt.Columns[0].ColumnName, DataRowVersion.Current,
    null));
    da.InsertCommand = insCmd;
    try
    // ===========================
    da.Update(ds, dt.TableName);
    // ===========================
    catch (Exception ex)
    throw new ArgumentException(" Error: update_datasets_return " +
    ex.Message);
    m_conn.Close();
    m_conn.Dispose();
    return ds;
    If you need a working program of how this works, let me know.

    Oh my god, it is too long! You definitely check out types, casting and especially ODP.Net (it does everything for you)... etc. They can help you to simplify your code. I do not have enough time to copy paste it to Studio and understand and solve your issue, so I got title of your message as your main question.
    In Oracle, you can create an autonumber field by using sequences object. This is really useful when you need to create a unique number to act as a primary key.
    Basically you can create a sequence simply typing;
    CREATE SEQUENCE MY_SEQUENCE;
    now you have a sequence called "MY_SEQUENCE"... Then, I advice you select a number from sequence;
    select MY_SEQUENCE.nextval from dual;
    I said I advice actually kinda must, although it called sequence, I cannot be sequential. Do not even try to predict the value. You can be sure that it is unique number so you can use it.
    Then insert you record and use that number part of your primary key. I think that's it. Have fun.

  • How can i create an auto increment column

    Hello Everyone
    We are working on an EAM package which has an auto number facility but that is not meeting our requirement because some 10s and 100s of numbers keep on jumping based on the number of records the child table has.Means every record in my parent table will have some child records in another table which we call it a child table.The number of numbers that will be jumped each time will depend on the number of child records it has. Now we want to create a new column and generate a sequential unique number in my parent table with out linking it to its child table and use this number as a reference number. And we cant do that through our package customization. Can any one guide us if we can meet our requirement through oracle triggers or so.
    Thanks and Regards

    Hi,
    For "Auto-Increment" functionality - you can use a combination of a sequence and a trigger like so:
    create table roles ( role_id INT
                       , role_name VARCHAR2(30) NOT NULL
                       , creation_date DATE DEFAULT SYSDATE NOT NULL
                       , role_description VARCHAR2(255)
                       , CONSTRAINT roles_pk PRIMARY KEY (role_id)
                       , CONSTRAINT roles_uk1 UNIQUE (role_name)
    create sequence role_id_seq
    start with 1
    increment by 1
    nocache;
    CREATE OR REPLACE TRIGGER roles_pk_trig
    BEFORE
    insert on roles
    for each row
    begin
    IF :new.role_id IS NULL THEN
       SELECT role_id_seq.NEXTVAL
       INTO :new.role_id
       FROM dual;
    END IF;
    end;
    /Now any insert which leaves the "ROLE_ID" column NULL will have an auto-incremented value put in for that column. This is similar to an "Autonumber" column in Access.
    Hope this helps...
    Take care.

  • How to auto-generate a "empno" field at run time in oracle forms 6i

    Hello!
    I have connected to a SCOTT schema. And i am using emp table. At run time mode when i press F8 then the data is displayed in the fields.
    My task is to generate auto "empno" as soon as i run the form. Kindly do the needful.
    Thanks in advance

    Hi Francios,
    I think with your solution our user only able to see the current information in the form.I donot think it will auto generate the empno.
    Dear user,
    I suggest what you can do is to create one sequence in your database and use it to generate automatic
    empno.
    In post query trigger try to implement the idea.
    Suppose in the name of the sequence is empno_seq.
    if emp.empno is null then
    :emp.empno := empno_seq+1;
    end if;
    Try i hope it will work
    Regards
    Rajat

  • SQL Dev Data Modeller:  Auto-generate Surrogate PKs in the Physical Model ?

    How can I have the logical modeller allow the user to design with logical PKs, but then have surrogate primary keys be auto-generated off sequences by the modeller when it comes to create the physical model - as in conventional application design?
    Without this facility, this tool is useless, IMO.
    I want:
    i). sequences to become the physical PKs by default, and that what were the logical PKs in the logical model, to become a unique key in the physical model.
    ii). I want this set by default when generating the physical model....
    iii). ....with an option to turn this off on a entity-by-entity basis (as not all tables will necessarily require such a surrogate PK; so the logical PK may remain the physical PK).

    It is common practice that physical PKs in Oracle tables are defined from sequences (surrogate PKs), and that the logical PK from the entity becomes a unique key in the table.
    This may not always be the case in every application out there, and some people may disagree, but it is nonetheless a needed feature.
    My new Feature Request is therefore:
    I would like to see the following additions to the product.
    1. In the Preferences -> Data Modeler -> Model -> Logical, a flag that by default indicates whether the designer wishes to opt to enable this feature (ie; have all logical PKs converted to unique keys, and replaced by sequence nos. in the physical model). This flags needs to be there since in real life, albeit erroneously IMO, some people will choose not to opt to use this functionality.
    2. On every entity created in the model, there needs to be a flag that allows to override this default option, as not every table will require a surrogate PK to be generated. Being able to (re)set a flag located on the entity properties (perhaps under 'Engineer To'), will accomplish this.
    3. When Forward Engineering to the physical model from the logical, the following should happen.
    ENTITY  1 ---------->TABLE 1
    ---------------------> P * Surrogate PK
    * Attribute 1 -----> U * Column 1
    * Attribute 2 -----> U * Column 2
    o Attribute 3 ----------> Column 3
    Here you can see,
    - Attributes 1 & 2 (the logical PK) of the entity become a unique key in the table (columns 1 & 2),
    - optional Attribute 3 becomes NULLable column 3,
    - and a physical surrogate PK column is added (type unbounded INTEGER, PRIMARY KEY constraint added).
    From entity DEPT as:   (Examples based on SCOTT schema)
    DEPTNO NUMBER(2) NOT NULL <-- Logical primary key on entity
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    CREATE TABLE DEPT
    (PK_DEPT INTEGER, -- New column becomes surrogate physical PK, driven from sequence defined later
    DEPTNO NUMBER(2) NOT NULL, -- Former logical PK becomes a UK
    DNAME VARCHAR2(14),
    LOC VARCHAR2(13))
    ALTER TABLE DEPT
    ADD CONSTRAINT PK_DEPT PRIMARY KEY (PK_DEPT) USING INDEX PCTFREE 0
    ALTER TABLE DEPT
    ADD CONSTRAINT UKLPK_DEPTNO UNIQUE (DEPTNO) USING INDEX PCTFREE 0 -- Former logical PK becomes a UK (constraint name reflects this)
    CREATE SEQUENCE PK_DEPT_SEQ
    CREATE TRIGGER PK_DEPT_SEQ_TRG
    BEFORE INSERT ON DEPT
    FOR EACH ROW
    WHEN (new.PK_DEPT IS NULL)
    BEGIN
    SELECT PK_DEPT_SEQ.NEXTVAL
    INTO :new.PK_DEPT
    FROM DUAL;
    -- Or from 11g onwards, simply,
    :new.PK_DEPT := PK_DEPT_SEQ.NEXTVAL;
    END;
    From entity EMP as:
    EMPNO NUMBER(4) NOT NULL -- Logical primary key on entity
    ENAME VARCHAR2(10)
    JOB VARCHAR2(9)
    MGR NUMBER(4)
    HIREDATE DATE
    SAL NUMBER(7,2)
    COMM NUMBER(7,2)
    DEPTNO NUMBER(2)
    CREATE TABLE EMP
    (PK_EMP INTEGER, -- New column becomes surrogate physical PK, driven from sequence defined later
    FK_DEPT INTEGER, -- New FK to surrogate PK in DEPT table (maybe NOT NULL depending on relationship with parent)
    EMPNO NUMBER(4) NOT NULL, -- Former logical PK becomes a UK
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4),
    HIREDATE DATE,
    SAL NUMBER(7,2),
    COMM NUMBER(7,2),
    DEPTNO NUMBER(2))
    ALTER TABLE EMP
    ADD CONSTRAINT PK_EMP PRIMARY KEY (PK_EMP) USING INDEX PCTFREE 0
    ALTER TABLE EMP
    ADD CONSTRAINT FK_DEPT FOREIGN KEY (FK_DEPT) REFERENCES DEPT (PK_DEPT)
    ALTER TABLE EMP
    ADD CONSTRAINT UKLPK_EMPNO UNIQUE (EMPNO) USING INDEX PCTFREE 0 -- Former logical PK becomes a UK (constraint name reflects this)
    CREATE SEQUENCE PK_EMP_SEQ
    CREATE TRIGGER PK_EMP_SEQ_TRG
    BEFORE INSERT ON EMP
    FOR EACH ROW
    WHEN (new.PK_EMP IS NULL)
    BEGIN
    SELECT PK_EMP_SEQ.NEXTVAL
    INTO :new.PK_EMP
    FROM DUAL;
    -- Or from 11g onwards, simply,
    :new.PK_EMP := PK_EMP_SEQ.NEXTVAL;
    END;
    [NOTE:   I use PCTFREE 0 to define the index attributes for the primary & unique keys since the assumption is that they will in general not get updated, thereby allowing for the denser packing of entries in the indexes and the (albeit minor) advantages that go with it.
    This is certainly always true of a sequence-driven primary key (as it is by its very nature immutable), but if the unique key is likely to be frequently updated, then this PCTFREE option could be user-configurable on a per table basis (perhaps under Table Properties -> unique Constraints).
    For non-sequence-driven primary keys, this storage option could also appear under Table Properties -> Primary Key.
    I notice no storage options exist in general for objects, so you may like to consider adding this functionality overall].
    Associated Issues :
    - Preferences, 'Naming Standard: Templates' should be updated to allow for the unique key/constraint to be called something different, thus highlighting that it comes from the logical PK. I've used 'UKLPK' in this example.
    - Mark the physical PK as being generated from a sequence; perhaps a flag under Table Properties -> Primary Key.
    - When Forward Engineering, if an entity exists without a logical PK, the forward engineering process should halt with a fatal error.
    !!! MODERATOR PLEASE DELETE ME !!!

  • Auto generate forms in Oracle BPM 10.3?

    Is there an option to auto generate a form in Oracle BPM 10.3?
    The scenario is like I(as a customer) have to fill a form with few details. the next I want (in the process) is, to auto generate a form with these details and a few extra ones...how is this possible?
    Im a newbie to Oracle BPM!:)
    thanks in advance

    There's no out of the box way to automatically generate a form on the fly from a customer perspective.
    There are three ways forms are usually created in Oracle BPM 10g. You can use the out of the box BPM Object presentations, hand code JSPs based on a BPM Object using a tag library Oracle provides, and hitting external web pages.
    Of the three, BPM Object presentations are the easiest if your team is unfamiliar with JSPs. BPM Object presentations are very simple to build initially - there's a wizard that prompts you for the attributes (fields) to display and the sequence you want them displayed. As the UI is built, you'll see text labels automatically added to the left of the fields. The labels added are based on the attribute's name. Modifying the presentations after they are build is fairly easy using a table and cell drag and drop paradigm.
    If you're a JSP shop, you should definitely go the JSP route.
    If your development team is building forms using another technology and are heavily invested in this, then go the external route.
    Hope this helps,
    Dan

  • Auto-generate Chapter Markers every 5 mins?

    Is there a way of auto-generating Chapter Markers at 5 minute intervals in a particular sequence? Perhaps with the titles of "5 mins" then "10 mins" and so on...? It would be really handy.

    This would be such a great feature.
    Something like Mark > Markers > Multiple and then a dialog box that states "Place a marker every _ minutes. Okay."
    Here's what I do in FCP (you may already be doing something like this):
    1. Press Home.
    2. Press "+" on the extended numeric keypad or "shift +" on the standard keyboard. You'll see a "+" appear in the Current Time Code text field.
    3. Enter 5.00.00 (you can leave the periods out, but I use them to double check my text entry).
    4. Press Enter. The playback head will move five minutes toward the end.
    5. Add a marker (I press "m" then "m" again to add a marker and then open the Edit Marker dialog box).
    6. In the Edit Marker dialog box, click Add Chapter Marker and then press Ok. (Since you're using all keyboard shortcuts, you can position the mouse to hover over where "Add Chapter Marker" appears to make this step a bit faster).
    Repeat from step 2 until you have as many markers as you need.
    Or…
    1) If you're using DVD Studio Pro, create a text document (.txt) as follows:
    00:00:00;00 Chapter 1
    00:05:00;02 Chapter 2
    00:10:00;02 Chapter 3
    00:15:00;04 Chapter 4
    00:20:00;04 Chapter 5
    01:25:00;06 Chapter 6
    01:30:00;06 Chapter 7
    01:35:00;08 Chapter 8
    01:40:00;08 Chapter 9
    2) Continue this list until you have enough markers to span the duration of your video. (Note: if using drop frame time code, the frames will increase 2 frames every 10 minutes).
    3) Save this as "<project name> Marker List.txt" (insert the name of your project where it reads <project name>).
    4) In DVD Studio Pro, right click or control click above the timeline and select Import Marker List and select the text file that you saved.
    -Warren

  • How to change Auto-generated web service's URL

    Hi,
    is it possible to change/edit the auto-generated url of a web services created with the wizard in SE80 transaction?
    Example:
    Now the wizard generates a URL as following:
    http://<host name>:8080/sap/bc/srt/wsdl/bndg_4BC67655E5155680E10000000A7B0410/wsdl11/allinone/standard/document?sap-client=001
    where the alfa-numeric code 4BC67655E5155680E10000000A7B0410 changes every time I create the service. at the same time and for the reason above, I have to change the LOGICAL DESTINATION with "visual administrator" application to consume the service in SAP Netweaver environment.
    Thanks in advance.
    Luca

    Hi Luca,
    Please refer the below link . it is described that URLs and its Namespaces  . Please check whether its useful.
    [http://help.sap.com/saphelp_nw70/helpdata/EN/8c/780741375cf16fe10000000a1550b0/frameset.htm] .

Maybe you are looking for

  • Remote for Tv anywhere not working

    My new remote from the box will not work but everything else works fine. Any Ideas how to make my remote work?

  • Restore Exchange 2010 Database into Restore Database in stages

    I have a full backup and a number of incremental backed up using TSM. I am trying to restore a database into a recovery DB so that I can mount an old version of a users mailbox. To restore the full backup and all the subsequent incremental backups up

  • Unable to open any PDF using the Reader

    I downloaded a free trial version of Acrobat Pro, which after the tiral period requried a $19.?? monthly fee.  I decided not to buy.  Did not serve my purpose.  When the trial period ended my Reader no longer works.  I tried to download the reader ag

  • Real time replication

    I think my initial load finished and I have couple questions. 1. Checked data from both source and replicat, they are the same amount of data, is there a way to check from ggsci to ensure at the data is in-sync? 2. I checked the extract status and it

  • Help me to update the table

    hi all i have a table. In my code i am doing like this got connection and every thing need to update. -> setAutoCommit(false) -> updating here -> commiting here -> setAutoCommit(true) -> -> -> again updating here can i do this way