Clarification on the limitation of sequence generator in T-SQL

Hi, I found this limitation of sequence numbers for T-SQL:
"If there are multiple instances of the NEXT
VALUE FOR function specifying the same sequence generator within a single Transact-SQL statement, all those instances
return the same value for a given row processed by that Transact-SQL statement. This behavior is consistent with the ANSI standard."
From this link:  http://technet.microsoft.com/en-us/library/ff878058.aspx
Does this mean that if we want to have different value generated then we can't use it in multi-threading environment whereby multiple instances / processes are calling the same T-SQL code that generate the sequence numbers using the
NEXT VALUE FOR function?
My understanding of the above might not be correct, any sample example to illustrate this limitation? 
Thanks

Hi
This is the meaning of the comment in the article.
If you are using in a single t-sql
statement several times (NEXT VALUE FOR) then it will act as you use the same value. This is in-design :-)
try this for example:
select (NEXT VALUE FOR MySequenceName),(NEXT VALUE FOR MySequenceName),(NEXT VALUE FOR MySequenceName) -- same value several times
But you can use (NEXT VALUE FOR) several time like this:
DECLARE @QQ_01 int, @QQ_02 int, @QQ_03 int, @QQ_04 int
SET @QQ_01 = NEXT VALUE FOR MySequenceName;
SET @QQ_02 = NEXT VALUE FOR MySequenceName;
SET @QQ_03 = NEXT VALUE FOR MySequenceName;
SET @QQ_04 = NEXT VALUE FOR MySequenceName;
SELECT @QQ_01,@QQ_02,@QQ_03,@QQ_04 -- different valus
Hope this clarify things :-)
[Personal Site] [Blog] [Facebook]

