Update a primary key of type char data
HelloNot a guy to oracle technology. but am forced to work on a query that is a basic requirement.
I have a table that has a composite primary key values (6 columns).
Of these, I've updated 1 specific column, which is a char data type.
I tested after writing my logic as a query, threw it [the Unique constraint violated schema.tablename];
So I gave it a query simple base to test it yet, still get the same error.
Query such as:
Update table_name set Column1 = "100000" where column2 = 'BOMBAY '; (Column1 is the primary key of type char)
Even if it did not work.
Now a doubt arises, a column is a primary key of type Char can be modified? or is it not possible at all to do?
Note: I made sure only am not updated with a duplicate value;
Thank you.
Published by: 966353 on October 18, 2012 12:01
While you never need to update a primary key (regardless of the type of data), it is possible to do. If you get an error ORA-00001 indicating that a unique constraint has been violated and the unique constraint that is violated is associated with the primary key of the table (I'm guessing that this is the case according to your description of the error), implying strongly that the update would result in duplicate rows. Your UPDATE statement updates more than 1 row? If so, how do you determine when the update is complete there will be no duplicate lines?
Justin
Tags: Database
Similar Questions
-
best method to update the primary key
Can someone tell me the best possible method to update the primary key so that the foreign key is also updated.
Please explain with example940340 wrote:
Can someone tell me the best possible method to update the primary key so that the foreign key is also updated.
Please explain with exampleYou're after a mechanism that lets you update the primary key sometimes on some lines, or did you just impossible, which means that you must update all the data because of some kind of change in the structural definition?
If all you need is a rational method to change keys sometimes (and this isn't quite mortal sin that other posters have been suggesting) then recreate your foreign key as a constraint can be delayed may help.
Oracle allows no you cascading updates automatically for primary keys, but if the foreign key is carried forward you can proceed as follows:
set constraint {foreign key constraint name} deferred; update parent primary key; update child foreign key; set constraint {foreign key constraint name} immediate;
Concerning
Jonathan Lewis -
How can I update the primary key column
Hello
Can you suggest me best workaround/algorithm for task below:
(Oracle 10g, Solaris OS.)
Location:
Table a primary key column P 'Code', tables children F1, F2,..., reference to F15 "Code_P' foreign key column"P.Code"column, and we do not know which of the child tables data available for a particular value"P.Code.
Task:
Change the value "P.Code" from 100 to 200. So that the result would be that record P [Code = 100] should be updated:
And child tables 'Code_P' column should be updated as:update P set Code = 200 where Code = 100;
The best solution would be that you can easily repeat this task.update F1, F2, .., F15 set P_code = 200 where P_code = 100;
Edited by: CharlesRoos the 28.12.2010 12:10Will there be FK constraints in place?
If so, you may need to modify them so that their application may be temporarily deferred.The gameplan would be something like this:
-Making of CF can be deferred, immediate departure.
-Alter FK set delay.
-Update of Parent table.
-Update of the children tables.
-Immediate constraints set
s ' engage; -
Primary key several columns with Date - parameter problem
All,
I'm having a problem where I can not find the answer to. I looked upstairs and down nothing helps. Help, please.
The issue is that I have a table that has a primary key of several columns and a column is a date, and the other is a string. I have a simple search and I want a picture update of the results table that users can click on and go to another page to update this record. The question is when I launch an appeal based on the updated image, I also want to define the settings based on the record that I have selected. So I put the string parameter and that works very well. The problem is with the date. When I put the setting date this market but he chops off the coast of the timestamp. Later when I try to access this setting "("dateParameter") pageContext.getParameter"; that it will bring a date as December 15, 2008 but I need the whole date and time stamp (i.e., December 15, 2008 10:20:33) to properly identify the record.
Help, please!
Thank you
Colby JHello
because each parameter go into url as a format string, so you will never get the full date with timestamp setting, the solution would be to
1.) set a fire on the photo update action, give his name to the event as "update."
(2.) by clicking Update photograph fires this event.
(3.) processFormrequest in the controller method
OAApplicationModule am = pageContext.getApplicationModule (webBean);
If ("update".equals (pageContext.getParameter ("event")))
{
This will give you the select line when you click UpdateString rowReference = pageContext.getParameter (OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
Line VORowImpl = (EmployeeSummaryVORowImpl) am.findRowByRef (rowReference);
Timestamp sdateVal = (String) row.getAttribute ("Date value");This will transfer the values to the next page
pageContext.putTransactionTransientValue ("transferdvalue", sdateVal);}
and in the next page, you can get the value as follows
timestamp getDateVal = pageContext.getTransactionTransientValue ("transferdvalue" l);
hope this will solve your problem, please let me know if you face any problem
thanx
Pratap -
Creating primary key based on the Date
Hi all
I am trying to create a unique ID for each record, based on the date that the record is created. Example, if the folder is created today, I want to the key is 20101130XX where XX is a sequential list of numbers e.g. 01, 02, 03 etc... in the case where more than one person creates a record today.
If 3 people created record yesterday their unique ID would be
2010112900
2010112901
2010112902
and then comes the midnight and someone creates a new record, that it would be
2010113000
This is intended to give each record with a unique ID that will be used to reference the ticket.
We are already using the date format, but currently users have to manually enter the id and who can create errors such as 2011112900 when it should have been 2010112900 then instead of 2010 they put 2011
I'm not sure how to create a trigger to generate this type of unique identification number and would appreciate any help
Thanks in advance
WallyNever said it was perfect, but then again, it is a rather sticky issue... Reset sequence work would be scheduled to run @ some point... You entered in tables past 24/7? I would say that system could be locked for those 5 minutes sequence is updated, or the table is locked to allow no access while the process is...
To be honest, that is the question in the design of a key value that is dependent on outside data, as apposed to a surrogate key, which is generated System... Again, you could have at ONCE and have the surrogate for a key key REAL primary and date + sequence as a secondary key for the use of basic unit of carbon...
Thank you
Tony Miller
Webster, TXIf vegetable oil is made from vegetables, then what is baby oil?
-
In bulk API REST v2 activity Data Export 'primary key '?
After reading the documentation, I expected that ActivityId would be the primary key when you export activity data - for example, it would not be in double ActivityID in the data returned by the export items . However, I see the exported data where I have several references to activity that are identical, except that they have different CampgainIds
- Is ActivityId, CampaignId the primary key for the activity data? If not, what is?
- When the activity with the same activity ID data has different areas (excluding CampaignId)?
Thank you!
It is a known issue that we're working to correct.
-
Create the primary key on the target
Y at - it no IKM which would create the primary key on target after having read the instructions for the source?
Thank you
Dinesh.Hi Dinesh,
You can customize a KM to create a primary key on the target
The target table will be created with the mention of the primary key constraint in the data target store.Steps: -.
Customiuse creating target step of the table and I create $ step table.
for example: -.
original train target table KM walk (IKM Oracle Simple incremental update): -.
create table< %="snpRef.getTable" ("l",="" "a",="" "targ_name")="" %="">
(
<%=snpRef.getTargetColList("", "[COL_NAME]\t[DEST_CRE_DT] NULL", ",\n\t", "")%>
)custom STAGE: -.
create table< %="snpRef.getTable" ("l",="" "a",="" "targ_name")="" %="">
(
<%=snpRef.getTargetColList("", "[COL_NAME]\t[DEST_CRE_DT] NULL", ",\n\t", "")%>CONSTRAINT constraint_name PRIMARY KEY (< %="snpRef.getColList" ("",="" "[column]",="" ",",="" "",="" "pk")="" %="">)
)Note:- The code above described here is just a sample of reference. I did not test the syntax.
Kind regards
Its -
Adding primary keys with javascript.
I have a database that has no metadata.
We have the primary key definitions in an external system.
The primary key information are easy to get.
I want to update the relational model (and display) with the primary key information.
Is it possible to update the primary key of infromation in the model of the relationship of Javascript?
Hello
You can try to settle for your use:
// get table name tname = ...; //get pk name pkname = ....; table = model.getTableSet().getByName(tname); if(table !=n ull){ index = table.createIndex(); index.setName(pkname); index.setPK(true); // get column name - should iterate in case of multi column PK cname = ...; column = table.getElementByName(cname); if(column != null){ index.add(column); } table.setDirty(true); }
Philippe
-
Primary key on the attributes of data type
Production data Modeler 3.0 is really nice! Kudos to the development team.
Now for a question. Any idea when the Data Modeler will support (generate after modeling) the following SQL statements?
CREATE or REPLACE TYPE x_flags_t
AS AN OBJECT
(
ID NUMBER,
has_note NUMBER,
has_image NUMBER,
created_on DATE,
created_by VARCHAR2 (30 CHAR),
modified_on DATE,
Modified_By VARCHAR2 (30 CHAR),
FINAL
X_flags_t FUNCTION CONSTRUCTOR
(
GITES x_flags_t IN OUT NOCOPY
)
RETURN SELF AS RESULT
,
FUNCTION MEMBER update_row
(
X_flags_t COTTAGES
)
RETURN x_flags_t,
FUNCTION MEMBER update_note_flag
(
X_flags_t COTTAGES
p_note_flag in NUMBERS
)
RETURN x_flags_t
) NOT FINAL
;
/
CREATE TABLE x_flags
(
indicators x_flags_t
)
/
ALTER TABLE x_flags
ADD (CONSTRAINT x_flags_pk PRIMARY KEY * (flags.id)) *.
/Hi Scott,.
Thanks for your comments.
I logged an enhancement request to enable a primary key for a Table containing columns of structured Type to refer to attributes of structured Type.David
-
Update a table with primary key
Hello
I have a table called Temp
CREATE TABLE TEMP ( A VARCHAR2 (50 CHAR), B VARCHAR2 (50 CHAR), C VARCHAR2 (50 CHAR), D VARCHAR2 (18 CHAR), E DATE, F NUMBER, G VARCHAR2 (18 CHAR), H FLOAT );
The primary key is the PRIMARY KEY: (A, B, C, D, E, F, G).
I HAVE THE TEMPORARY TABLE 48052365 COUNTY,
HOWEVER I HAVE A REQUIREMENT TO UPDATE WHERE E (COLUMN) IS WEDNESDAY, THE SAME DAY IN MONDAY (I.E., C - 2 TO EXISTING DATE)
Approach;
I CREATED the TABLE TEMP_WED_TO_MONDAY AND SELECTED ALL THE RECORDINGS ELIGIBLE IN CE AND TABLE AND INDEX UNIQUE CREATED on this SUBJECT. TO UPDATE, I WROTE UNDER ANONYMOUS BLOCK.
Number of Tables: TEMP_WED_TO_MONDAY is 46,921,912 and count of total of the table is 48052365
Anonymous block:
DECLARE CURSOR UPDATE_TEMP_DATE IS SELECT A, B, C, D, E, F, G, E - 2 NEW_E FROM TEMP_WED_TO_MOONDAY; TYPE UPDATE_TEMP_DATE_REC IS RECORD ( A VARCHAR2 (50 CHAR), B VARCHAR2 (50 CHAR), C VARCHAR2 (50 CHAR), D VARCHAR2 (18 CHAR), E DATE, F NUMBER, G VARCHAR2 (50 CHAR), NEW_E DATE ); TYPE UPDATE_TEMP_DATE_TBL_TYPE IS TABLE OF UPDATE_TEMP_DATE_REC; UPDATE_TEMP_DATE_TBL UPDATE_TEMP_DATE_TBL_TYPE; BEGIN OPEN UPDATE_TEMP_DATE; LOOP FETCH UPDATE_TEMP_DATE BULK COLLECT INTO UPDATE_TEMP_DATE_TBL LIMIT 1000000; EXIT WHEN UPDATE_TEMP_DATE_TBL.COUNT = 0; FORALL I IN UPDATE_TEMP_DATE_TBL.FIRST .. UPDATE_TEMP_DATE_TBL.LAST UPDATE TEMP SET E = UPDATE_TEMP_DATE_TBL (I).NEW_E WHERE A = UPDATE_TEMP_DATE_TBL (I).A AND B = UPDATE_TEMP_DATE_TBL (I).B AND C = UPDATE_TEMP_DATE_TBL (I).C AND D = UPDATE_TEMP_DATE_TBL (I).D AND E = UPDATE_TEMP_DATE_TBL (I).E AND F = UPDATE_TEMP_DATE_TBL (I).F AND G = UPDATE_TEMP_DATE_TBL (I).G; COMMIT; END LOOP; CLOSE UPDATE_TEMP_DATE; END;
But for the past 6 hours, it only updated records 20,00,000(Twenty lakh) only. because this update in the table and is also part of the teaching primary key I think it takes time, but pointers to improve/acceleration of the update
Explain the plan:
update statement all_rows (Cost 4) 3 update hr.temp 2 table access by index rowid table hr.temp (Cost 4, Bytes : 64 ,Cardinality 1) 1 index range scan index hr.temp_wed_to_monday (Cost 3: Cardinality 1)
Thank you guys, I would be grateful if someone provides the solution for the scenario, rather than highlight the design. Please understand someone designed to best with whatever the limits it has during this period. (and this isn't me).
-
How to add the primary key for the table with the existing data?
The table is already busy data. There was no primary key before, so for each column, there are some duplicate values.
I want to add a new column, which should be of the integer data type and can automatically incremented, from 001. I tried with Oracle SQL Developer, but it says "ORA-01758: table must be empty to add mandatory (NOT NULL) column. How can I do? Thank you!Hello
Look for the [ALTER TABLE | http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_3001.htm#sthref4803] command to find out how to add a column (step (1)) and a (step (3)) constraint to an existing table.
For the step (2):
CREATE SEQUENCE employee_id_seq START WITH 1 ; UPDATE employee SET id = employee_id_seq.NEXTVAL;
When you create a sequence, START WITH 1 is the default value, so that the line is not really necessary above... I've included just to show how you could start with any number you have chosen.
-
# in the primary key data.
Hi all
I have an interactive relationship with form (update-able). I cannot retrieve the line for a few records by clicking on the link change.
I get the error message: "Unable to Fetch Row.
After investigation, I found one thing in common. My primary key data is impossible between the two for these records.
Can you guys clarify / confirm, if there is any work around to eliminate this # or I need to set the data for the records?
I use versioin Apex 3.1 and 9i db
Thank you
Daniel
Published by: Daniel on June 14, 2011 05:33
Published by: Daniel on June 14, 2011 05:36The # being the PK passed along the url, Yes, it is a problem... You SHOULDN'T have these characters in a PK if you use a substitute of PK. You can disinfect your PK before calling your routine and then add the # incriminated in your form called...
When you call the form of the report, you place the PK with # in there, so when you call the form, replace it # with a ^ and then in the form of the front header process, evaluate your pk happened in and replace the ^ by a # when it is required...
(I'd also look seriously to replace your generation of PK process)
Thank you
Tony Miller
Webster, TXOn the road of life... He has "windshield", and there are "bugs".
(splat!)
"Squeegees wanted."If you answer this question, please mark the thread as closed and give points where won...
-
SQL Data Model 3.0 EA1 trying to create the primary key on OT
Hello
I am trying to change a primary key of a table of the object that has been reversed (imported) from an Oracle 11.2.x RDBMS and get the error message "the incomplete Index Definition. It is displayed in the window "columns transfer Index." I get to the window"properties of primary key 'by pressing the 'Properties' button on the 'table properties'-> 'Primary key'. If I try to change the expression, and then press Ok or apply buttons I get the error. With this be corrected in the production version? That we will be able to create a model in the SQL Developer Data Modeler, which generates a SQL statement similar to the following:
ALTER TABLE x_flags
ADD (CONSTRAINT x_flags_pk PRIMARY KEY (flags.id))
?
Thank you
Scott KHi Scott,.
I am trying to change a primary key of a table of the object that has been reversed (imported) from an Oracle 11.2.x RDBMS and get the error message "the incomplete Index Definition"... With this be corrected in the production version?
Yes
That we will be able to create a model in the SQL Developer Data Modeler, which generates a SQL statement similar to the following:
ALTER TABLE x_flags
ADD (CONSTRAINT x_flags_pk PRIMARY KEY (flags.id))I guess that 'flags' is the type of the object column and 'id' attribute of this type. I logged for this bug, there are however not for 3.0.
Philippe
-
Updating related Records primary key and FK dependencies
(1) how can I found the name of all the tables that use my primary key as a foreign key? The primary key is of type varchar and used in many other paintings. Now PK records must be changed by the customer's request, so it will affect obviously all of my dependent tables.
(2) which corresponds to the PL/SQL script more efficient to perform this procedure?
All suggestions will be useful.
To test, I think I want a list of all tables in followed by a list of all affected records. This report must show registration PK & all records in dependence requiring an update. Is this reasonable?user10998542 wrote:
(1) how can I found the name of all the tables that use my primary key as a foreign key? The primary key is a varchar and used in many other paintings. Now PK records must be changed by the customer's request, so it will affect obviously all of my dependent tables.Discover the view USER_CONSTRAINTS. You could do something like this:
SELECT UC.OWNER , UC.TABLE_NAME , UC.R_OWNER , RUC.TABLE_NAME , UC.R_CONSTRAINT_NAME , RUC.CONSTRAINT_TYPE FROM USER_CONSTRAINTS UC , USER_CONSTRAINTS RUC WHERE UC.R_OWNER = RUC.OWNER AND UC.R_CONSTRAINT_NAME = RUC.CONSTRAINT_NAME AND UC.CONSTRAINT_TYPE = 'R'
If you need names of columns, you can use the USER_CONS_COLUMNS view also.
(2) which corresponds to the PL/SQL script more efficient to perform this procedure?
All suggestions will be useful.[Tom Kyte: package Cascade | http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteupdatecascade.html]
-
Hi all
This question is purely for updating my knowledge on the rules of comparison of data type for Oracle. I am referring
[Types of oracle data | http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#i1960]
and
[Datatype comparison rules | http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/sql_elements002.htm]
So I understand that Oracle uses the semantics of white comparison comparing the CHAR data type. I was testing a few queries on the CHAR data type.
But when I tried using the set operators to compare data from CHAR data type I got results that confused me.SQL> SELECT col_1, LENGTH (col_1), col_2, LENGTH (col_2) 2 FROM (SELECT CAST ('A' AS CHAR (2)) col_1, CAST ('A' AS CHAR (5)) col_2 3 FROM DUAL) 4 WHERE col_1 = col_2 5 / CO LENGTH(COL_1) COL_2 LENGTH(COL_2) -- ------------- ----- ------------- A 2 A 5 1 row selected. SQL>
For reviews of col_1 in the Table_A in Table_B col_2 I used two different methods:--DDL & DMLStatements For Sample Data CREATE TABLE TABLE_A ( col_1 CHAR(10) ); INSERT INTO TABLE_A(col_1) values ('A'); INSERT INTO TABLE_A(col_1) values ('B'); CREATE TABLE TABLE_B ( col_2 CHAR(15) ); INSERT INTO TABLE_B(col_2) values ('A'); INSERT INTO TABLE_B(col_2) values ('B');
Using the sub-sub-queries/join method:
I got the expected results. Now, I tried to achieve the same thing using a game operator (INTERSECT)SQL> SELECT a.col_1 2 FROM table_a a 3 WHERE a.col_1 IN (SELECT b.col_2 4 FROM table_b b) 5 / COL_1 ---------- B A 2 rows selected.
Using Set operator (INTERSECTION):
I had to add the TRIM function to achieve the expected results:SQL> SELECT a.col_1 2 FROM table_a a 3 INTERSECT 4 SELECT b.col_2 5 FROM table_b b 6 / no rows selected SQL>
Could someone please explain why I get different results for the above mentioned methods? I hope that I don't miss any details in the documentation.SQL> SELECT TRIM (a.col_1) 2 FROM table_a a 3 INTERSECT 4 SELECT TRIM (b.col_2) 5 FROM table_b b 6 / TRIM(A.COL_1) --------------- A B 2 rows selected.
Thanks in advanceThis might help:
http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/queries004.htm#i2054381
'If the select queries values of TANK with different lengths, then the returned value is VARCHAR2 with the length of the largest CHAR value."
and
'In queries using the set operators, Oracle does not make the implicit conversion between the data type groups.I guess that if the values are CHAR with lengths, then they will not be considered as being equal, even if it is the same value in both tables, bar the number of spaces at the end.
I don't rely on the parameters of comparison; make it explicit - trim TANKS before being compared - or, better yet, don't use TANKS in the first place, replace them by of VARCHAR2.
Published by: Boneist on August 25, 2009 16:41
Maybe you are looking for
-
cannot sync the ipad. An error has occurred...
Hello World! Whenever I start my PC, I get this message "cannot sync the ipad. An error occurred... "or similar as I have translated it to French somethng. What can I do? Both iTunes and iOS are uptodate. Thanks for any tips, hints, suggestions, and
-
Keychain Access: change password for Local Items
Hey everybody, Until a few days ago, I had my OS X connected to my Apple ID login Then I unplugged the two and changed the two passwords. Now every time that I start to OS X, many things (talagent...) ask my local products Keychain password, which is
-
Troubleshooting of an installation fails to El Capitan on macbook pro
I installed a Samsung ssd 6 months ago. It was working fine with snow leopard, when I upgraded to 10.11.2 installation never finished instead went into a reboot loop. I am able to get into safe mode and recovery mode.
-
HP-14 D010TU: I'm not treated driver for 32-bit hp-14 d010tu
I face a big problem in my HP D010TU - 14 for 32-bit graphics drivers. plese give me a download link on my pc in 32-bit...
-
Hey,. So the other day I was shooting and whenever I pressed the Menu button, so that the menu would show a second on the LCD screen, but then the screen would go blank before any menu change could be significant. Literally the LCD has become empty i