Why is the trigger triggering on all fields in a table?
I have a trigger and the text is as follows. The trigger should just write the emplid to the table PS_DM_ADDR_CHG_EMP whenever there is an update to the fields
STREET1,STREET2 ,STREET3 ,CITY ,STATE ,ZIP ,COUNTRY in PS_PERSONAL_DATA. But some how it is writing emplid to the PS_DM_ADDR_CHG_EMP when any updateis done on any field on the 50 plus fields of the PS_PERSONAL_DATA table. Is there any reason why this happens. I looked at all other triggers and none of them writes any thing to this table though I found one more trigger on PS_PERSONAL_DATA for any insert or update or delete on any field and it uses insert in some other table. I did not see any other triggers related to the PS_PERSONAL_DATA table. So how to diagonize the issue of finding what is causing to write the data to this custom table.
CREATE OR REPLACE TRIGGER HT0P.PERSDATA_RAU
AFTER UPDATE OF STREET1,STREET2 ,STREET3 ,CITY ,STATE ,ZIP ,COUNTRY
ON PS_PERSONAL_DATA
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
v_Emplid ps_personal_data.emplid%type; -- Used for storing EMPLID
BEGIN
v_Emplid := :old.emplid;
UPDATE ps_dm_addr_chg_emp a
SET a.emplid = v_Emplid
WHERE (((a.emplid = v_Emplid) and length(v_emplid) = 3)
or ((substr(a.emplid, 1, 3) = substr(v_Emplid, 1, 3)) and length(v_emplid) = 4 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U'))
or ((a.emplid = v_Emplid) and length(v_emplid) = 4)
or ((substr(a.emplid, 1, 4) = substr(v_Emplid, 1, 4)) and length(v_emplid) = 5 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U'))
or ((a.emplid = v_Emplid) and length(v_emplid) = 5)
or ((substr(a.emplid, 1, 5) = substr(v_Emplid, 1, 5)) and length(v_emplid) = 6 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U'))
or ((a.emplid = v_Emplid) and length(v_emplid) = 6)
or ((substr(a.emplid, 1, 6) = substr(v_Emplid, 1, 6)) and length(v_emplid) = 7 and substr(v_emplid, -1, 1) in('B', 'C', 'J', 'K', 'P', 'U')));
IF SQL%NOTFOUND THEN
INSERT INTO ps_dm_addr_chg_emp (emplid)
VALUES (v_Emplid);
END IF;
END;
Hi,
It would be helpful if you could post formated code using tags. Learn more from FAQ
To test your trigger - You may want to create a temparory table and have an insert statement for the temp table in your trigger and test it by updating other columns of your main table.
Also you may want to ensure it is not the UPDATE statement which is causing the trouble for you by updating some unintended rows...
Regards,
Rakesh
Similar Messages
-
Why is the download icon on all the time?
why is the download icon on all the time?
Hello joelblair85! I know how frustrating it can be when you can't match an icon to a specific app! What make & model phone do you have? Which apps do you know of sync on a regular basis?
Thanks,
MichelleH_VZW
Follow us on Twitter @VZWSupport -
Select all fields of a table while designing the layout of a query
Can some one tell me how to select all fields of a table at a single stroke while designing the layout of a query....this would greatly reduce the time spent to select each and every field of a table into the layout....
Thanks in advanceHi,
Declare your internal table (Say it is itab).
Then :-
Select * from <tablename>.
Eg,.Select * from mara.
Then display it using:-
Loop at itab.
write:/ wa_itab. "Workarea.
endloop.
Thanks and regards,
Prerna -
Why are the duscussion administrators archiving all cd-text conversations?
Why are the duscussion administrators archiving all cd-text conversations?
Looks like they are all archived... Is this to shut us up?
Seeing how long it takes for my posts to be archived!
Windows XPI would try a reset. Hold the sleep/wake and home buttons together until you see the Apple logo and then release. Once the phone restarts, see if it is working correctly. It sounds to me like you may have too many text messages in the Messages app. Have you deleted anything from there lately?
-
Why is the print area on all envelope templates more than 1/2 inch from the left side of the envelope.. ? Can this be fixed or changed.. ?
I have pages 09 version 4.1... It is a small aggravation.. The left 3 or 4 characters on the return address would not print until I realized that by clicking on
" View " & " Show Lay-Out " that it was out side the printable range ...It seems to be a Pages template " Print range " issue.. Both the Epson and the HP printers were doing it and it was today that I realized why.. !!
When I move it to where it will print there is large gap on the left margin of the return address.. Just wondering if anyone else knew about this.. ? My Pages is ' 09 ' version 4.1... -
why is the ios6 compatible for all the iphones but not all the phones got the all upgrades, for example the panorama camera?? this is another reason I am starting to dislike apple. An ipod is able to us an upgrade but not all the phones are? makes sense
"why is the ios6 compatible for all the iphones"
Ios 6 is not available for all iphones. Original Iphone and iphone 3 are not supported.
"but not all the phones got the all upgrades, "
This is common for most any device/computer. Not all iphone/computer/device models can handle all of the new features. Like any device, hardware is limited and cannot always support all new features and software. -
How do you count the multiple columns of a field in a table
How do you count the multiple columns of a field in a table
Hi,
4396bf34-e890-4202-a6b0-4e08c9ff0e89 wrote:
How do you count the multiple columns of a field in a table
Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
"Field" isn't a standard database term. Some people say "field" when they mean "column", but I don't think that's what you mean ("How do you count the multiple columns of a column .."). Do you want to know how many times a column is used (as opposed to NULL), or the number of different values in a column? You really need to show what you want. -
Trim the gaps.. condense a field of a table
Hello all,
I have a query related to trim the spaces of a particular field of a table.
e. i have a table gt_aoextseq which contains 2 records.
This table contains the filed ORDNO.
This field ORDNO contains prefixed spaces.
How can I remove the spaces for the field ORDNO in the table gt_aoextseq .
Kindly suggest me.
Thanks,
RekhaHi, Rekha
Hope following code will help you in this way,
TYPES: BEGIN OF t_test,
a(10),
b(20),
END OF t_test.
DATA: it_test TYPE STANDARD TABLE OF t_test WITH HEADER LINE,
wa_it_test TYPE t_test.
DO 10 TIMES.
wa_it_test-a = ' 45'.
wa_it_test-b = ' 10'.
APPEND wa_it_test TO it_test.
ENDDO.
LOOP AT it_test INTO wa_it_test.
CONDENSE: wa_it_test-a, wa_it_test-b.
MODIFY it_test from wa_it_test INDEX sy-tabix.
ENDLOOP.
Please Reply if any Issue,
Kind Regards,
Faisal -
Change the decimal places of a field in screen table control
HI ,
I have a MENGE field having data element as , BSTMG (decimals 3 ).
This field MENGE , I have used in a table control. The value in this field is filled from a custom Z-table where the same data element BSTMG is used. So , for eq.) value in MENGE field is shown as 6.010
But the requirement is that the value should be displayed as only 2 decemals i.e.) 6.01
I dont want to change the domain of the field in the Z-table , to 2 decimal places , because the table is used in other developments also , so it will give a dump there which I have to correct in other developments also.
So , is there any way to change the decimal places of a field in screen table control , without changing the domain , in the table from where the value is fetched... ????
Edited by: abhijeet_7013 on Feb 14, 2011 3:18 PMHi, create a structure in local program with same field names and change the TYPE with some 2 decimal domain of MENGE. Populate this local stucture and use it in TABLE CONTROL.
Hope this helps...
Cheers -
Why is the ipod screen on all the time when plugged in
and conversely, why does the screen only show the time when you are actually walking around playing music?
Is there any way to change that? I want to see what song is playing, not what time it is or whatever that number on the screen means.
thanks
BobI don't want it to stay ON, ie lit -- I just want the information on the screen to stay the same, is that so hard? The time is on that screen anyway, why not give us an option to leave it that way? The battery lasts plenty long compared to older ipods.
Bob -
Changing the length of a key field in a table
Hi,
I want to increase the length of the field from 2 to 4 in a standard SAP table and deliver it to the customers. This field is a key field in table. This field from this table is also used in view and view clusters.
What is the implication of changing the length to the customers. The customers would have already data in this field and they should not loose any data. Will the existing data for customers remain at length 2 or do they have to do some conversion?
Regards,
Srini.
Edited by: Srinivasa Raghavachar on Feb 7, 2008 12:45 PMhi,
The database table can be adjusted to the changed definition in the ABAP Dictionary in three different
ways:
By deleting the database table and creating it again. The table on the database is deleted, the inactive
table is activated in the ABAP Dictionary, and the table is created again on the database. Data
existing in the table is lost.
By changing the database catalog (ALTER TABLE). The definition of the table on the database is
simply changed. Existing data is retained. However, indexes on the table might have to be built again.
By converting the table. This is the most time-consuming way to adjust a structure.
If the table does not contain any data, it is deleted in the database and created again with its new
structure. If data exists in the table, there is an attempt to adjust the structure with ALTER TABLE. If the
database system used is not able to do so, the structure is adjusted by converting the table.
Field 1 Field 2, Field 3
NUMC,6 CHAR 8 CHAR, 60
Field 1 Field 2 Field 3
NUMC,6 CHAR, 8 CHAR,30
The following example shows the steps necessary during conversion.
Starting situation: Table TAB was changed in the ABAP Dictionary. The length of field 3 was reduced
from 60 to 30 places.
The ABAP Dictionary therefore has an active (field 3 has a length of 60 places) and an inactive (field 3
still has 30 places) version of the table.
The active version of the table was created in the database, which means that field 3 currently has 60
places in the database. A secondary index with the ID A11, which was also created in the database, is
defined for the table in the ABAP Dictionary.
The table already contains data.
Step 1: The table is locked against further structure changes. If the conversion terminates due to an
error, the table remains locked. This lock mechanism prevents further structure changes from being
made before the conversion has been completed correctly. Data could be lost in such a case.
Step 2: The table in the database is renamed. All the indexes on the table are deleted. The name of the
new (temporary) table is defined by the prefix QCM and the table name. The name of the temporary
Step 3: The inactive version of the table is activated in the ABAP Dictionary. The table is created on the
database with its new structure and with the primary index. The structure of the database table is the
same as the structure in the ABAP Dictinary after this step. The database table, however, does not
contain any data.
The system also tries to set a database lock for the table being converted. If the lock is set, application
programs cannot write to the table during the conversion.
The conversion is continued, however, even if the database lock cannot be set. In such a case
application programs can write to the table. Since in such a case not all of the data might have been
loaded back into the table, the table data might be inconsistent.
You should therefore always make sure that no applications access the table being converted
during the conversion process.
Step 4: The data is loaded back from the temporary table (QCM table) to the new table (with MOVECORRESPONDING).
The data exists in the database table and in the temporary table after this step.
When you reduce the size of fields, for example, the extra places are truncated when you reload the
data.
Since the data exists in both the original table and temporary table during the conversion, the storage
requirements increase during the process. You should therefore verify that sufficient space is available in
the corresponding tablespace before converting large tables.
There is a database commit after 16 MB when you copy the data from the QCM table to the original
table. A conversion process therefore needs 16 MB resources in the rollback segment. The existing
database lock is released with the Commit and then requested again before the next data area to be
converted is edited.
When you reduce the size of keys, only one record can be reloaded if there are several records whose
key cannot be distinguished. It is not possible to say which record this will be. In such a case you should
clean up the data of the table before converting.
Step 5: The secondary indexes defined in the ABAP Dictionary for the table are created again.
Step 6: The temporary table (QCM table) is deleted.
Step 7: The lock set at the beginning of the conversion is deleted.
If the conversion terminates, the table remains locked and a restart log is written.
Caution: The data of a table is not consistent during conversion. Programs therefore should not access
the table during conversion. Otherwise a program could for example use incorrect data when reading the
table since not all the records were copied back from the temporary table. Conversions therefore
should not run during production! You must at least deactivate all the applications that use tables to
be converted.
You must clean up terminated conversions. Programs that access the table might otherwise run
incorrectly. In this case you must find out why the conversion terminated (for example overflow of the
corresponding tablespace) and correct it. Then continue the terminated conversion.
Since the data exists in both the original table and temporary table during conversion, the storage
requirements increase during conversion. If the tablespace overflows when you reload the data from the
temporary table, the conversion will terminate. In this case you must extend the tablespace and start the
conversion in the database utility again.
If you shorten the key of a table (for example when you remove or shorten the field length of key fields),
you cannot distinguish between the new keys of existing records of the table. When you reload the data
from the temporary table, only one of these records can be loaded back into the table. It is not possible
to say which record this will be. If you want to copy certain records, you have to clean up the table
before the conversion.
During a conversion, the data is copied back to the database table from the temporary table with the
ABAP statement MOVE-CORRESPONDING. Therefore only those type changes that can be executed
with MOVE-CORRESPONDING are allowed. All other type changes cause the conversion to be
terminated when the data is loaded back into the original table. In this case you have to recreate the old
state prior to conversion. Using database tools, you have to delete the table, rename the QCM table to
its old name, reconstruct the runtime object (in the database utility), set the table structure in the
Dictionary back to its old state and then activate the table.
If a conversion terminates, the lock entry for the table set in the first step is retained. The table can no
longer be edited with the maintenance tools of the ABAP Dictionary (Transaction SE11).
A terminated conversion can be analyzed with the database utility (Transaction SE14) and then
resumed. The database utility provides an analysis tool with which you can find the cause of the error
and the current state of all the tables involved in the conversion.
You can usually find the precise reason for termination in the object log. If the object log does not
provide any information about the cause of the error, you have to analyze the syslog or the short dumps.
If there is a terminated conversion, two options are displayed as pushbuttons in the database utility:
After correcting the error, you can resume the conversion where it terminated with the Continue
adjustment option.
There is also the Unlock table option. This option only deletes the existing lock entry for the table .
You should never choose Unlock table for a terminated conversion if the data only exists in the
temporary table, i.e. if the conversion terminated in steps 3 or 4. table for table TAB is therefore QCMTAB.
Hope this is helpful,Do reward. -
Trigger to concatenate two fields in a table
Hi
I am trying to concatenate two column in a table and add to the third column in the same table, all the columns are
numbers, I want to write a trigger which is after insert to do that..does anyone know how its done...
thanks a lot
JessicaHi, Jessica,
Welcome to the forum!
Do you really need to store this concatenation? The way you would get these results in a normalized database is to store the numbers separately, and comnbine them, when necessary, in queries and reports. You can use use a view to avoid repeating the same coiding over and over.
If you really want to store the value, use a BEFORE INSERT OR UPDATE trigger, like this:
CREATE OR REPLACE TRIGGER table_x_biu
BEFORE INSERT OR UPDATE
ON table_x
FOR EACH ROW
BEGIN
:NEW.column_3 := TO_CHAR (:NEW.column_1)
|| '-'
|| TO_CHAR (:NEW.column_2);
END;I'm confused by your exact requirements. Concatentaion can only be done to strings.
If column_1 and column_2 are NUMBERs, the trigger above will make string versions of those numbers, concatenate them together (with a hyphen between them), and put the results in the VARCHAR2 column column_3.
So after this statement:
INSERT INTO table_x (column_1, column_2, column_3)
VALUES (1, 2, '9-8');the new row will have column_3= '1-2'. (In this case, there is no point in explicitly setting column_3, because the trigger will always set the value based entirely on column_1 and column_2.)
If you need more help, post CREATE TABLE , INSERT and UPDATE statements, and who what you want the table to contain after each INSERT or UPDATE. -
SQVI - Not able to see all fields in a table.
Hello all,
I was not able to add few fields in a table into my report as I am not able to see those table fields in SQVI. For example T508A-RTEXT. Please let me know.Hi,
As Tamas suggested, field RTEXT is actually a filed in text table T508S. You would have to join table T508S in your query.
For more info on text-tables, please look the below link:
[Text Tables|http://help.sap.com/saphelp_smehp1/helpdata/en/cf/21ea9e446011d189700000e8322d00/content.htm]
Thanks.
Ravi -
Activation error while changing the data type of a field of a table
hi friends,
i am facing one problem while changing a data type of a field of a table.
i just created one table(Yqm32) .i have assigned charcter data type to one field(ztotal_count) .now i want to change this charcter data type to numeric data type.
while changing to NUMC data type activation error is comming as below.
Table is not yet classified
Field ZTOTAL_COUNT: Type change
ALTER TABLE is not possible
Structure change at field level (convert table YQM32)
Check on table YQM32 resulted in errors
Table YQM32 could not be activated
(E- Structure change at field level (convert table YQM32)
plz suggest.i need to change the data type from char to numc.
Thanks & RegardsHi Pabitra......
From the SE11 change the table as u wanted and then from menubar select
UTILITIES--> DATABASE UTILITY
It will open database utility
there u select the Activate and adjust database button.
then the database table will get adjusted.
just try it once.........
Suresh...... -
How can i know the number of lines in field-symbol internal table
how can i know the number of lines in field-symbol internal table
Hi,
If your field symbol has been defined as an internal table :
Use std describe as
Data: l type i.
describe <fs> lines l.
'l' will contain the number of lines as needed.
FYI
The size of this storage area in a field symbols depends on the number of table lines which is not fixed, but determined dynamically at runtime.
Regards,
Amit
Maybe you are looking for
-
How to see open files on server
I want to be able to see which files that are open on my server by my users. Is there a tool or utility to see this? Ive tried lsof but i find that not usable.
-
903 management of app / out / err logs to rotating log files??
I'm deploying BC4J apps under OC4J. One of my complaints about the production environment is that the noisy logging from BC4J is directed to a static file name by the shell startup script. This not enterprise nor manageable in a 24x7 environment sinc
-
When I access my website by cellphone, my desktop design format is displayed, and not the cellphone format which I designed. What can I do?
-
AMS 5 on AWS, Video on Demand and CloudFront
Hi there, I recently subscribed to AMS on Amazon and was able to stream audio content (mp3) on demand to a HTML page using flow player. What I need to do now is integrate CloudFront to the stack. All I could find regarding AMS and CloudFront was rela
-
Lower security to higher security interface PAT.
Hi, Can we have PAT with nat and global statements for source natting a traffic from Lower security interface to Higher security? If nat & global can't achieve this, what are the Possibilities. merci, arun