Similar Messages

  • Knowing the Primary Key Sequence Generator of a table

    Hello All,
    I'm working on an application that uses Oracle toplinks/JPA for persistence. The entity classes in the application have primary key fields with annotations @Id and @GeneratedValue(strategy = GenerationType.AUTO). Per our understanding, this means the primary key generation is done by JPA/Top-links. When we see our database, we notice only one SEQUENCE table available and that table has only one row, while in the application, we are getting different sequence numbers for the primary key of each entity. So, not clear on how this sequence number is generated. Could anybody share information on where the sequence number is stored for each entity/table? Really appreciate your help here. Our database is MSSQL.
    Thank you,
    Venkatesh

    EclipseLink/TopLink uses Table sequencing for GenerationType.AUTO because it is more portable between databases. My understanding of your issue is from
    http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Table_sequencing
    Each row in the table represents one sequence generator, and your entities are all using the same default sequence generator and so all use the same row.
    To use multiple rows I believe you need to define multiple TableGenerators.
    Best Regards,
    Chris

  • JPA: Oracle Sequence Generator not up to date

    Hi,
    I'm using the JPA Oracle Sequence Generator in one of my JPA classes:
    @Entity
    @Table(name = "DACC_COST_TYPE")
    public class JPACostType implements Serializable {
    @SequenceGenerator(name = "CostTypeGenerator", sequenceName = "DACC_COST_TYPE_SEQ")
        @Column(name = "ID_COST_TYPE")
        @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CostTypeGenerator")
        private Integer idCostType;
    In order to persist a new object I perform the following code:
    @PersistenceContext
    private EntityManager em;
    JPACostType myJPA = new JPACostType();
    myJPA.setIdCostType = null;
    em.merge(myJPA);
    em.flush();
    Normally this works fine. But after deploying the app there sometimes happens an error:
    Caused by: javax.persistence.PersistenceException: SQLException while inserting entity {com.karmann.dacc.ejb.busilog.jpa.JPACostType(idCostType=4)}.
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.flush(PersistenceContextImpl.java:278)
    at com.sap.engine.services.orpersistence.core.PersistenceContextImpl.beforeCompletion(PersistenceContextImpl.java:565)
    at com.sap.engine.services.orpersistence.entitymanager.EntityManagerImpl.beforeCompletion(EntityManagerImpl.java:410)
    at com.sap.engine.services.orpersistence.environment.AppJTAEnvironmentManager.beforeCompletion(AppJTAEnvironmentManager.java:197)
    at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:232)
    ... 52 more
    Caused by: java.sql.SQLException: ORA-00001: unique constraint (AEMA.DACC_COST_TYPE_PK) violated
    Obviously JPA does not fetch the new key by accessing the Oracle sequence. This documents "next value = 5". Does JPA fetch the new key from its cache? Is there any possibility to avoid this?
    Thanks for each hint,
    Christoph

    Hello Christoph Schäfer  ,
    I am stuck with a similar issue. I was able to save mutiple entries and there has not been much change to my JPA. I added new entities and new sequences.
    Now, I get the error Caused by: javax.persistence.PersistenceException: java.sql.SQLException: ORA-02289: Sequence ist nicht vorhanden.
    I have checked the name of sequence and sequence next val on the DB. It works on DB but when i execute it from ejb, it gives me thsi error. Now, it gives the error for all previously working JPA entities.
    I have also provided allocationSize = 1 for all entities.
    Please let me know, possible cause/solution to this issue.
    thank you.
    Regards,
    Sharath

  • Buffered event counting. Why can't I explicitly sequence generating the Sample Clock Pulse and reading the counters?

    At irregular occasions I need to grab counts from several counters, and buffering the counts must be done simultaneously for all counters. I'm modeling my approach after zone.ni.com/devzone/cda/tut/p/id/5404 which someone kindly pointed out in an earlier thread. However, that example only uses one counter, and you can't test the synchronization with only one counter, so I am using two counters configured the same way, and they're wired to a single benchtop signal generator (for example at 300 kHz).
    What I want to do, I can test in a loop with a somewhat random wait in it. I want to drive a hardware digital output line high for a few ms and then low again. The hardware line is physically connected to terminals for my timing vi's Sample Clock Source and so will cause them to buffer their counts for later reading. After I pulse this line, when I know new good buffered counts await me, I want to read both my counters. If their bufferings are simultaneous, then each counter will have counted the same number of additional counts since the last loop iteration, which I can check by subtracting the last value sitting in a shift register and then subtracting the two "additional counts" values and displaying this difference as "Diff". It should always be 0, or occasionally +1 followed immediately by -1, or else the reverse, because buffering and a count could happen practically at the same moment.
    When I do this using a flat sequence to control the relative timing of these steps, so the read happens after the pulse, the counters often time out and everything dies. The lengths of time before, during, and after the pulse, and the timeout value for the read vi, and the size of the buffer and various other things, don't seem to change this, even if I make things so long I could do the counting myself holding a clipboard as my buffer. I've attached AfterPulse.vi to illustrate this. If I get 3 or 10 or so iterations before it dies, I observe Diff = 0; at least that much is good.
    When I use two flat sequences running in parallel inside my test loop, one to control the pulse timing, and the other to read the counters and do things with their results, it seems to work. In fact, Diff is always 0 or very occasionally the +/- 1 sequence. But in this case there is nothing controlling the relative timing such that the counters only get read after the pulse fires, though the results seem to show that this is true. I think the reads should be indeterminate with respect to the pulses, which would be unreliable. I don't know why it's working and can't expect it to work in other environments, can I? Moreover, if I set some of the pulse timing numbers to 1 or 2 or 5 ms, timeouts start happening again, too. So I think I have a workaround that I don't understand, shouldn't work, and shouldn't be trusted. See SeparateSequence.vi for this one.
    I also tried other versions of the well-defined, single sequence vi, moving the counter reads to different sequence frames so that they occur with the Sample Clock Source's rising edge, or while it is high, or with the falling edge, and they also often time out. I'll post these if anyone likes but can't post now due to the attachment limit.
    Here's an odd, unexpected observation: I have to sequence the reads of the counters to occur before I use the results I read, or else many of the cycles of this combine a new count from one counter with the one-back count from the other counter, and Diff takes on values like the number of counts in a loop. I though the dataflow principle would dictate that current values would get used, but apparently not so. Sequencing the calculations to happen after the reads fixes this. Any idea why?
    So, why am I not succeeding in taking proper control of the sequence of these events?
    Thanks!!!
    Attachments:
    AfterPulse.vi ‏51 KB
    InSeparateSequence.vi ‏49 KB

    Kevin, thanks for all the work.
    >Have you run with the little execution highlighting lightbulb on? -Yes. In versions of this where there is no enforced timing between the counter and the digital line, and there's a delay inserted before the digital line, it works. There are nearly simultaneous starts on two tracks. Execution proceeds directly along the task wire to the counter. Meanwhile, the execution along the task wire to the digital high gets delayed. Then, when the digital high fires, the counter completes its task, and execution proceeds downstream from the counter. Note, I do have to set the timeout on the counter longer, because the vi runs so slowly when it's painting its progress along the wires. If there is any timing relationship enforced between the counter and the digital transition, it doesn't work. It appears to me that to read a counter, you have to ask it for a result, then drive the line high, and then receive the result, and execution inside the counter has to be ongoing during the rising line edge.
    >from what I remember, there isn't much to it.  There really aren't many candidate places for trouble.  A pulse is generated with DIO, then a single sample is read from each counter.  -Yup, you got it. This should be trivial.
    >A timeout means either that the pulse isn't generated or that the counter tasks don't receive it. - Or it could mean that the counter task must be in the middle of executing when the rising edge of the pulse arrives. Certainly the highlighted execution indicates that. Making a broken vi run by cutting the error wires that sequence the counter read relative to the pulse also seems to support that.
    >Have you verified that the digital pulse happens using a scope? -Verified in some versions by running another loop watching a digital input, and lighting an indicator, or recording how many times the line goes high, etc. Also, in your vi, with highlighting, if I delete the error wire from the last digital output to the first counter to allow parallel execution, I see the counter execution start before the rising edge, and complete when the line high vi executes. Also, if I use separate loops to drive the line high and to read the counter, it works (see TwoLoops.vi or see the screenshot of the block diagram attached below so you don't need a LV box). I could go sign out a scope, but think it's obvious the line is pulsing given that all these things work.
    >Wait!  I think that's it!  If I recall correctly, you're generating the digital pulse on port0/line0...  On a 6259, the lines of port 0 are only for correlated DIO and do not map to PFI. -But I'm not using internal connections, I actually physically wired P0L1 (pin 66) to PFI0 (pin 73). It was port0/line1, by the way. And when running some of these vi's, I also physically jumper this connection to port0/line2 as an analog input to watch it. And, again, the pulse does cause the counter to operate, so it clearly connects - it just doesn't operate the way I think it is described operating.
    For what it's worth, there's another mystery. Some of the docs seem to say that the pulse has to be applied to the counter gate terminal, rather than to the line associated with the sample clock source on the timing vi. I have tried combinations of counter gate and or sample clock source and concluded it seems like the sample clock source is the terminal that matters, and it's what I'm using lately, but for example the document I cited, "Buffered Event Counting", from last September, says "It uses both the source and gate of a counter for its operation. The active edges on the gate of a counter is used to latch the current count register value in a hardware register which is then transferred via Direct Memory Access...". I may go a round of trying those combinations with the latest vi's we've discussed.
    Attachments:
    NestedSequences.png ‏26 KB

  • How to avoid the parameters accepting screen generated by crystal report

    Hi ,
    I designed one rpt file which will take one parameter and trying to run that file from java servlets. But I am getting one problem. I am passing parameters from jsp and setting those to the crystal report but, instade of generating the report, it is generating one jsp page which is having text feild , after enter the parameter value onece I submit this page then only I am getting required output.
    anybody please help me in this. Below I am placing my code.     
                   ReportClientDocument reportClientDocument = new ReportClientDocument();
                   CrystalReportViewer viewer = new CrystalReportViewer();
                   ServletContext cxt = req.getSession().getServletContext();
                   String fileName = "C:/Documents and Settings/Administrator/Desktop/lib-so/ix_sample2.rpt";
                   try
                        String realPath = fileName;
                        reportClientDocument.open(realPath, 0);
                        viewer.refresh();
                        viewer.setReportSource(reportClientDocument.getReportSource());
                   catch(Exception e)
                        System.out.println("inside catch block...");
                        e.printStackTrace();
                   IReportSource reportSource = reportClientDocument.getReportSource();
                   Fields oFields = new Fields();  
                   ParameterField portfolio = new ParameterField();
                   portfolio.setName("Portfolio");
                    Values oValues = new Values();
                      ParameterFieldDiscreteValue oParameterFieldDiscreteValue = new ParameterFieldDiscreteValue();
                       oParameterFieldDiscreteValue.setValue(new Integer(16));
                       oValues.add(oParameterFieldDiscreteValue);
                       portfolio.setCurrentValues(oValues);
                       portfolio.setReportName(fileName);
                       oFields.add(portfolio);
                          viewer.setOwnPage(false);
                               viewer.setParameterFields(fi);
                       try {
                             viewer.processHttpRequest(req, res, cxt, res.getWriter());
                             viewer.dispose();
                       catch (ReportSDKExceptionBase e) {
                             e.printStackTrace();
    thanks,
    Mallikarjun
    Edited by: mallikarjuna.ch1 on May 17, 2009 9:58 AM

    Thanks a lot for worthful suggetion Neeraj.
    I got resolved my problem. I have one more issue, please give a clarification about that.
    my doublt is,
    For parameterized rpt file running purpose I need to set the database details . every jar file is placed in application lib only. And my CRConfig.xml file also placed bellow.
                  <?xml version="1.0" encoding="utf-8"?><CrystalReportEngine-configuration>
        <timeout>1</timeout>
        <ExternalFunctionLibraryClassNames>
              <classname> </classname>
              <classname> </classname>
        </ExternalFunctionLibraryClassNames>
    <keycode>B6W60-01CS200-00GCPT0-0JY1</keycode>
    <Javaserver-configuration>
    <DataDriverCommon>
         <JavaDir>D:\inventex\crystal_report\Business Objects\j2sdk1.4.2_08\bin</JavaDir>
        <Classpath>$</Classpath>
         <IORFileLocation>$</IORFileLocation>
         <JavaServerTimeout>1800</JavaServerTimeout>
         <JavaServerStartupTimeout>30</JavaServerStartupTimeout>
         <JVMMaxHeap>64000000</JVMMaxHeap>
         <JVMMinHeap>32000000</JVMMinHeap>
         <NumberOfThreads>100</NumberOfThreads>
    </DataDriverCommon>
    <JDBC>
         <CacheRowSetSize>100</CacheRowSetSize>
         <JDBCURL>jdbc:sqlserver://10.0.0.65:1433;DatabaseName=reportmanager</JDBCURL>
         <JDBCClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</JDBCClassName>
         <JDBCUserName>malli</JDBCUserName>
         <JNDIURL></JNDIURL>
         <JNDIConnectionFactory></JNDIConnectionFactory>
         <JNDIInitContext>/</JNDIInitContext>
         <JNDIUserName>weblogic</JNDIUserName>
         <GenericJDBCDriver>
              <Default>
                   <ServerType>UNKNOWN</ServerType>
                   <QuoteIdentifierOnOff>ON</QuoteIdentifierOnOff>
                   <StoredProcType>Standard</StoredProcType>
                   <LogonStyle>Standard</LogonStyle>
              </Default>
              <Sybase>
                   <ServerType>SYBASE</ServerType>
                   <QuoteIdentifierOnOff>OFF</QuoteIdentifierOnOff>
                   <DriverClassName>com.sybase.jdbc2.jdbc.SybDriver</DriverClassName>
                   <StoredProcType>Standard</StoredProcType>
                   <LogonStyle>MySQL</LogonStyle>
              </Sybase>
         </GenericJDBCDriver>
    </JDBC>
    <XML>
         <CacheRowSetSize>100</CacheRowSetSize>
         <PreReadNBytes>4096</PreReadNBytes>
         <XMLLocalURL></XMLLocalURL>
         <SchemaLocalURL></SchemaLocalURL>
         <XMLHttpURL></XMLHttpURL>
         <SchemaHttpURL></SchemaHttpURL>
    </XML>
    <JavaBeans>
        <CacheRowSetSize>100</CacheRowSetSize>
         <JavaBeansClassPath></JavaBeansClassPath>
    </JavaBeans>
    </Javaserver-configuration>
    </CrystalReportEngine-configuration>
    still it is showing "Error finding JNDI name (sql server) " error. I am solving this problem setting these paramers through program.

  • Java persistence: sequence generator not working in expected way.

    Hi,
    I just played around with java persistence api and found that sequence generator annotations for making new primary key value not working correctly in my code. following is part of my code related to this problem.
    in entity class:
    @SequenceGenerator(name="mySeq", sequenceName="MY_SEQ_IN_DB")
    @Id
    @GeneratedValue(strategy=SEQUENCE, generator="mySeq")
    @Column(name = "UPLOAD_ID", nullable = false)
    private Integer uploadId;
    I have a sequence called MY_SEQ_IN_DB in my oracle 9i testing db. When I ran the code to save a new entity instance to database I found that the new upload id is not the one that should be created from the MY_SEQ_IN_DB sequence, while the sequence was not increased either. It's instead something starting from 97 (in my pc), and increased just like a sequence, but every time I reran my code the sequence restarted itself again beginning with 97(of course the insert failed with primary key conflict). the behavior just looks like it's a sequence created and managed totally by the persistence api or toplink itself (I guess).
    So, my question is, is this a designed behavior or have I done something wrong to make it not using the correct sequence in the db?
    I used hibernate before, and assigning new primary key from sequence in this way works fine.
    Thanks
    JC.L

    There are some things in Java which can't be serialized. When contained within a higher-level class such as Buttons. A button can be associated with an Action Listener. Now, you can serialize a button; however you can't serialize an action listener - for what should be to you obvious reasons. This is NOT an error and so there is no need to throw an exception when serializing the button.
    Basically: Applet sends servlet button, but not listener.

  • How to edit the contents of spools generated by smartforms

    Hi All,
    I am developing a print form using print work bench & smartforms.
    There is a requirement to generate both preprinted forms (contains only datas) and Non-preprinted forms (contains u2026 data + layout + colors + picturesu2026etc) using a single smartform.In which the non-preprinted part should only get converted into pdf & preprinted should only be get printed.
    For this I am making a replica of the first two pages of non-preprinted into preprinted format in the same smartform(total 4 pages).
    Here I am able to extract & save the non-preprinted part from the spool into PDF.
    After the above process, I want to edit the spool content, & then sent to printer.
    But clueless about editing the spool content...
    ( for eg:- delete the first two pages of content in the spool & print the rest)
    So my question is u2026.
    -Is it possible to edit the contents of spool generated by smartforms u2026 ?
    (Is it possible to copy the content of existing spool ,edit, save it into new spool  and delete the old one. )
    Any solutions / suggestions u2026 ?
    Thank you for your attention.
    With Regards,
    santh

    Hi Niki,
    Thank you for your time & suggestions....
    >
    Niki wrote:
    >
    > try to control it in smartform itself.....(above idea will not work).
    >
    > try this ...
    >  from ur driver program pass a variable to identify o/p is preprinted forms or non-preprinted forms
    Yes, I got your point... I even tried this option also.
    First of all the user want both(preprinted-hardcopy & non-preprinted pdf) form in a single process, so that data integrity is maintained both in hardcopy & soft copy.
    Even if I negotiate tha above requirement....
    The problem is , I am using Print WorkBench , not an user-defined driver program.Inside printworkbench , the smartform is mentioned.
    The process is as follows...
    ea40/ea60(isu billing transaction) -> Printworkbench ->smartforms -> spool -> printer(preprint part) / pdf(non - preprint).
    Hope u understand my limitations....
    Still expecting a solution...
    Regards,
    santh

  • Comments on the 285GTX and the Limiter

    I ask if you have the time and are willing, please post your experiences or feedback with the 285GTX and the limiter whether positive or negative. I will forward to the appropriate parties This is not a official Adobe request or anything incase any are wondering.

    Thank you for the feedback. The limiter comes into play on the 285GTX when you add effects to a 4th layer or higher video and leave the tracks active. The yellow line above your sequence will turn red indicating that the effects for that layer will be processed by the CPU and you will have to render out those effects to export them with the sequence. If you monitor your CPU usage once you add effects to a 4th layer or higher, you will see it increases far more for that layer than it did for the previous 3 layers. Basically what the limiter does is force you to render your timeline if you have effects beyond the first 3 layers and increases CPU usage allot more for any effects beyond the 3rd layer. This requires those projects to take more time due to rendering the effects on those layers. For many that may not be an issue but for those with tight deadlines it will be. If you monitor your GPU usage while playing back 3 layers with several effects, you will see the 285GTX is not being pushed hard with just 3 layers. It is not based on the codec of the material. AVCHD and R3D had the same limitation with regards to effects processing and the limiter.
    My request for feedback is to determine if most people are barely pushing their 285GTX cards with 3 layers. Also it is to determine if you would purchase a Quadro card due to the limiter.I will forward this information to our contacts at Nvidia and Adobe to show them the limiter is completely uncalled for. That is the only way we are going to get this changed now or with the Fermi Geforce cards.

  • How to set a sequence generator as a value

    When i am creating a new object in a table there is a unique id i want to keep to identify this object and I use sequence generator. I believe the command is DB_SEQ_PK.NEXTVAL, do i put this statement as a "SQL EXP" in the Source value for the specific variable i want to set it to? Please give me the right expression if i am wrong thank you.

    Raj,
    i tested it with the emp table the following way:
    Extend This Application
    A page or application component
    Component > Form > Table
    [selected EMP table, page 40, the rest default]
    Edit Page 40
    Edit Page Item P40_EMPNO
    Alternate source used: Only when current value is session state is null
    Source Type: SQL Query
    Source value or expression: SELECT CT_ID_SEQ.NEXTVAL FROM DUAL;
    Apply Changes
    Run Page
    [The empno field shows a value of 50]
    [I enter 'test' into the ename field and click 'Create']
    [I receive the error: ORA-01400: cannot insert NULL into ("EAS"."EMP"."EMPNO")]
    I'm not sure what i am doing wrong here.
    Thanks

  • Sequence Generator problem in OWB Mapping

    Hi,
    I am using a Sequence Generator in my Dimension mapping. And OWB implements the mapping via an Oracle MERGE statement.
    However when I execute the mapping my sequence number value gets incremented even when there are only updates and no inserts taking place during the execution.
    I am using the sequence number only for inserts and not for updates in the mapping.
    Is there a way to avoid this situation or a work around to this problem? This is very urgent and any help in this area would be greatly appreciated.
    Thanks

    Hi
    I also have the same problem as I loose the seq numbers when there are updates only and I do not want to loose thousands of seq numbers. I tried with bulk size =1 as well as row based only execution but no result.
    The thing which solved this problem is to have outer join with source and target, then use splitter to find out new and updated records (by looking the join key as null on target table side), then use a fuction to generate seq number when the key is not null. But doing all this does not seem to be elegant performance point of you. I do not want to join source and target due to performance issues.
    Could you pl clrify your apprach. Are you using , Source minus target and Source Intersect Target . What you will do if there is no one to one matching between source and the target.
    Thanks

  • Multiple referenced relationships over the same intermediate dimension - generated processing query

    Hi, I know the title is a bit confusing so let me try to explain it:
    I have added 3 new dimensions do the AdventureWorks cube - RefA, RefB and RefC:
    They are all related to the DimReseller table, and finally, to the FactResellerSales table. In the dimension usage chart, you can see that there are 4 referenced relationships using the Reseller dimension as the intermediate dimension. The Geography
    was the existing one, and the other 3 were added.
    Now, if I process a partition from the Reseller Sales measure group, the Profiler catches this generated query on the server:
    SELECT [dbo_FactResellerSales].[dbo_FactResellerSalesSalesAmount0_0] AS [dbo_FactResellerSalesSalesAmount0_0]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesOrderQuantity0_1] AS [dbo_FactResellerSalesOrderQuantity0_1]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesExtendedAmount0_2] AS [dbo_FactResellerSalesExtendedAmount0_2]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesTaxAmt0_3] AS [dbo_FactResellerSalesTaxAmt0_3]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesFreight0_4] AS [dbo_FactResellerSalesFreight0_4]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesDiscountAmount0_5] AS [dbo_FactResellerSalesDiscountAmount0_5]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesUnitPrice0_6] AS [dbo_FactResellerSalesUnitPrice0_6]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesUnitPriceDiscountPct0_7] AS [dbo_FactResellerSalesUnitPriceDiscountPct0_7]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesTotalProductCost0_8] AS [dbo_FactResellerSalesTotalProductCost0_8]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesProductStandardCost0_9] AS [dbo_FactResellerSalesProductStandardCost0_9]
    ,[dbo_FactResellerSales].[dbo_FactResellerSales0_10] AS [dbo_FactResellerSales0_10]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesEmployeeKey0_11] AS [dbo_FactResellerSalesEmployeeKey0_11]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesPromotionKey0_12] AS [dbo_FactResellerSalesPromotionKey0_12]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesSalesTerritoryKey0_13] AS [dbo_FactResellerSalesSalesTerritoryKey0_13]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesResellerKey0_14] AS [dbo_FactResellerSalesResellerKey0_14]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesProductKey0_15] AS [dbo_FactResellerSalesProductKey0_15]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesCurrencyKey0_16] AS [dbo_FactResellerSalesCurrencyKey0_16]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesOrderDateKey0_17] AS [dbo_FactResellerSalesOrderDateKey0_17]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesShipDateKey0_18] AS [dbo_FactResellerSalesShipDateKey0_18]
    ,[dbo_FactResellerSales].[dbo_FactResellerSalesDueDateKey0_19] AS [dbo_FactResellerSalesDueDateKey0_19]
    ,[dbo_DimReseller_6].[GeographyKey] AS [dbo_DimResellerGeographyKey5_0] -- 1
    ,[dbo_DimReseller_22].[RefAKey] AS [dbo_DimResellerRefAKey7_0] -- 2
    ,[dbo_DimReseller_23].[RefBKey] AS [dbo_DimResellerRefBKey9_0] -- 3
    ,[dbo_DimReseller_24].[RefCKey] AS [dbo_DimResellerRefCKey11_0] -- 4
    FROM (
    SELECT [SalesAmount] AS [dbo_FactResellerSalesSalesAmount0_0]
    ,[OrderQuantity] AS [dbo_FactResellerSalesOrderQuantity0_1]
    ,[ExtendedAmount] AS [dbo_FactResellerSalesExtendedAmount0_2]
    ,[TaxAmt] AS [dbo_FactResellerSalesTaxAmt0_3]
    ,[Freight] AS [dbo_FactResellerSalesFreight0_4]
    ,[DiscountAmount] AS [dbo_FactResellerSalesDiscountAmount0_5]
    ,[UnitPrice] AS [dbo_FactResellerSalesUnitPrice0_6]
    ,[UnitPriceDiscountPct] AS [dbo_FactResellerSalesUnitPriceDiscountPct0_7]
    ,[TotalProductCost] AS [dbo_FactResellerSalesTotalProductCost0_8]
    ,[ProductStandardCost] AS [dbo_FactResellerSalesProductStandardCost0_9]
    ,1 AS [dbo_FactResellerSales0_10]
    ,[EmployeeKey] AS [dbo_FactResellerSalesEmployeeKey0_11]
    ,[PromotionKey] AS [dbo_FactResellerSalesPromotionKey0_12]
    ,[SalesTerritoryKey] AS [dbo_FactResellerSalesSalesTerritoryKey0_13]
    ,[ResellerKey] AS [dbo_FactResellerSalesResellerKey0_14]
    ,[ProductKey] AS [dbo_FactResellerSalesProductKey0_15]
    ,[CurrencyKey] AS [dbo_FactResellerSalesCurrencyKey0_16]
    ,[OrderDateKey] AS [dbo_FactResellerSalesOrderDateKey0_17]
    ,[ShipDateKey] AS [dbo_FactResellerSalesShipDateKey0_18]
    ,[DueDateKey] AS [dbo_FactResellerSalesDueDateKey0_19]
    FROM (
    SELECT [dbo].[FactResellerSales].[ProductKey]
    ,[dbo].[FactResellerSales].[OrderDateKey]
    ,[dbo].[FactResellerSales].[DueDateKey]
    ,[dbo].[FactResellerSales].[ShipDateKey]
    ,[dbo].[FactResellerSales].[ResellerKey]
    ,[dbo].[FactResellerSales].[EmployeeKey]
    ,[dbo].[FactResellerSales].[PromotionKey]
    ,[dbo].[FactResellerSales].[CurrencyKey]
    ,[dbo].[FactResellerSales].[SalesTerritoryKey]
    ,[dbo].[FactResellerSales].[SalesOrderNumber]
    ,[dbo].[FactResellerSales].[SalesOrderLineNumber]
    ,[dbo].[FactResellerSales].[RevisionNumber]
    ,[dbo].[FactResellerSales].[OrderQuantity]
    ,[dbo].[FactResellerSales].[UnitPrice]
    ,[dbo].[FactResellerSales].[ExtendedAmount]
    ,[dbo].[FactResellerSales].[UnitPriceDiscountPct]
    ,[dbo].[FactResellerSales].[DiscountAmount]
    ,[dbo].[FactResellerSales].[ProductStandardCost]
    ,[dbo].[FactResellerSales].[TotalProductCost]
    ,[dbo].[FactResellerSales].[SalesAmount]
    ,[dbo].[FactResellerSales].[TaxAmt]
    ,[dbo].[FactResellerSales].[Freight]
    ,[dbo].[FactResellerSales].[CarrierTrackingNumber]
    ,[dbo].[FactResellerSales].[CustomerPONumber]
    FROM [dbo].[FactResellerSales]
    WHERE OrderDateKey >= '20080101'
    AND OrderDateKey <= '20081231'
    ) AS [FactResellerSales]
    ) AS [dbo_FactResellerSales]
    /*** One JOIN per Referenced Relationship ***/
    ,[dbo].[DimReseller] AS [dbo_DimReseller_6] -- 1
    ,[dbo].[DimReseller] AS [dbo_DimReseller_22] -- 2
    ,[dbo].[DimReseller] AS [dbo_DimReseller_23] -- 3
    ,[dbo].[DimReseller] AS [dbo_DimReseller_24] -- 4
    WHERE (
    ([dbo_FactResellerSales].[dbo_FactResellerSalesResellerKey0_14] = [dbo_DimReseller_6].[ResellerKey]) -- 1
    AND ([dbo_FactResellerSales].[dbo_FactResellerSalesResellerKey0_14] = [dbo_DimReseller_22].[ResellerKey]) -- 2
    AND ([dbo_FactResellerSales].[dbo_FactResellerSalesResellerKey0_14] = [dbo_DimReseller_23].[ResellerKey]) -- 3
    AND ([dbo_FactResellerSales].[dbo_FactResellerSalesResellerKey0_14] = [dbo_DimReseller_24].[ResellerKey]) -- 4
    As you can see in the comments, the generated query contains 1 join on the referenced table
    per referenced relationship. This can slow down the processing if both the Fact table and the Referenced Dimension table are big (and they usually are, otherwise the design would be different). The thing is, all 4 tables are filtered in the
    WHERE clause on the same condition, which makes perfect sense. This leads to the conclusion that all 4 columns could have been read from a single join.
    I was quite surprised by this kind of query generation and I can't seem to find a reason why this would be so, or how it could be avoided. Naturally, the RefAKey, RefBKey, RefCKey columns could be added to the Fact table, eliminating the need for referenced
    relationships, but this would add 3*4 bytes per row to the Fact table. The Fact table in my real example contains around 3 billion rows, so adding extra bytes is painful. (Yes, it's partitioned but still ... )
    The referenced relationships could also be "dematerialized" by removing the famous Materialize check in the relationship settings. Then again, this would issue a join to the referenced tables at query time, slowing down the query.
    Has anyone been profiling processing queries like this one and stopped to think about it?

    I don't believe it's on the Essbase side, as it uses a fairly standard API to allow string input to such things, and it's limitation is well beyond 512 chars even for a direct formula input.<BR><BR>I instead suspect that a carriage return/line feed is being inserted by the ODBC driver as part of it's output formatting, and this is causing the API to consider the input record "completed." I could be wrong, of course, but if you examine the Memo field closely, you may find the formatting to have migrated to the Access database, and even if not, you are still using ODBC to access it on the output side, so we're back to the same issue.<BR><BR>Perhaps it really is an issue related to the ODBC drivers in Essbase, but it's not unique to dim build, to formulas, or Essbase for that matter. Allowing a single field to <i>output</i> more than 512 chars in a single field is where I believe you will find the real issue.<BR><BR>Again, we need an ODBC expert to weigh in on this. <img src="i/expressions/face-icon-small-smile.gif" border="0"><BR>

  • Issues with Sequence Generator

    I'm having trouble with Sequence generator not generating continuous numbers starting from 1, each time I run the mapping.
    I want the Sequence to start from 1, each time the mapping is run. For this to happen, I'm using a pre-mapping operator which uses an oracle procedure to reset the sequence.
    But, the sequence generates the numbers from some weird number, say 3508 and then jumps to 5006 and so on. I'm not able to track what's wrong with the sequence. I have stopped the caching in Sequence but still it hasn't helped. I'm sure and have verified that the procedure being used to reset the sequence is running fine.
    Please suggest some additional parameters/properties at OWB level to be checked for the sequence, if any OR any thoughts on why the sequence is not starting from 1. Thanks in advance.
    Thanks,
    Sachin
    Edited by: 850549 on Apr 23, 2011 11:43 AM
    Edited by: 850549 on Apr 23, 2011 11:44 AM

    Could you check whether the sequence you use has a cache value greater than 1 defined in the database. This way if your database regularly should be stoped, e.g for offline backup, you'll loose the sequence values that were unused in memory at that time. That way the gaps in your surrogate ids would be explainable.

  • Sequence generating duplicate numbers

    Hi guys,
    this might be more of a DBA question type... we had a situation where we copied data (once full schema and other time only tables ) from one database to another but ended up having sequence problem because new sequence was generating numbers which were lower than previousley generated one !
    I wonder if anyone had similar problem or know what could be causing it.
    when we copy full schema this happens to random table/sequences.
    Thanks for reading.
    Ali

    The sequence skipping behaviour is seen when cached sequences are exported.
    From the Oracle utilities manual
    >
    If transactions continue to access sequence numbers during an export, sequence numbers might be skipped. The best way to ensure that sequence numbers are not skipped is to ensure that the sequences are not accessed during the export.
    Sequence numbers can be skipped only when cached sequence numbers are in use. When a cache of sequence numbers has been allocated, they are available for use in the current database. The exported value is the next sequence number (after the cached values). Sequence numbers that are cached, but unused, are lost when the sequence is imported.
    >
    Hope this helps
    Varad

  • Sequence generator

    Hi All,
    I am populating a dimension table with a primary key field populated from a sequence generator. The target table is on a SQL Server database and from the literature online, it appears a sequence generator object does not exist in S Server. How do I work around this ? I have tried to create a sequence object through ODI but Im not clear on how to call this sequence generator from the interface. Is this the right approach to populating this sequence fiels ? Any ideas ?
    Thanks
    MN

    Hi MN,
    Look into this link http://odiexperts.com/?p=450
    the other way is to using an variable and row number .
    In variable call like this ' SELECT NVL(MAX(<SEQUENCE_COLULMN_ID>,0)) FROM TARGET_TABLE
    In the interface call like this #VARIABLE+ROWNUM and call the variable in refresh mode and then the Interface.
    This way once the variable fetches the max value, using rownum for the number of insert we can increment the number .
    This method is for Oracle now dealing with SQL Server , i think you can make use of ROW_NUMBER() OVER (ORDER by COLUMN ) for rownum. You can google and learn more about it .
    I have personally not tried it sql server so i am not sure how much help row_number will be.
    Hope this helps.

  • Can a sequence generate negative numbers?

    Hi
    Thank you for reading my post
    i think my sequence generate negative numbers , is it possible ?or somewhere in my application is incorrect ?
      CREATE SEQUENCE  "HR"."GLOB_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 5 NOCACHE  ORDER  NOCYCLE ;is there anything that i made wrong which caused the negative numbers in my edit box ?
    type of my category_ID is number.
    Thanks

    Generally speaking yes you can generate negative numbers:
    SQL> create sequence seq1 increment by -1;
    Sequence created.
    SQL> select seq1.nextval from dual;
    NEXTVAL
    -1
    SQL> /
    NEXTVAL
    -2
    But if you have defined minvalue as 1 it is impossible because:
    SQL> create sequence seq1 increment by -1 minvalue 1 maxvalue 1000000 start with 1;
    Sequence created.
    SQL> select seq1.nextval from dual;
    NEXTVAL
    1
    SQL> /
    select seq1.nextval from dual
    ERROR at line 1:
    ORA-08004: sequence SEQ1.NEXTVAL goes below MINVALUE and cannot be instantiated
    SQL>
    So most probably someone simply inserted a row with negative values knowing that they'll never be in conflict with sequence generated values, or your code is buggy :)
    Generally for surrogate keys (assuming this is your case) you don't care what values they have.
    Gints Plivna
    http://www.gplivna.eu

Maybe you are looking for

  • SAP Client is very slow with windows 8 Pro 64 bit

    Dear All, I'm currently using Win8 Pro 64bit OS and SAP 7.30 PL3 am facing a slow performance compared to my old Win 7 system with 7.20, Actually i upgraded one of my users OS with Win8 ( previously it was Win7 32 bit ) after that SAP started giving

  • Question from waveform chart

    Hi, this must be a simple question, but I want to "fix" time axis "between 0sec and 10sec" although the running time of my vi is more than 100 sec, i.e., I want to reset the waveform chart every 10sec. Please help me out thanks.

  • Extension Installer in infinite loop

    Hi, I'm trying to use an Extension Installer to install some extra files for my application. I've searched the forum for problems with the Extension Installer and I've seen a few posts, even the same problem I'm having. But none of the suggestions ha

  • Deploying Jabber on PC and MAC for BE-6K

    Hi, i ask your help to clarify if i can deploy using BE6K jabber softclient o PC and MAC for a customer that doesn't want to synchronize its user DB with CUCM, or for example does not have one. I am asking because looking at the deploying guide for J

  • Synchronizing with a second computer

    Hi, I have just purchased a new computer and have found that my iPod won't synchronize with it, as it is still synched with the family computer. Is there any way of "un-synchronizing" my iPod with the family computer, so I could then synch with my ne