‎2009 Feb 16 10:16 AM
Hi !
I have a database table. It has 4 fields. 3 of them are key.
Table (f1,f2,f3,f4)
f1,f2,f3: key
f4: numeric field.
From a ABAP program, I can insert (using insert sentence) two records with the same key. why ???
Then, if I try ....
select f1 f2 f3 sum(f4)
from table
group by f1 f2 f3
... it doesn´t work. This sentence returns two records. Why ?
(some fields of the key can be nulls)
Thanks.
‎2009 Feb 16 10:18 AM
HI...
programatially you can insert an entry in a database table....it doesnot look for any other thing....
and after you are done with insertion or deletion or whatever it may be...it will feel as if the created entry are orignal ones
regards
‎2009 Feb 16 10:19 AM
‎2009 Feb 16 10:20 AM
Hi,
When u use groupby statement it will add the similar records and give the result into one record.
check is there any matching records are there...
fro ex:
f1 f2 f3 f4
1 2 3 4
1 2 3 7
1 3 4 10
the output is like this..
f1 f2 f3 f4
1 2 3 11
1 3 4 10
if u perform select query then it will fetch the above two records...
Regards
Kiran
‎2009 Feb 16 10:24 AM
Hi,
From a ABAP program, I can insert (using insert sentence) two records with the same key. why ???If it column is defined with NOT NULL key, you can insert duplicate records as well.
thanks\
Mahesh
‎2009 Feb 16 10:24 AM
select f1 f2 f3 sum(f4)
from table
group by f1 f2 f3
The above select statement does the summation for the same values of f1, f2, f3 and returns. say if table contains
a b c 1
a b c 2
a b d 3
output will be :
a b c 3
a b d 3
Technically the above select statement won't make sense, as you said f1, f2, f3 are key fields and table contains unique row for any f1, f2, f3.
this statement is as good as
select f1 f2 f3 f4
from table
‎2009 Feb 16 10:27 AM
HI OSCAR ,
You can insert duplicate entries in DB table from Program .
Some fields of the key can be nulls .
As far my Knowledge Group By should work .
Thanks
Pinaki
‎2009 Feb 16 10:32 AM
>
> From a ABAP program, I can insert (using insert sentence) two records with the same key. why ???
No you cannot, the second INSERT will result in SY-SUBRC = 4.
Thomas
‎2009 Feb 16 10:33 AM
HI,
From a ABAP program, I can insert (using insert sentence) two records with the same key. why ???first of all It is not at all possible. There should be atleast one key value different for 2 data-row in database table. It is the fundamental concept of key. Your above statement holds for nonkey vaule or partial key field view/selection only.
for next query,
Instead of
select f1 f2 f3 sum(f4)
from table
group by f1 f2 f3........use
select distinct f1 f2 f3 sum(f4)
from table
group by f1 f2 f3............Regards,
Anirban
‎2009 Feb 16 10:33 AM
for the same set of primary keys, u can not insert a value twice.
even if u try to modify the table with adifferent value for the same set of primary keys,it will overwrite the previous value.
Edited by: Kalyan Chakravarthi on Feb 16, 2009 11:33 AM
‎2009 Feb 16 11:48 AM
hi,
well when try creating your table as a sorted table and handle the error. that will not allow you to enter duplicate vales.
the reason u can enter duplicate values is because you have declared your table as a standard table and programatically u can do whatever you like with your standard table..
‎2009 Feb 17 4:46 AM
hi,
well when try creating your table as a sorted table and handle the error. that will not allow you to enter duplicate vales.
the reason u can enter duplicate values is because you have declared your table as a standard table and programatically u can do whatever you like with your standard table..
‎2009 Feb 17 4:51 AM
Hi,
First of all u canot insert two ecirds with the same key.
i u insert then with this key the value of 4th field will change but not a new record with same key.
so, first see this,
Regards