Generate Sequential values for a column

Hi,
I had a column in named 'ID' in the block of my form. I want to generate sequential values for the column without using sequence. Suppose if the table does not have any data it has display the starting value what i am providing.(ex. 101).If the data is there in the table If i am executing the query in the last null record it has to show the maxvalue+1 for that column. where can I write the code to get this logic? How to write the code? Can any body please solve my problem?
Thanks in advance
user1

Why don't you want to use a sequence? Do the ORDID values have to be sequential without any gaps in between?
If so, this requirement is quite hard to achieve in multi-user environment.
Some approaches:
Select the next available value from the database when creating a new record , e.g. in the WHEN-CREATE-RECORD-Trigger:
DECLARE
  CURSOR crMax IS
    SELECT NVL(MAX(ORDID), 0)+1
      FROM ORD;
BEGIN
  OPEN crMax;
  FETCh crMax INTO :ORD.ORDID;
  CLOSE crMax;
END;Pros: The user can see the new value when he starts entering the data.
Contras: When another user uses the same form to create a new record between the point of time user 1 starts entering the record and the point of time he saves, the same number will be taken again which will fail on insert for the second user (i assume there is a Unique Key on ORDID).
Result: This approach is not suitable in a multi-user environment.
Second approach:
Use the same logic as in approach 1, but select the next available number in the PRE-INSERT-trigger of the block:
Pros: The problem of approach 1 with two users getting the same number gets much more unlikely, for in general the COMMIT goes quite short after the PRE-INSERT has fired, so there will only be problems if both users save at the same moment.
Contras: Problem with duplicate numbers can still occur iunder special circumstances. The number is not shown until the Insert is issued against the database.
Result: This approach is possible, but you have to decide if the restrictions are bearable for your situation.
Further approaches:
Create a "Number table" either with just one record and one column which contains the next suitable number (lets say TAB_ORDID with column NEXT_ORDID) or with a number of records containing the next suitable numbers.
Then with the usage of SELECT FOR UPDATE you can lock a record, take the number from it and either update the row to the next value (one row apporach)or delete the row retrieved (multi row approach). Both cases require some more complex logic for retrieving the next number and can cause some trouble in multi-user-environments (ending up in all users who want to create records waiting for the one user who started and did not save correctly) if the locks are not handled correctly.

