Primary Key in nested tables
Let's assume I have a table containing only one column with users. Behind this table I have a nested table containing different lists. Thus, one database row consists of one user and different list names. However, every user should be only allowed to use unique list names, e.g. the listname "list 1" should be only one time usable for one user. But also every other user should be able to use this name, so the restriction of the key should refer to every row, NOT to the whole nested table.
If I set listname unique, this name can only be used one time for ALL users, not just for ONE. I thought nested tables would manage such problems - what am I doing wrong?
Thanks again. I tried your solution and it worked. However, I have to admit that the whole task is a little more complicated and so I'll just post the SQL-Statement:
CREATE TABLE JMEDOCS.KARTEIVERWALTUNG (
KVUSERID VARCHAR(30) NOT NULL,
KVKOSTSTELLE JMEDOCS.KARTEILISTE_NT,
CONSTRAINT KVUSERID_BENUTZER FOREIGN KEY(KVUSERID)
REFERENCES JMEDOCS.BENUTZER(USERID))
NESTED TABLE KVKOSTSTELLE STORE AS
KARTEILISTE_NT_TAB
(NESTED TABLE KLNEUELISTE STORE AS
KATLISTNRNEU_NT_TAB,
NESTED TABLE K_LISTEN STORE AS KATLISTEN_NT_TAB
(NESTED TABLE KLKATLISTNR STORE AS
KATLISTNRALT_NT_TAB));
If I would like to put the following piece of code somewhere in this statement - where do I have to put it?
((primary key (nested_table_id, klkostnr)) organization index compress)
Similar Messages
-
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 -- -
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. -
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 -
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 -
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 -
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 -
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.
GarryI 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 . -
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. -
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 -
Query to return list of all missing primary key ids from table T1
I found this query online that returns a start and stop for a range of all missing primary key id values from table T1. However i want to rewrite this query to return a whole list of all the missing primary key ids and not a start and stop range. any help plz?
select strt, stp
from (select m.id + 1 as strt,
(select min(id) - 1 from T1 x where x.id > m.id) as stp
from T1 m left outer join T1 r on m.id = r.id - 1 where r.id is null)x where stp is not nullwith t as
select 1 as id from dual union all
select 2 as id from dual union all
select 3 as id from dual union all
select 5 as id from dual union all
select 8 as id from dual union all
select 10 as id from dual union all
select 11 as id from dual union all
select 20 as id from dual
select id_start + level missing_id
from (
select id id_start,
nullif(lead(id) over(order by id) - 1, id) id_end
from t
start with id_end is not null
connect by prior id_start = id_start
and prior dbms_random.random is not null
and level <= id_end - id_start
MISSING_ID
4
6
7
9
12
13
14
15
16
17
18
MISSING_ID
19
12 rows selected.Or:
with t as
select 1 as id from dual union all
select 2 as id from dual union all
select 3 as id from dual union all
select 5 as id from dual union all
select 8 as id from dual union all
select 10 as id from dual union all
select 11 as id from dual union all
select 20 as id from dual
select id_start + level - 1 missing_id
from (
select min(id) id_start,
max(id) id_end
from t
connect by level <= id_end - id_start
minus
select id
from t
MISSING_ID
4
6
7
9
12
13
14
15
16
17
18
MISSING_ID
19
12 rows selected.SY.
Maybe you are looking for
-
Table will not show mutiple price values
I am unable to go beyond 152 for my property price. I want it to say 152000. This is what I put into Oracle: SELECT * FROM Property; PROPERTY_NUM PROPERTY_ADDRESS PROPERTY_CITY PROPERTY_STATE PROPERTY_ZIP PROPERTY_PRICE PROPERTY_TYPE 0001 245 Benner
-
Solaris 8: USB and modem support
Does Solaris 8 IA support USB modems? And if so, what do I have to do to make Solaris talk to my modem using the USB connector? Thank you! Dirk
-
What program do I need to be able to merge files into on PDF
What Adobe program do I need to be able to merge files into one PDF
-
Trying to download Creative Cloud on Desktop and it tells me to download on Desktop!!
I'm using my desktop to try to Download Creative Cloud for the first time and I get the following: Creative Cloud is a desktop app so you'll want to download it from your computer. Driving me crazy! Please assist urgently thank you. Rachelle
-
Why does other storage build up so fast?
I just did a complete restore and back up yesterday, 'cuz I had no storage space remaining. I have no movies, no music, barely any photos or apps installed. After the restore I freed up almost 9 GB out of 12 GB of storage space. The only thing tha