Alter sequence value
Hai all.,
im trying to import data from one database table(A) to other database table(B)
and almost all the fields in the two tables are same.
if i try to import the data from A to B.Im gettin problem with sequence
Can anybody help me on this....
Note :Table B has some values before importing values from A to B
and both the tables have sequences.
Thanks In Advance...
im trying to import data from one database table(A) to other database table(B)You are not being clear. Are you using the import utility to bring data from one insatnce of a table into another instance of the same table (i.e. t1 @a.world vs [email protected])? Or are you trying to run a SQL insert statement to bring data from one table into a different table within the same database instance?
The fixes are different in each case.
Cheers, APC
Blog : http://radiofreetooting.blogspot.com/
Similar Messages
-
ALTER SEQUENCE on a busy server results in unexpected very high values
Our sequence was at 782,393,232 or so, when I bumped it up by 30,000. Here's the commands I used:
alter sequence OUR_SEQ increment by 30000;
select OUR_SEQ.nextval from dual;
alter sequence OUR_SEQ increment by 1;
commit;
When I queried the sequence's nextval a few minutes later, it had jumped to over 8 billion !?! I quickly reset down to 783 million or so, and it behaved propertly after that. I've seen a couple of posts on the net that infer that resetting a sequence while it is being heavily used can cause "unpredictable results". Has anyone else experienced this or is there a known bug ?
I'm running :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit, RAC system.
PL/SQL Release 10.2.0.4.0 - Production
"CORE 10.2.0.4.0 Production"
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - ProductionJustin Cave wrote:
Sven,
I'm not sure that I understand what you're clarifying...
In a RAC cluster, a sequence with a cache has a separate cache in each node of the cluster. If the cache was set to 20 (the default), and the increment was set to 30,000, each node would cache 20 values each separated by 30,000. And the caches would be non-overlapping (i.e. node A would get the 20 values from 1 - 570,001, node B would get the 20 values from 600,001 - 1,170,001). I don't see that this is at odds with what I posted.
Obviously, the presence of a cache creates a bit of a wrinkle with when, exactly, you say that a sequence is incremented. The NEXT_VALUE in DBA_SEQUENCES is incremented by cache*interval when any node exhausts its cache. The NEXTVAL of a sequence for connections that are hitting a particular node will increase by interval each time some other session gets the NEXTVAL of a sequence. The NEXTVAL of a sequence for connections on a different node is unaffected by what is happening on the current node. Is that the clarification you're making? If so, I agree.
user11300030,
The discussion on sequence caching may provide some insight into why none of the rows are between 780 million and 1 billion. It's entirely possible that those values were cached on a node other than the node where the inserts were run. Had the caches not been flushed when you altered the sequence, inserts run on those other nodes might have used the values from that range.
JustinWe do have two nodes and the sequence cache size was 100, so what you suggested in your last paragraph makes sense.
Also, I just ran an AWR report and noted that "select our_seq.nextval from dual" was called 280K times (Hibernate is a hungry beast). -
Getting error while reset sequence value
i hve created two table. and a sequence for other table. i want to do that when i insert into a first table, entries of other table should be deleted and sequence value should reset to 1. For that i have executed the following sql code
but getting the error:
create or replace Trigger m_sale_ainsert_trig
after insert on m_sale_bill
for each row
begin
DELETE FROM M_TEMP;
<<COLUMN_SEQUENCES>>
BEGIN
Alter Sequence M_TEMP_SEQ Restart with 1;
END COLUMN_SEQUENCES;
end;
Alter Trigger m_sale_ainsert_trig enable;
Warning: execution completed with warning
Trigger m_sale_ainsert_trig Compiled.
Alter Trigger m_sale_ainsert_trig succeeded.
5/4 PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
pls rectify it!!!!! what are the mistakes in this code?
Edited by: JKMourya on Mar 21, 2013 10:55 AMJKMourya wrote:
i hve created two table. and a sequence for other table. i want to do that when i insert into a first table, entries of other table should be deleted and sequence value should reset to 1. For that i have executed the following sql code
but getting the error:
create or replace Trigger m_sale_ainsert_trig
after insert on m_sale_bill
for each row
begin
DELETE FROM M_TEMP;
<<COLUMN_SEQUENCES>>
BEGIN
Alter Sequence M_TEMP_SEQ Restart with 1;
END COLUMN_SEQUENCES;
end;
Alter Trigger m_sale_ainsert_trig enable;
Warning: execution completed with warning
Trigger m_sale_ainsert_trig Compiled.
Alter Trigger m_sale_ainsert_trig succeeded.
5/4 PLS-00103: Encountered the symbol "ALTER" when expecting one of the following:
( begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
pls rectify it!!!!! what are the mistakes in this code?
Edited by: JKMourya on Mar 21, 2013 10:55 AMDDL inside PL/SQL is NOT allowed
you must (ab)use EXECUTE IMMEDIATE -
Changing the nextval of a sequence using alter sequence
Hello experts,
Is there any option to modify the nextval of a sequence using alter sequece command?
Thanks in advance.
J.PrakashHi
I do not think so there is any direct way to modify the nextval of a sequence, only workaround i can think of is firing two DDL
alter sequence dumm increment by 10
alter sequence dumm increment by 1Where first alter command would increment the nextval to (currentvalue + incement value) and second alter command would reset the increment to its original value in my case 1
Regards -
Golden Gate Sequence Value replication?
Hi all,
I have searched the web, and read the Golden Gate documentation but I've found mixed answers.
I'm just trying to ascertain for certain whether it's possible to automatically replicate sequence values in a bi-directional configuration. Both databases will be identical and both will be 11gR2 with the latest version of GG.
If it is not possible to automatically increment sequences in a bi-directional configuration, what are the best practices for maintaing them?
One option is the alternate sequences on each database, one with even values (for example) and one with odd values, but this requires deployment of new sequences on both databases, something we were hoping would be taken care of by the replication. (yes the sequence creation can be taken care of but the value is not incremented on the target database).
another way that we thought of off the top of our heads is to have an on insert trigger (we only use sequences to generate surrogate keys) which will select nextval from the target database via a db link, but this seems somewhat cumbersome.
What is best practice?Use sequence parameter... here is from Golden gate document:
SEQUENCE
Valid for Extract
Use the SEQUENCE parameter to extract sequence values from the transaction log forpropagation to a GoldenGate trail and delivery to another database. Currently, GoldenGate supports sequences for the Oracle database.
NOTE DDL support for sequences (CREATE, ALTER, DROP, RENAME) is compatible with, but not required for, replicating sequence values. To replicate just sequence values, you do not need to install the GoldenGate DDL support environment. You can just use the SEQUENCE parameter.
GoldenGate ensures that the values of a target sequence are:
● higher than the source values if the increment interval is positive
● lower than the source values if the increment interval is negative
Depending on the increment direction, Replicat applies one of the following formulas as a test when it performs an insert:
source_highwater_value + (source_cache_size * source_increment_size * source_RAC_nodes) <= target_highwater_value
Or...
source_highwater_value + (source_cache_size * source_increment_size * source_RAC_nodes) >= target_highwater_value
If the formula evaluates to FALSE, the target sequence is updated to be higher than the source value (if sequences are incremented) or lower than the source value (if sequences are decremented). The target must always be ahead of, or equal to, the expression in the parentheses in the formula. For example, if the source highwater value is 40, and CACHE is 20, and the source INCREMENTBY value is 1, and there are two source RAC nodes, the target highwater value should be at least 80:
40 + (20*1*2) <80
If the target highwater value is less than 80, GoldenGate updates the sequence to increase the highwater value, so that the target remains ahead of the source. To get the current highwater value, perform this query:
SELECT last_number FROM all_sequences WHERE sequence_owner=upper('SEQUENCEOWNER') AND sequence_name=upper('SEQUENCENAME'); -
Patch 3480000 install - Failed worker ALTER SEQUENCE
Dear All,
I am in the process of installing Patch 3480000 (11.5.10.2) and during the running workers 1,3 fail and this the part of worker 1 log :
The sequence IEM_ACCOUNT_TAG_KEYS_S1 in the database is defined as:
MINVALUE = 1 MAXVALUE = 2000000000 INCREMENT BY = 1
CYCLE = NO ORDER = NO CACHE = 20
which should be defined as:
MINVALUE = 10000 MAXVALUE = 2000000000 INCREMENT BY = 1
CYCLE = NO ORDER = NO CACHE = 20
Alter the sequence with :
Start time for statement below is: Fri Apr 29 2011 14:51:14
ALTER SEQUENCE IEM.IEM_ACCOUNT_TAG_KEYS_S1 MINVALUE 10000
AD Worker error:
The following ORACLE error:
ORA-04007: MINVALUE cannot be made to exceed the current value
occurred while executing the SQL statement:
ALTER SEQUENCE IEM.IEM_ACCOUNT_TAG_KEYS_S1 MINVALUE 10000
AD Worker error:
Unable to compare or correct sequences
* because of the error above*
Thanks&BR
TarekHussein
_ this I did:_*
**SQL> select IEM.IEM_TAG_KEYS_S1 .nextval from dual;**
**NEXTVAL**
**10001**
**SQL> alter sequence IEM.IEM_TAG_KEYS_S1 increment by 1000;**
**Sequence altered.**
**SQL>**
and this part from screen out put:_+
**ATTENTION: All workers either have failed or are waiting:**
**FAILED: file iemsvrp.odf on worker 1.**
**ATTENTION: Please fix the above failed worker(s) so the manager can continue.**
**Fixed: file iemsvrp.odf on worker 1 for product iem username IEM.**
**Restarted: file iemsvrp.odf on worker 1 for product iem username IEM.**
**FAILED: file iemsvrp.odf on worker 1 for product iem username IEM.**
**ATTENTION: All workers either have failed or are waiting:**
**FAILED: file iemsvrp.odf on worker 1.**
**ATTENTION: Please fix the above failed worker(s) so the manager can continue.**
and this from log file:+_
**The sequence IEM_ENCRYPTED_TAG_DTLS_S1 in the database is defined as:**
**MINVALUE = 1 MAXVALUE = 2000000000 INCREMENT BY = 1**
**CYCLE = NO ORDER = NO CACHE = 20**
**which should be defined as:**
**MINVALUE = 10000 MAXVALUE = 2000000000 INCREMENT BY = 1**
**CYCLE = NO ORDER = NO CACHE = 20**
**Alter the sequence with :**
**Start time for statement below is: Fri Apr 29 2011 17:10:15**
**ALTER SEQUENCE IEM.IEM_ENCRYPTED_TAG_DTLS_S1 MINVALUE 10000**
**AD Worker error:**
**The following ORACLE error:**
**ORA-04007: MINVALUE cannot be made to exceed the current value**
**occurred while executing the SQL statement:**
**ALTER SEQUENCE IEM.IEM_ENCRYPTED_TAG_DTLS_S1 MINVALUE 10000**
**AD Worker error:**
**Unable to compare or correct sequences**
** because of the error above**
Thanks hussein
please advise
Tarek
Edited by: user11973469 on Apr 29, 2011 5:17 PM
Edited by: user11973469 on Apr 29, 2011 5:18 PM -
hello gurus,
i have a sequence like this
CREATE SEQUENCE seq_idea
START WITH 6
MAXVALUE 9999999999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;i want to change the start with as 100 ,can any one tell me how to alter sequence
regards,
friendmost wanted!!!! wrote:
hello gurus,
i have a sequence like this
CREATE SEQUENCE seq_idea
START WITH 6
MAXVALUE 9999999999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;i want to change the start with as 100 ,can any one tell me how to alter sequence
regards,
friendDrop it and recreate it with the appropriate start with value. -
hi friends needed help immediately can we use the statement to alter a sequence value
ssss is a variable
EXECUTE IMMEDIATE 'ALTER SEQUENCE abcd_SEQ MAXVALUE '||ssss||'';
very urgentlyEXECUTE IMMEDIATE 'ALTER SEQUENCE abcd_SEQ MAXVALUE
'||ssss||'';Why did you put quote after variable?
It'll work if you create statement like:
EXECUTE IMMEDIATE 'ALTER SEQUENCE abcd_SEQ MAXVALUE ' || ssss; -
How to alter sequence next number
Can we alter sequence next number. I want to start it from minval.
To restart the sequence at a different number, you must drop and re-create it.
If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.
Oracle Database performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number. -
Altering sequence to start from 0
I have a sequence for auto-incrementing a value. Each day I want that sequence to restart, meaning to start from 0 again. So I did a job in which I tried deleting the sequence and re-creating it. Someone told me that instead of deleting-recreating a sequence I can use alter sequence to make the sequence start from 0 again but as I read, the alter sequence cannot do that. as I read:
ALTER SEQUENCE [schema.]sequence
[INCREMENT BY integer]
[MAXVALUE integer | NOMAXVALUE]
[MINVALUE integer | NOMINVALUE]
[CYCLE | NOCYCLE]
[CACHE integer | NOCACHE]
[ORDER | NOORDER]
there is no option to change start from.
Does anyone knows if that can be actually done?
As I figured it's not possible to alter the sequence to start from 0 again I can do a job in oracle to delete and create the sequence again. The thing it it's not working. If I do a job and say:
execute immediate 'drop sequence name_seq'; and execute it, it works, it deletes the squence but if I further write:
execute immediate 'create sequence name_seq ' ||
'start with 1 ' ||
'increment by 1 ' ||
'nomaxvalue ';
it doesn't do it anymore. I get no errors but the sequence is not created. can anyone give me a hand here? 10x a lot in advancethere is no option to change start from.
Does anyone knows if that can be actually done?ensure that noone other works with sequence and:
alter sequence seq increment by -(current_value);
select seq.nextval from dual;
alter sequence seq increment by 1;
execute immediate 'drop sequence name_seq'; and
execute it, it works, it deletes the squence but if I
further write:
execute immediate 'create sequence name_seq ' ||
'start with 1 ' ||
'increment by 1 ' ||
'nomaxvalue '; Looks OK, can you do that from jus SQL prompt?
>
it doesn't do it anymore. So it did a while ago? What has been changed?
Gints Plivna
http://www.gplivna.eu -
Unable to save Sequence value to Database
Hi,
I am trying to pupulate a sequence value so that I can use it as primary key along with the combination of other columns later. My problem is that the sequence value is getting populated on the page with the right value, But is not getting saved to the database. The Column is there in the VO. The column is blank on the table. When I print it(System.out.println("Seq=" + xSeq.getText(pageContext));), the value is null. Can anyone please advice what I am doing wrong OR if I am missing anything here.
Thanks
Ali
My CO file:
============
package lac.oracle.apps.lac.jobperf.server.webui;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.webui.OADialogPage;
import oracle.apps.fnd.framework.webui.TransactionUnitHelper;
import oracle.jbo.domain.Number;
import oracle.apps.fnd.common.MessageToken;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.layout.OAMessageComponentLayoutBean;
import oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;
import com.sun.java.util.collections.HashMap;
import oracle.bali.share.util.IntegerUtils;
import oracle.apps.fnd.framework.server.OADBTransaction;
* Controller for ...
public class ReviewCreateCO extends OAControllerImpl
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
OAApplicationModule am; // dave
OADBTransaction oadbxn; // dave
oracle.jbo.domain.Number Seq;
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
// Always call this first
super.processRequest(pageContext, webBean);
am = pageContext.getApplicationModule(webBean); // dave
oadbxn = am.getOADBTransaction(); // dave
OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
OAMessageComponentLayoutBean mainRn = (OAMessageComponentLayoutBean)pageLayout.findIndexedChildRecursive("MainRN");
// If isBackNavigationFired = false, we are here after a valid navigation
// (the user selected the Create Review button) and we should proceed
// normally and initialize a new Review.
if (!pageContext.isBackNavigationFired(false))
// We indicate that we are starting the create transaction(this
// is used to ensure correct Back button behavior).
TransactionUnitHelper.startTransactionUnit(pageContext,"jobperfCreateTxn");
// This test ensures that we don't try to create a new review if we
// had a JVM failover, or if a recycled application module is activated
// after passivation. If this things happen, BC4J will be able to find
// the row you created so the user can resume work.
if (!pageContext.isFormSubmission())
OAApplicationModule am = pageContext.getApplicationModule(webBean);
// String Seq = (String)oadbxn.getValue("Seq");
oracle.jbo.domain.Number Seq = oadbxn.getSequenceValue("lac.LAC_CM_PERF_REVIEW_SEQ");
OAMessageStyledTextBean xSeq = (OAMessageStyledTextBean)mainRn.findIndexedChildRecursive("Seq");
xSeq.setText(Seq.toString());
am.invokeMethod("createReview",null);
// Initialize the ApplicationpropertiesVO for PPR.
// am.invokeMethod("init");
else
if (!TransactionUnitHelper.isTransactionUnitInProgress(pageContext,"jobperfCreateTxn", true))
// We got here through some use of the browser "Back" button, so we
// want to display a stale data error and disallow access to the page.
// if this were a real application, we would propably display a more
// context-specific message telling the user she can't use the browser
//"Back" button and the "Create" page. Instead, we wanted to illustrate
// how to display the Applications standard NAVIGATION ERROR message.
OADialogPage dialogPage = new OADialogPage(NAVIGATION_ERROR);
pageContext.redirectToDialogPage(dialogPage);
} // end processRequest()
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{ //super.processFormRequest(pageContext, webBean);
// Always call this first.
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
OAMessageComponentLayoutBean mainRn = (OAMessageComponentLayoutBean)pageLayout.findIndexedChildRecursive("MainRN");
// Pressing the "Apply" button means the transaction should be validated
// and committed.
// OAPageLayoutBean pageLayout = pageContext.getPageLayoutBean();
// String Seq = SeqText.getText(pageContext);
oadbxn.putValue("Seq", Seq);
am = pageContext.getApplicationModule(webBean);
oadbxn = am.getOADBTransaction();
if (pageContext.getParameter("Apply") != null)
// Generally in the tutorial application and the labs, we've illustrated
// all BC4J interaction on the server (except for the AMs, of course). Here,
// we're dealing with the VO directly so the comments about the reasons
// why we're obtaining values from the VO and not the request make sense
// in context.
OAViewObject vo = (OAViewObject)am.findViewObject("jobperfVO1");
// Note that we have to get this value from the VO because the EO will
// assemble it during its validation cycle.
// For performance reasons, we should generally be calling getEmployeeName()
// on the EmployeeFullVORowImpl object, but we don't want to do this
// on the client so we're illustrating the interface-appropriate call. If
// we implemented this code in the AM where it belongs, we would use the
// other approach.
String employeeName = (String)vo.getCurrentRow().getAttribute("FullName");
// We need to get a String so we can pass it to the MessageToken array below. Note
// that we are getting this value from the VO (we could also get it from.
// the Bean as shown in the Drilldwon to Details lab) because the item style is messageStyledText,
// so the value isn't put on the request like a messaqeTextInput value is.
String employeeNumber = (String)vo.getCurrentRow().getAttribute("EmployeeNumber");
//ma String employeeNum = String.valueOf(employeeNumber.intValue());
//ma Number employeeNumber = (Number)vo.getCurrentRow().getAttribute("EmployeeNumber");
//ma String employeeNum = String.valueOf(employeeNumber.intValue());
// Simply telling the transaction to commit will cause all the Entity Object validation
// to fire.
// Note: there's no reason for a developer to perform a rollback. This is handled by
// the framework if errors are encountered.
OAMessageStyledTextBean xSeq = (OAMessageStyledTextBean)mainRn.findIndexedChildRecursive("Seq");
System.out.println("Seq=" + xSeq.getText(pageContext));
am.invokeMethod("apply");
// Indicate that the Create transaction is complete.
TransactionUnitHelper.endTransactionUnit(pageContext, "jobperfCreateTxn");
// Assuming the "commit" succeeds, navigate back to the "Search" page with
// the user's search criteria intact and display a "Confirmation" message
// at the top of the page.
MessageToken[] tokens = { new MessageToken("EMP_NAME", employeeName),
new MessageToken("EMP_NUMBER", employeeNumber) };
OAException confirmMessage = new OAException("PER", "LAC_FWK_TBX_T_EMP_CREATE_CONF", tokens,
OAException.CONFIRMATION, null);
// Per the UI guidelines, we want to add the confirmation message at the
// top of the search/results page and we want the old search criteria and
// results to display.
pageContext.putDialogMessage(confirmMessage);
HashMap params = new HashMap(1);
// Replace the current employeeNumber request parameter value with "X"
params.put("employeeNumber", "employeeNumber");
// IntegerUtils is a handy utility
params.put("employeeNumber",IntegerUtils.getInteger(5));
pageContext.forwardImmediately(
"OA.jsp?page=/lac/oracle/apps/lac/jobperf/webui/jobperfPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
params, //null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_YES);
else if (pageContext.getParameter("Cancel") != null)
am.invokeMethod("rollbackReview");
// Indicate that the Create transaction is complete.
TransactionUnitHelper.endTransactionUnit(pageContext, "jobperfCreateTxn");
pageContext.forwardImmediately("OA.jsp?page=/lac/oracle/apps/lac/jobperf/webui/jobperfPG",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
} // end processFormRequest()
}Hi Tapash,
Thanks for all of you guys(Tapash/Sumit/user550094) help. The sequence is working and also populating the values in the table when I do not have any validation checks imposed on it.
If I add any validations as mentioned in the exercise for create page where it checks if the sequence can be updated while null and so on... and throws appropriate exception. I get error. That is the code that I mentioned above.
Here is the validation code for EOImpl:
As mentioned below in order for the code to compile and work I had to comment the "throw new OAAttrvalException". If I uncomment the
"throw new OAAttrvalException" part, it gives me the following error while compiling:
"Error(796,13): method getPrimarykey not found in class lac.oracle.apps.lac.jobperf.schema.server.jobperfEOImpl"
public void setSeq(Number value)
// Because of the declaritive validation that you specified for this attribute,
// BC4J validates that this can be updated only on a new line, and that this,
// mandatory attribute cannot be null. This code adds the additional check
// of only allowing an update if the value is null to prevent changes while
// the object is in memory.
if (getSeq() != null)
/* throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), //getSeq(), // EO name
getPrimarykey(), // EO PK
"Seq", // Attribute Name
value, // Attribute value
"AK", // Message product short name
"FWK_TBX_T_EMP_ID_NO_UPDATE"); // Message name */
if (value != null)
// Seq ID must be unique. To verify this, check both the
// entity cache and the database. In this case, it's appropriate
// to use findByPrimaryKey() because you're unlikely to get a match, and
// and are therefore unlikely to pull a bunch of large objects into memory.
// Note that findByPrimaryKey() is guaranteed to check all employees.
// First it checks the entity cache, then it checks the database.
OADBTransaction transaction = getOADBTransaction();
Object[] employeeKey = {value};
EntityDefImpl empDefinition = jobperfEOImpl.getDefinitionObject();
jobperfEOImpl Seq =
(jobperfEOImpl) empDefinition.findByPrimaryKey(transaction, new Key(employeeKey));
if (Seq != null)
/* throw new OAAttrValException(OAException.TYP_ENTITY_OBJECT,
getEntityDef().getFullName(), // .getSeq(), // EO name
getPrimaryKey(), // EO PK
"Seq", // Attribute Name
value, // Attribute value
"AK", // Message product short name
"FWK_TBX_T_EMP_ID_UNIQUE"); // Message name */
// Note that this is the point at which the value is actually set on the EO cache
// (during the scope of setAttributeInternal processing). If you don't make this
// call after you perform your validation, your value will not be set correctly.
// Also, any declarative validation that you define for this attribute is executed
// within this method.
setAttributeInternal(SEQ, value);
} // end SetSeq
I am sorry if I have confused you. I really did not mean to do it.
Thanks,
Ali -
Using a single sequence value over multiple scripts (in a variable?)
Hi all...
I'm writing a number of scripts that insert rows into tables.
To better explain my point, I'll paste a simple breakdown of the scripts here as that will be easier to understand...
Script 1:
INSERT INTO WORKGROUP_DEPARTMENTS(ID, DEPT_NAME, DEPT_TYPE)
VALUES (SEQ_WGDPT.NEXTVAL, 'Staff', 3);
Script 2:
INSERT INTO WORKGROUP_SECTIONS(ID, SECT_NAME, WGDPT_ID)
VALUES (SEQ_WGSEC.NEXTVAL, 'Staff 1',
(SELECT ID FROM WORKGROUP_DEPARTMENTS
WHERE DEPT_NAME = 'Staff'
AND DEPT_TYPE = '3')
Script 3:
INSERT INTO WORKGROUPS(NAME, UNIT_TYPE, WGSEC_ID)
VALUES ('Staff Room', 3,
(SELECT ID FROM WORKGROUP_SECTIONS
WHERE SECT_NAME = 'Staff 1')
As you can see, in scripts 1 and 2 a new value is produced from a sequence (SEQ_WGDPT & SEQ_WGSEC respectively). Then, in scripts 2 & 3 (respectively) these values are inserted into another table.
What I'm trying to figure out is: can I do the same thing here without having to include the horrible SELECT statements in scripts 2 & 3 in order to find the ID, which was produced by the sequence in the previous script?
Unfortunately they do have to be separate scripts, and as such I can't call Sequence.CurrVal from a different script as other users may have used the sequence since it was used initially in the previous script. I could call it from the original calling script, and save it intop a variable, but I have no idea how to - even if it is the right idea!
I tried to insert the sequence value into a variable a la PL/SQL so that I could call this variable from the next script, but failed miserably as I'm rubbish!
Any help would be great. Thanks.You can use PL/SQL, for example:
SQL> desc t
Name Null? Type
ID NUMBER
NAME VARCHAR2(10)
SQL> desc t1
Name Null? Type
ID NUMBER
NAME VARCHAR2(10)
ID1 NUMBER
SQL> desc t2
Name Null? Type
ID NUMBER
NAME VARCHAR2(10)
ID2 NUMBER
SQL> create sequence seq_1;
Sequence created.
SQL> declare
2 prev_id number;
3 begin
4 insert into t values(seq_1.nextval,'A')
5 returning id into prev_id;
6 insert into t1 values(seq_1.nextval,'B',prev_id)
7 returning id into prev_id;
8 insert into t2 values(seq_1.nextval,'C',prev_id);
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> select * from t;
ID NAME
1 A
SQL> select * from t1;
ID NAME ID1
2 B 1
SQL> select * from t2;
ID NAME ID2
3 C 2
Rgds -
How to get sequence value on click of button in OAF Page
Hi all,
I have a requirement to get a field called Bankrefernece number populated with sequence value on click of apply button ; i mean inserting new record in database for new transaction.
Sequence Value should be something like this:
Example
No Transfer Date Bank Reference Number
(DDMMYY_999)
1 24-Oct-2010 241010_001
2 24-Oct-2010 241010_002
3 25-Oct-2010 251010_001
means every day sequence should start with the date initials.
Kindly give your valuable input.
Thanks
Sims
Edited by: sims on Jan 4, 2011 11:22 PMsims wrote:
Hi Anil,
Its a standard page & i want it on click of apply button but my question is when i click apply button it navigates to other page..is it possible in such scenario to extend the controller.
Thnx for ur suggestion
SimsThat is not an issue, you can extend the controller of that page and get the value of sequence and set it to the VO attribute.
Thanks
--Anil
http://oracleanil.blogspot.com -
Need to populate sequence value in a field after insert in oaf page
Hi All,
I have a custom OAF insert page in that i need to populate a sequence value to a field once the data inserted successfully to the table.
so for that i followed the below approach.
1>Created a sequence in database.
2>In the EOImpl java file in the setter method for the respective field have written below code.
public void setContainid(Number value) {
if (value == null) {
OADBTransaction t = getOADBTransaction();
value = t.getSequenceValue("XXXXX_CONTAIN_SEQ");
setAttributeInternal(CONTAINID,value);
But still i am not able to populate the sequence value for the field in my oaf page,please help me out on thsi.
ThanksHi,
Write this logic in create method of EOImpl:
public void create(AttributeList attributeList)
super.create(attributeList);
OADBTransaction transaction = getOADBTransaction();
Number contID = transaction.getSequenceValue("XXXXX_CONTAIN_SEQ");
setContainId(contID);
--Sushant -
How to get sequence value?
hi,
i'm trying to store sequence's value into a variable... smth like this:
create or replace function my_funct() as integer
is
begin
return my_sequence.currval;
end;
and "return my_sequence.currvalue" doesn't seem to work...
also i'would like to store that value into a variable, like:
is
i integer;
begin
i := my_sequence.currval;
end;
this also doesn't seem to work
regardsHi,
You will using this method to store sequence value to variable
declare
i number;
begin
select sq.currval into i from dual;
dbms_output.put_line(i);
end;
Anbudan,
Radha.
Maybe you are looking for
-
Trying to write an if statement around the return value of a CANCEL_OPTION
I am writing a program that takes an input String using JOptionPane. The String can be made of only letters of the A-Z alphabet and the space character. I have written an error-checking loop that will pop another input box up along with an error mess
-
Combine several XML files with same structure
Hello, I have several XML files with the same structure and I want to combine them and create a new XML file to be bale to compare that information easily. It does not look very difficult but as I am very new in this I am not bale to get it The struc
-
Compiling a package without disturbing the load process
Hi, I need to compile a package, with the changes, in the database without stopping the load process that is using this package. Please let me know if any one has any ideas. Thanks
-
Right now, I have no wireless security. If I were to have one, which setup/system would be the best of the choices offered in Airport utility? I noticed there are a number of networks(due to different names) in my area. How can I make sure, no one el
-
Smart shapes and caption styles
The default Halo Blue caption style has a pleasing 3-dimentional look with shading, but the pointer on it is not resizable. The smart shapes give the ability to resize the pointer, but they look very flat. Is there a way to add the shading of Halo Bl