Two Primary keys on one table
We are at the end of completing a project and we ran into a last minute bug. We are using two primary keys on a table to form a unique key. The problem we have is the program hangs up and gives us the following error,
ORA-20001: Error in DML: p_rowid=CUA, p_alt_rowid=SIT_ID, p_rowid2=, p_alt_rowid2=. ORA-01422: exact fetch returns more than requested number of rows,
probably meaning we only have one key setup in the DML
processing when our table has two.
we created a process with the Primary key set up in the DML but how does the secondary key column value work and is that what it's used for,because we tryed with no success. Is there a way around this problem without having to change our table by inserting only one primary key.
Thanks in advance.
Garry
I am facing a similar problem , I used the two primary keys for navigating to the form page (forms with reports) so that the form page may display distinct records.
Its not posing any error but its not showing the value of other columns associated with that record.
Only the columns contained in the page item in the form page , that's are used as primary keys or that have been specified in the navigation part of the report page, are being shown ,
Like for example I have got 5 columns
a,b,c,d,e out of which a and b are my primary keys .
I am using these to fetch values in the form page of forms with reports.
We can specify three keys at the most , in my case I am having two , if in place of the third key I specify some column then in the form page it displays the correct record details of the three columns specified( 2 keys and one simple column), and it doesn't displays the value of other columns.
Please help me out of this .
Similar Messages
-
How many primary keys for one table?can we add more primary keys
In general Table have one primary key.is it possible to more than one primary key in a table?(ie is it possible to add more than one pirmary key in a table). Help me out.
pls do check this link
[http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm|http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ea0b446011d189700000e8322d00/frameset.htm]
All the key fields of a table must be stored together at the beginning of the table. A non-key field may not occur between two key fields.
A maximum of 16 key fields per table is permitted. The maximum length of the table key is 255.
If the key length is greater than 120, there are restrictions when transporting table entries. The key can only be specified up to a maximum of 120 places in a transport. If the key is larger than 120, table entries must be transported generically. -
If I have an EntityBean that mappes to two tables within one database, when I create
that EJB, whoes reponsibilty to generate the primary key in database table? The
RDBMS or EJB?
Thanks,
JWRefer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
"Jingwei Zhang" <[email protected]> wrote:
>
If I have an EntityBean that mappes to two tables within one database,
when I create
that EJB, whoes reponsibilty to generate the primary key in database
table? The
RDBMS or EJB?
Thanks,
JW -
Two foreign keys in one single table
i have a table 'customers' with a 'customerid' as its primary key and another table 'drinks' with a primary key 'drinkid'.now i have to create a table 'customerdrink' with its primary key as 'customerdrinkid' , and 'customerid' & 'drinkid' as
its two foreign keys.how can i write the script in sql server to connect the first two tables with the last one ie how can i relate one primary key(customerdrinkid) with two foreign keys(customerid and drinkid) in a single query?pls help me out!!!>> I have a table 'customers' ...<<
How nice for you, but where is the DDL? Oh, I see you are the Great and Wonderful “shubha2323” who does not have to follow Netiquette or treat anyone with minimal respect when he demands they do his work him!
Where is what you already tried? Oh, the Great and Wonderful “shubha2323” does not try anything! His forum slaves should serve him!
Do you understand how rude you are when you ignore the basic forum rules?
CREATE TABLE Customers
(customer_id CHAR(16) NOT NULL PRIMARY KEY,
CREATE TABLE Drinks
(drink_id CHAR(10) NOT NULL PRIMARY KEY,
>> with a customer_id as its primary key and another table Drinks with a primary key drink_id. now I have to create a table 'customer_drink' with its primary key as 'customer_drink_id' <<
You do not know what single quotes mean in ANSI/ISO Standard SQL, or how to follow ISO-11179 Standards for data element names. And this is a stupid idea. You have a key!! Do you know what a key is?
CREATE TABLE Drink_Preferences
(customer_id CHAR(16) NOT NULL
REFERENCES Customers(customer_id)
ON DELETE CASCADE,
drink_id CHAR(10) NOT NULL
REFERENCES Drinks(drink_id)
ON DELETE CASCADE,
PRIMARY KEY (customer_id, drink_id),
etc
Stop posting until you have manners and you have read a book on RDBMS.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
Two foreign keys to one primary key
I'm having trouble displaying information for two foreign keys in my table. My goal is to display the first and last name of both a Project Manager and Account Manager. I have a "Jobs" table linked to an "Employees" table.
Jobs
ProjectMgrID
AcctMgrID
Employees
EmployeeID
LastName
FirstName
Both ProjectMgrID(fk) and AcctMgrID(fk) are linked to EmployeeID(pk). When I build a query, I am not sure how to display both the FirstName and LastName fields for both. It only allows me to add them once, and when I add them twice it just displays the same information twice.
Please help!Welcome to the forum!
It looks like you'll need to join to EMPLOYEES twice.
Something like the following:
SELECT e1.firstname
, e1.lastname
, e2.firstname
, e2.lastname
FROM jobs
JOIN employees e1 ON e1.employeeid = jobs.projectmgrid
JOIN employees e2 ON e2.employeeid = jobs.acctmgrid
; -
How can I obtain the primary key of a table for an entity relation?
hello everybody
I am doing a consultation to a table in my data base, good this table has alone two fields, the first one is the code or pk and the second one is the description, to be presisos they are names of city and code.
From the beginning!!: This method this one in another class that is a Dialog that is going to call to the class SelecPlace ();
SelecPlace sl = new SelecPlace();
public void capturarLugar(){ // Simple void method in the mentioned class
String place = txtProcedencia.getText() ; // a JTextField
sl.executeStatement(place) ;
}ok, now we see part of the code of the class SelectPlace
public class SelecPlace extends AbstractTableModel{
Connection con = null;
Statement sentencia = null ;
ResultSet rs = null;
ResultSetMetaData rsmd = null ;
String[] nameColum = {} ;
Vector datos = new Vector() ;
public SelecPlace() { }
public void executeStatement(String query){
try{
con = DBManager.getConnection() ;
sentencia = con.createStatement(rs.TYPE_SCROLL_INSENSITIVE,
rs.CONCUR_UPDATABLE) ;
String sql = "select * from Place where descripcion like %"+query+"%'";
rs = sentencia.executeQuery(sql) ;
rsmd = rs.getMetaData();
int nroColumnas = rsmd.getColumnCount() ;
nameColum = new String[nroColumnas] ;
//obtengo los nombres de columnas en cache
for(int colum = 0; colum < nroColumnas; columna++){
nameColum[colum] = rsmd.getColumnLabel(columna + 1) ;
datos = new Vector();
while(rs.next()){
Vector newRow = new Vector();
for(int i = 0; i < getColumnCount(); i++){
newRow.addElement(rs.getObject("place_ID"));
newRow.addElement(rs.getObject("description"));
datos.addElement(nuevaFila);
fireTableChanged(null);
}catch(SQLException e){
System.err.println(e);
e.printStackTrace(System.err);
System.out.println("error in statement");
}catch(ClassNotFoundException cnfe){
System.err.println(cnfe);
}Ok, this code me works and I obtain in this case the field description of the table Place
Now my question is, how can I obtain the primary field of my table?
I need this value of this field that in the base of information in a bigint, and to take it to the first class before mentioned, for that I am working with a data base relatedCertain duffymo and everyone!!, good I give you my scheme:
And generalizing my question, I want to obtain the value of the primary key of a table in the database, I obtain more values of the same row, but I need the primary key, and you see one with the primary key I want to turn a Long and it to insert with code java in foreign clave in another table of the database
Good of this form I believe that it would not be breaking the integrity relacional of the tables -
How to get the PRIMARY KEY of a table at runtime ???
Hi everybody,
My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
Any suggestions will be appreciated..
Thanks,
SekharU will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
Or else you can try with 'DDIF_TABT_GET'
Or try this code
PARAMETERS: p_table TYPE tabname OBLIGATORY.
DATA: go_strucdescr TYPE REF TO cl_abap_structdescr,
gt_tab_fields TYPE ddfields.
FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
TRY .
* Get the details of the DDIC table
go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
CATCH cx_sy_move_cast_error .
MESSAGE 'Error while casting' TYPE 'S'. RETURN.
ENDTRY.
* Check if input is a DDIC table
CHECK go_strucdescr->is_ddic_type( ) = 'X'.
* Get the details of the table fields
gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
* Display the Key fields of the table
LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
WRITE: / <gwa_tab_field>-fieldname.
ENDLOOP. -
Is it possible to create many primary key for a table?
hello sir/mam.
i am selva, i am new to abap,
is it possible to create many primary key for a table?
please guide me.Hi Selva,
Many Primary Keys = Composite Key.
i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
This can be achieved by checking the primary key check box in se11.
Hope it helps.
Regards,
Maheswaran.B
Message was edited by: Maheswaran B -
How to define Composite primary key for a Table
Hi ,
I am basically more into Java Programming , with little bit knowledge on Oracle as DataBase .so please excuse for my silly doubts .
Can anybody please tell me how to define a Composite Primary Key on a Table .
Thanks in advance .
Edited by: user672373773 on Sep 25, 2009 8:54 AMHere is an example right out of the Oracle documentation and the syntax for adding PK since you mention adding a composite PK.
Example creating composite index
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_indexing.htm#sthref594
Syntax for adding a PK (composite or not)
alter table oooooooo.tttttttt
add constraint tttttttt_PK
primary key (sample_column2,
sample_column1)
using index
tablespace IDXSPC
pctfree 05
initrans 04
maxtrans 08
storage (initial 16k
next 16k
maxextents 32
pctincrease 0);
-- dictionary management with restricted storage, change as desired.
HTH -- Mark D Powell -- -
Is there any restriction on the length of all Primary keys in a table
Hi all,
Is there any restriction on the length of all Primary keys in a data base table?
i have some 10 fields as primary key in a DB table and length exceeds 120 and getting a warning.
Please let me know will there be any problems in future with respect to the same?
With regards,
SumanthWell actually there are constraints like
Total of internal lengths of all primary key columns 1024 Bytes
Number of primary key columns per table 512
For other information about SAP database please refer to http://sapdb.org/sap_db_features.htm
Thanks & Regards,
Vivek Gaur
Alwayz in high spirits -
What is the best practice for creating primary key on fact table?
what is the best practice for primary key on fact table?
1. Using composite key
2. Create a surrogate key
3. No primary key
In document, i can only find "From a modeling standpoint, the primary key of the fact table is usually a composite key that is made up of all of its foreign keys."
http://download.oracle.com/docs/cd/E11882_01/server.112/e16579/logical.htm#i1006423
I also found a relevant thread states that primary key on fact table is necessary.
Primary Key on Fact Table.
But, if no business requires the uniqueness of the records and there is no materilized view, do we still need primary key? is there any other bad affect if there is no primary key on fact table? and any benifits from not creating primary key?Well, natural combination of dimensions connected to the fact would be a natural primary key and it would be composite.
Having an artificial PK might simplify things a bit.
Having no PK leads to a major mess. Fact should represent a business transaction, or some general event. If you're loading data you want to be able to identify the records that are processed. Also without PK if you forget to make an unique key the access to this fact table will be slow. Plus, having no PK will mean that if you want to used different tools, like Data Modeller in Jbuilder or OWB insert / update functionality it won't function, since there's no PK. Defining a PK for every table is a good practice. Not defining PK is asking for a load of problems, from performance to functionality and data quality.
Edited by: Cortanamo on 16.12.2010 07:12 -
Multiple composite primary key in Master Table
Dears ,
I am try to find any solution about Multiple composite primary key by search in forum , but i didn't success ... i am try to built master detail , the master structure table built with multiple composite primary key , i know that apex 4.2 still support tow primary key , in detail table i solved the problem by depend on rowid , and now i can use multiple composite primary key in detail table , the problem with master table because it's support only tow primary key , there are any solution by manual process or any something else ?
Thanks
Abo YahyaHi,
I've never done this so all I can do is give some suggestions. It takes more effort because you are going beyond what APEX currently supports. That said, you might try searching the forum with this search string:
key AND table AND instead
Make sure the ANDs are capitailized in the search criteria. Also, look at this thread {thread:id=395870} and the forum thread asociated with this message {message:id=10542916}.
Best wishes,
Howard -
Composite primary key in oe_order_headers_all table?
Hi all
What are columns involved in composite primary key in oe_order_headers_all table? how to identify that?
(Order_number, order_type, org_id) are the combination of composite primary key or anything else ?select * From all_constraints where table_name = 'OE_ORDER_HEADERS_ALL'
SELECT AIC.* FROM ALL_INDEXES AI, ALL_IND_COLUMNS AIC
WHERE AI.TABLE_NAME='OE_ORDER_HEADERS_ALL'
AND AI.UNIQUENESS='UNIQUE'
AND AI.INDEX_NAME = AIC.INDEX_NAME
order by AI.INDEX_NAME
Hope this helps,
Sandeep Gandhi -
Primary Key missing in Table OBJS
Hi,
I have a problem in establishing relationship between Course Type and Course in Training and Event Management.
Course Type is created in Active status and Course is Planned (ISTAT2).
How can I create cours ein active status?
How can I establish the relationship A020 between D and E object.
How can I see the Participant list in PSV1 , I get an Error Primary Key misisng in Table OBJS.
I am uploading the data with LSMW.
Thanks
PVPlease go through documentation of report "RHSOBJCH". Also check following SAP notes:
520488
134311
138411
Regards -
How add new field as primary key for existing table
Hi,
There is table with name REVIEWER_REUSE_EFFORT and the table has 8000 rows in it.
Now the enhacement i must do on this table is there is no primary key on this table. so i must create a ID also add values to this table of ID
Table structure is like this
Create table REVIEWER_REUSE_EFFORT
PRO_ID number,
POBJ_ID number,
TASK_ID number,
POTENTIAL_EFFORT number,
COMMENTS varchar2(1200),
CREATED_BY varchar2(100),
CREATION_DATE sysdate
UPDATED_BY varchar2(1200),
UPDATED_DATE sysdate
Please suggest me how to add values in that 8000 rows
Thanks
SudhirHi,
If you want to add a new column and update the new column with sequence of number
alter table REVIEWER_REUSE_EFFORT add (ID number);
update REVIEWER_REUSE_EFFORT set ID=rownum;Regards,
Prazy
Edited by: Prazy on Jun 21, 2010 3:13 PM
Maybe you are looking for
-
IPad will not display photos from library
Hi there, have iPad 1 and strange problem noticed since uprgaded to OS5. I have photo album (Portable Album) on my MacBook Pro that is prepared for portable devices, namely iPad and iPhone. So I do sync and status bar is showing all 177 pictures tran
-
Photo booth image size after lion upgrade
While in Snow Leopard, whenever I take a photo using Photo Booth and drag and drop it onto an email message in a web browser, it pastes a smaller (approx 60-70kb) size of the image. With Lion, whenever I do this it pastes a bigger image (around 150-2
-
Annotating, Stamping, Signing PDF in Browser
Our company built a browser-based (Internet Explorer) product in which we allow the user to interact with PDFs to stamp, sign, and add comments using SDK 6. We built an Acrobat Plugin using C++ to create a custom toolbar to facilitate zooming, searc
-
Would i be better off if i Uninstalled,and reinstalled,the FCP due to the "The operation couldn't be completed. (DSPPublishing error -29)"? I Didn't think i was a complete idiot,when it came to video editing but this program is really kickin my Butt!
-
Transfering a playlist to external harddrive
Several months ago I moved my entire iTunes folder to an external harddrive. For a few weeks I was without the drive, though, so the new songs I imported got saved to my hard drive. To make things easier, I put all of these new songs in one playlist.