Similar Messages

  • How to set default values for boolean columns

    I'm trying to deploy some content types and columns into a site with a feature. All it's ok, except that I'm trying to set a default value for boolean columns with no success.
    I've tried to set default value at column level:
    <Field ID="{EFE23A1D-494E-45cf-832E-45E41B17F0CF}" Name="ScopeSpanish" DisplayName="Se publican noticias en español"
    Type="Boolean" Hidden="FALSE" Group="Columnas ShaCon" >
    <Default>TRUE</Default>
    </Field>
    and at content type level:
    <FieldRef ID="{EFE23A1D-494E-45cf-832E-45E41B17F0CF}" Name="ScopeSpanish" DefaultValue="TRUE" Required="TRUE" />
    But in any case, when i create a new item with this content type, default value is applied.
    Can anyone tell how to set default values for boolean columns?
    Thanks in advance,
    Regards,
    Sergio

    In the field definition you can set
    <Default>1</Default>
    or
    <Default>0</Default>
    How to set the default value Null?

  • Hide row values for certain column in GRR2

    Hi Experts,
    Looking for some help in report painter. I need to hide row values for certain columns in report painter. The requirement is I have 5 columns in the report, the 5 th column is the sum of col 1 to 4 and in my row i have a formula setup to sum of values for each column, what i would like to do is for column 1 thru 4 i didnt want to display the total values in row total but i wanted to dispaly value for column 5 in row total. I have been trying my best with putting formula, but couldnt succeed.
    Could somebody let me know is there an way to get this addressed.
    Thanks in advance
    Best Regards,
    gj

    How was it achieved ? Did you use sections for the columns for which rows needed to be hidden?
    I have a smiliar issue of hiding certain rows for few columns.

  • Calling a user defined function as default value for a column

    Hi All
    Can we call a user defined function as default value for a column ??
    for example:
    create or replace  function test1  return number is
    begin
    return 10;
    end;
    create table testt
    (id  as test1,
      name varchar2(20));
    getting error:
    Error at line 1
    ORA-02000: missing ( keywordThanks
    Ashwani
    Edited by: Ashwani on Jan 16, 2012 1:19 AM

    Hi;
    For your issue i suggest close your thread here as changing thread status to answered and move it to Forum Home » Database » SQL and PL/SQL which you can get more quick response
    Regard
    Helios

  • Default  value for a column in Table Control

    Hi friends, can i set dinamcally a default value for a column in table control?, this column is check type. This default value must appear in empty rows,
    thanks

    ADD A MODULE AS Module yyyy In ur PAI.
    as
    In PAI.
    LOOP at  itab.
    Module YYYY
    ENDLOOP.
    Module YYYY.
    LOOP AT SCREEN.
        IF SCREEN-NAME = 'ITAB-VAL’.
          ITAB-VAL = 'XXXXXXXX'        "(DEFAULT VALUE)
          SCREEN-INPUT = 0.
          MODIFY SCREEN.
        ENDIF.
    ENDLOOP.
    End module.
    *note
    make this event work only if the previous column is filled okay.
    the display will be in display mode on the screen as screen-input = 0.
    see that in the table control u can get the table field for all the rows even though you are processing on some fields .
    so what u do is make that particular filed masked(no i/p field and populate the field that will be better instead of populating all the columns okay.
    hope this helps you out ,
    regards,
    vijay.

  • Default Value for a column in matrix

    Hi,
    How to set default value for a column in matrix which is of type combo(Yes/No).
    The cell has combo in it
    Manoj

    Hi Manoj,
    The column is set as combo. Now you need to tell SBO what constituates a Y or N. In my example my Column "Col6" must display Yes if the RENTED column = 1 and No if the RENTED column = 0. (I'm obviously using a datasource to tie the data to the matrix)
    oMatrix = frm.Items.Item("YourMatrixID").Specific
            oColumns = oMatrix.Columns
    oColumn = oColumns.Item("Col6")
            oColumn.DataBind.SetBound(True, "@VIDEO", "U_RENTED")
            oColumn.ValOn = "1"
            oColumn.ValOff = "0"

  • Non sequential values for knobs

    Is it possible to set non-sequential values for the control knobs on the front panel? For example, I'd like to set values of 1, 2, 5, 10, 20, 25, 50, 100, etc...

    Use the log mapping and text labels.  See example.
    Attachments:
    Non_Seq_Knob.ctl ‏5 KB

  • Setting default values for a column

    Hi,
    I have a table having some default values for the columns. I am using a PreparedStatment to insert into this table. For null values I am using setNull(..) method but the default values given for the columns are not inserted for null values.
    eg: INSERT INTO TEST VALUES(?,?);
    where TEST table contains two columns col1 and col2 with default values 'AA' and 'BB' respectively. My requirement is to make sure that when null values are specified for the columns then the database default should be picked up. using setNull(..) method doesn't help.
    Thanks in advance.
    Gyan

    Default value for a column can be picked up from DatabaseMetaData class.
    The below snippet shows that: -
    DatabaseMetaData metaData = connection.getMetaData();
    ResultSet resultSet = metaData.getColumns(null, null, "TEST", "COL%");
    while ( resultSet.next() )
    String defaultValue = resultSet.getString("COLUMN_DEF");
    String datatype = resultSet.getString("DATA_TYPE");
    System.out.println("defaultValue = " + defaultValue);
    System.out.println("datatype = " + datatype);
    }

  • Pro*C & SQLDA with NULL value for predicate column

    Hi: I am using a C program to update a table via a dynamic sql (method 4) and SQLDA. In the update statement predicate, I have place holders (as in TBLCOL=:C000). One of the columns in the predicate contains null values, so I set L[n] = 0, V[n] = pData (which pData[0] = '\0'), *(I[n]) = -1, and T[n] = 5 (for text). I cannot find the row that I know is there.
    I cannot change my statement to contain TBLCOL IS NULL, since I don't know ahead of time if I'm looking for rows with null values for this column. The Pro*C manual says that by setting the appropriate *(I[n]) = -1, it indicates to Oracle to simulate the "IS NULL" clause, and update the appropriate rows. In my case, I receive 1403 as SQLCODE when I use TBLCOL=:C000 vs TBLCOL IS NULL. What am I doing wrong? Thank you for your help.

    You should include these columns as well;
    ChangeType (see mxi_changetype)
    ValOwner (repository)
    UserID ("jobid=<>", usermskey, GUI (mmc), DG (dyngrp), reconcile)
    IdAudit  (This is the event task (add and del member for assignments)
    ParentAuditId (AuditID of parent which last updated the attribute, not consistent)
    ChangedBy (Holds the MSKEY of the user which last changed the attribute)
    ExpiryTime
    to make sure you get a fuller picture of the audit record.
    Your selection does not cover all events and descriptions
    br,
    Chris

  • How to have a common value for a column using sql loader

    Hi Have a sql loader file which looks like below. But I am not getting how insert the same value for the column in all rows.
    id,
    crt_user_id
    BEGINDATA
    1;"system"
    2;"system"
    3;"system"
    So, instead of entering the crt_user_id as system in all rows, can we place the value at the top after the column name?

    Thanks Srini. your hint/suggestion helped me in finding the solution.
    LOAD DATA
    INFILE *
    BADFILE './TEST.BAD'
    DISCARDFILE './TEST.DSC'
    APPEND INTO TABLE TEST_TABLE
    Fields terminated by ";" Optionally enclosed by '"'
    ID,
    crt_user_id CONSTANT 'SOME CONSTANT VALUE'
    BEGINDATA
    1
    2
    3
    so by using CONSTANT key word, we can avoid tying the same value in the data

  • Display values for logical columns with several physical sources

    Hi all,
    I'm enocuntering some strange behaviour with the values displayed for a column (when we want to add it a as a filter, and in the dialogue box select 'Show All' values).
    Basically the logical column is mapped against several physical columns as the base fact table is aggregated to different levels. Additionally, one column in the fact tables has an attribute value, and these vary between the aggregated and non-aggregated table. This is not a problem.
    In the production environment, when we display the all values in the filters prompt for this column we are seeing the values being taken from one fact table. Naturally this means that not all the values possible for this column are being shown (i.e. values from the aggregated fact tables are missing). Now in one of our test environment where those fact tabels have additional data loaded, the values are being taken from one of the other fact tables. Unfortunately it is not necessarily the fact table with less data.
    My questions are:
    a) What dictates which fact table the server will use when the query in Answers doesnt use any dimensions (i.e. we are selecting just this attribute and selecting all the possible values by which it can be filtered)?
    b) Is there a way of obtaining all the values from the differente physical columns? I.e. that the display values shows the values of that logical column across all the physical fact tables? Maybe we would need to model that attribute as a logical dimension just for that attribute? Im not really sure this would work, as at the physical level the join between the dimension and fact would still have to go to only one particular fact table.
    Any info or help is much appreciated.

    Hi,
    Aggregate tables exist at physical level and are created by ETL procedures. Although i am aware that the dimension come into play when the application needs to decide which source aggregate table to use, it is not an issue here as in our query we are not involving dimensions. We are selecting just this one columen, and then the filter option on this column, then in the dialogue box we select 'All Choices', only the values from one of the source tables is being shown.
    This is not a probelm within reports, i think it is a product limitation in that in that option to list all values a user can filter by, it is not possible to display all the values from the different fact tables to which that column is mapped.
    Has anyone else encountered this behaviour?

  • Using default values for a column

    Hi,
    I am using PL/SQL Developer, where for some columns in a table I've defined 0 as default value.
    After running some queries on the table (insert,update) I realized that all the columns that are supposed to have 0 value (default), actually have NULL value.
    Please advice about possible reason.
    Thanks

    Hi,
    You might have explicitly inserted a NULL value in those columns. Have a look at the below test case:
    SQL> create table test(a number, b number default 0, c number default 1);
    Table created.
    SQL> insert into test (a) values (10);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
    SQL> insert into test (a, b) values (10, null);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
            10                     1
    SQL> insert into test (a, b, c) values (10, null, null);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
            10                     1
            10
    SQL> insert into test (a) values (20);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
            10                     1
            10
            20          0          1Regards

  • Cannot generate dynamic alert for initial column in SNP.

    Hello,
    I have an SNP alert macro with a simple condition running from Initial column for 158 weeks. The alert is generated correctly for all other weeks but not for initial column.
    The IF condition works correctly because a CELL_BG() in the same alert macro is correctly changing the color of the Initial column cell.
    Is there some setting I need to make to generate alert for initial column?
    Regards,
    SS

    Hello jejeje,
    thanks for your efforts - what you describe is something users have found out on our side too - a problem remains: you can save this setting "Period from last Selection" and it brings you to the INITIAL column but: once you have scrolled forward in the SNP data view (so that the INITIAL column has disappeared) and you leave the SNP data view or select another product ... it "remembers" that you last time left the data view NOT having INITIAL column as a start column.
    So, my users say that they scroll back to INITIAL column before selecting another part or using another SelectionID or leaving the SNP data view ... and of course they hate this since they have to do this a few hundred times a day worse case.
    We had a call open to SAP on this and I told them that is about productivity and usabaliity issue moving from SCM5.0 to SCM7.0 - but they have nothing more to say than "not supported anymore" - and the ultimate solution is / will be to modifiy SAP SCM standard coding - unless somebody from SAP is reading the discussioons here and is dedicated to help their customers which pay millions every year into SAP support fees.
    Thanks for your responses and effort !
    Regards
    Thomas

  • Create hash value for clob column ?

    Hi,
    does anybody know a way to calculate a hash value for a clob column (9i) ?
    DBMS_UTILITY.GET_HASH_VALUE could only handle varchar2(4000).
    Thank you!
    Regrads
    Michael
    Message was edited by:
    mseiwert

    I can't reproduce it on my 10.2.0.4.0. CTL file:
    load data
    INFILE *
    Replace into table samp
    fields terminated by ","
    trailing nullcols
    no,
    col1 Char(100000000) ,
    col2 Char(100000000) enclosed by '"' and '"'
    BEGINDATA
    1,asdf,"assasadsdsdsd""sfasdfadf""sdsdsa,ssfsf"
    2,sfjass,"dksadk,kd,ss""dfdfjkdjfdk""sasfjaslaljs"Loading:
    SQL> Create table samp
      2  (
      3  no number,
      4  col1 clob,
      5  col2 clob
      6  );
    Table created.
    SQL> host sqlldr scott/tiger control=c:\temp\samp.ctl log=c:\temp\samp.log
    SQL> select * from samp
      2  /
            NO
    COL1
    COL2
             1
    asdf
    assasadsdsdsd"sfasdfadf"sdsdsa,ssfsf
             2
    sfjass
    dksadk,kd,ss"dfdfjkdjfdk"sasfjaslaljs
            NO
    COL1
    COL2
    SQL> SY.

  • Insert into .. sql return incorrect value for 2 columns,sometime no value

    Hello,
    Oracle 10.2.0.3 , sol 10. (recently upgraded from oracle9i & sol8)
    sql query is used to populate a table. sometimes it is populating same values for all the records in 2 columns. Sometimes not populating or partially populating 1 other column. other times its running fine.
    SQL is not changed at all. When run again , it populates correctly.
    any help is highly appreciatied.
    --pooja                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    no ORA errors while execution. Its completing successfully.
    and its an intermittent issue. when the SQL is run manually its gives perfect results. Rerunnign the entire process is also fine. Conclusivly, data & SQL has no problem.
    its an insert into table <SQL>
    SQL contains left outer join.
    example:
    Expected output:
    1 john texas
    2 smith MA
    3 rob michigan
    Actual Output
    1 john texas
    2 smith texas
    3 rob texas

Maybe you are looking for

  • 10,000 Recorc Per Second (In EJB 3.0)

    hi all, i have some mission critical tasks into my project, is it possible to persist 10 000 record per seconds, 1. AS - JBoss Application Server 4.0.4GA 2. Database - Oracle 10G 10.2.0.1 3.EJB - 3.0 Framework 4.OS - SunOS 5.10 4.Server - Memory: 16G

  • HT4759 How do I know what version I'm running on my iPad?

    How do I know what version is running on my iPad?

  • I need help with my mapping - CL_MAPPING_XMS_PLSRV3-ENTER_PLSRV

    hi, guys, i need help with my mapping, i dont know this error (i not speak english) <Trace level="1" type="B">CL_MAPPING_XMS_PLSRV3-ENTER_PLSRV</Trace> <Trace level="2" type="T">......attachment XI_Context not found </Trace> <Trace level="3" type="T"

  • Aggregation level in only bps ?

    hi friends, can we need aggregation level in reporting for only bps module or for normal cubes also. so what is the if we use for normal cube alos., Tu suneel.

  • WS_SDK XI 3.1 Query Scheduler Queue

    We've a single XI 3.1 server running a single scheduler which processes one scheduled report at a time. Is it possible using the WS-SDK to query the scheduler queue to see how many reports are currently in the queue for process (i.e. those that shoul