Writing a store procedure for deleting records
how can i write a store procedure for deleting records from a table.
i have a table called employees
empid
empname
deptid
and table department
deptid
dept
floor
how can i write a store procedure which would delete records of employees from employees table for particular department when i delete that department from department table.
thanks
872959 wrote:
how can i write a store procedure for deleting records from a table.
i have a table called employees
empid
empname
deptid
and table department
deptid
dept
floor
how can i write a store procedure which would delete records of employees from employees table for particular department when i delete that department from department table.
thanksDoes not seem to be a sound design, to me.
Employees do not go missing when organization change is made & department is eliminated.
If you insist such nonsense, write TRIGGER to issue desired DML
Similar Messages
-
Procedure for deleting a role which is already in Production
Hi,
can any one explain me the procedure for deleting a role which is already in production
i want to know procedure for deletion of
1.single role
2.composite role
3.derived role
4.parent role
thanks,
SSSSHi,
Role deletion must be done in development box and the deletion must be transported to quality and productuion
For single and derrived roles create the transport request and delete the role and transport the deletion.
For Deletion of parent role: you cannot delete the parent role unless all the derrived roles within it are deleted.
To avoid the transport of user assignment make sure PRGN_CUST is set to 'NO' value for the parameter USER_REL_IMPORT.
Rakesh -
Release procedure for condition record
Hello Gurus,
please tell me how to run release procedure for condition record. especially the function of the release status and process status.
thanks very much!Hi,
Please go through the following information.
[Relase Procedure for Condition Record|http://help.sap.com/saphelp_47x200/helpdata/en/a4/af9e78e69611d2ace10000e8a5bd28/frameset.htm]
[Release Procedure for PR|http://www.sap123.com/showthread.php?t=59]
Reward if helpful.
Thanks and Regards,
Naveen Dasari -
I have two tables
table department
dep id
dep_name
dep_manager
it has following records in it :
1 sales mark
2 marketing petter
3 hr james
and how i have to insert date in to employee table which as
emp_id
emp_name
emo_dep
emp_salary
i need to write a store procedure which would
Insert a row into the employee table. If the department does not exist. Insert it into the departments table.
Thanks872959 wrote:
i need to write a store procedure which would
Insert a row into the employee table. If the department does not exist. Insert it into the departments table.Software engineering is about taking a complex problem, reducing it into smaller simpler problems, and then solving each of these simpler problems in turn. The end-result is a solution for the complex problem.
So do the following. Write 3 procedures:
- a procedure that takes employee data as input and inserts this into the employees table
- a procedure that takes department data as input and inserts this into the departments table
- a procedure (or function) that checks whether a specific department exists in the departments table
This is easy to do.
Once done, then you simply use these 3 building blocks in a new procedure that
a) checks if the department exists
b) inserts the department if it does not
c) inserts the employee
Keep in mind that a software engineering problem cannot be more simpler than this. You need to understand how to do this (simplifying the problem) and how the design and write the code for it. Real world problems are magnitudes more complex - and if you want to make software engineering a career, you should not be struggling to deal with the most elementary of problems. -
Store procedure for sale order
hi
i want store procedure that we can't add stand alone sale order without sale quatationhi,
you can check my post in this link
Re: Storeprocedure for sale order without sale quotation
regards
Fidel -
Alert Button for delete record ASP
Hello I have a delete record and have added a javascript
alert box. I have 2 options. The first is OK and the second is to
cancel. The problem is that I having trouble with the cancel part.
It deletes the record regardless. I tried to pass information such
as if they click cancel <% TH_Proceed = "" %> and in the
delete Dreamweaver code put an if statement to see if the
TH_Proceed <> "" to proceed.
It seems like once it is clicked the information from the
form to delete is passed and it forgets about what I try to send.
Sorry I am not to experienced with this.
Thanks for any help<form, not </form
onSubmit = "return confirm_entry()"
If you don't return anything from the function call, the
submit will of
course go through since that's the default behavior.
The function itself must be altered, too. After your alert
saying the file
will be deleted, return true. After your alert saying the
file will not be
deleted, return false.
"Pixel Pusher" <[email protected]> wrote in
message
news:e8k38f$mtt$[email protected]..
> Thank you. But still not completely understanding. I
have details. Thank
> you
> again for the help.
>
> This is the form tag:
>
> </form id="frm_delete" name="frm_delete"
method="POST"
> onSubmit="confirm_entry()"
action="<%=MM_editAction%>">
>
> This is the submit button:
> <input type="submit" name="Submit" value="Delete This
File!" />
>
> This is the JavaScript:
>
> <script language="JavaScript">
> <!--
> function confirm_entry()
> {
> input_box=confirm("Click OK or Cancel to Continue");
> if (input_box==true)
>
> {
> // Output when OK is clicked
> alert ("The File Will be deleted");
> }
>
> else
> {
> // Output when Cancel is clicked Option
>
> alert ("The File Has Not Been Deleted");
> }
>
> }
> -->
> </script>
> -
Calling Procedure for each record ?
Hi,
I am using a procedure in a mapping.
I defined the procedure which is having 4 out parameters.
I am assigning these default values to the tables in a mapping.
When I see the generated code in a mapping, I observed that, the procedure is being called for each record.
But actually, its enogh to be called only once.
Could any one please help me, how can I restrict the procedure calling for each record.
Any help would be greatly appreciated.
Thank you,
Regards,
Gowtham SenHi,
U can use MAP-INPUTS operator to give the inputs to the procedure and use a PRE_MAPPING operator to call the procedure. this way even if u feel u want to make the mapping running thru an scheduler u can still use it without changing the code.
Regards
Bharath -
Delta update for deleted records
Hi,
I use delta update for my data. As destination I use ODS object and this ODS contains two keys: key1 and key2. On step of preparing data for extraction, key2 is lost(we can't determine it) - key1 is known only.
I'm finding a way how to update ODS by deleted records('D' update mode) if this records contain only key1 value(key2 is empty). I need to delete all records with key1 only, key2 is not important for this update.
Is it possible to set key2 some BW specific value, which will be accepted as equal for old key2 values ?
Or some other standart ways are known for this situation ?
Thanks in advance,
Fiodar.I would use the update rules to read the active data table of the ODS. There you can read all the key2 values for a given key1.
If you get one row with key1 filled and key2 = '*' (for example you could split it into multiple records, one per key2. A sample coding might look like:
LOOP AT DATA_PACKAGE into l_d_data_package.
IF key2 = '*'.
DELETE DATA_PACKAGE.
SELECT * FROM /BIC/AMY_ODS00 INTO l_d_my_ods
WHERE key1 = l_d_data_package-key1.
l_d_data_package-key2 = l_d_my_ods-key2.
append l_d_data_package to DATA_PACKAGE.
ENDSELECT.
ENDIF.
ENDLOOP.
Best regards
Dirk -
Delta enable custom func mod data source for Delete record also
Hi,
We have a custom function module data source and the base table on which data is extracted has two time stamp fields ( created on, changed on ) and the data source is delta enabled with the timestamp field.
It works aboslutely fine in Full and initial mode and load data into a target ODS.
Even in delta mode we believe that it works in most of the cases( only change of an existing records and creation of new records). However in the case of delete, we have issues. When the data is deleted from the base table we completely loose the record and cant advice the BW which one to delete.
In order to bypass this we have analyzed the cdhdr/cdpos table and found out that that we can compute the Key field value that was deleted from the last delta run and can include it as such in the data that are extracted.
Big Question is by what mechanism we let the BW know that this is a delete, so that the existing record( with the same key) is actually deleted from the ODS. I have seen some fields like 0RECORDMODE doing things in SAP delivered content. But not sure how we can get this work for our custom data source.
Please let us know whether you need any clarification on this. I shall be prompt to provide points who can resolved this showstopper issue for us.
ThanksHi Aruna,
I have tried to explain : "Big Question is by what mechanism we let the BW know that this is a delete"
Now to create a DataSource, you will have to include the information from the Tables as you mentioned:
1: CDHDR
2: CDPOS
In this table you can check the CHANG_ID as the field which gives the information of
1: Overwrite
2: Add
3: Delete
Now when you create the Function Module, make a field similar to this and read the R/3 Table field CHANGE_IND and pass the relevant Indicators to the BW in the Transfer Rules
Like
CDHDR refers 'D' for delete but In BW 'R' denotes Deleted image. So the FM should take care this and pass the blank for all and 'R' for the documents with 'D' for each line item along with the other required fields.You will have to use an ODS in this case.
note: Plz check the logic of Change Ind "E". I am not sure of this type.if you want to delete 'E' then pass the value as 'R' to the BW system for documents with 'E' CHANGE_IND.
Hopes i made it clear.
regards
Happy Tony
Points == Thanks -
Help needed writing trigger for deleting records from multipul tables
i am trying to write a trigger which would help me delete the record from 3 different tables
lets say i have table a , b and c
i an trying to write a trigger which would help me delete the same record from table a and c.
drop trigger az_zzz_trigger;
create trigger az_zzz_trigger
before INSERT or UPDATE or DELETE ON az_employ
FOR EACH ROW
BEGIN
IF DELETING then
delete from za_payroll
delete from az_salary_audit
end if;
end;
while executing this trigger all data of table za_payroll is delete.
what should i do so that only the record which i delete from az_employ gets deleted from az_payroll and az_salary_audit872959 wrote:
i am trying to write a trigger which would help me delete the record from 3 different tables
lets say i have table a , b and c
i an trying to write a trigger which would help me delete the same record from table a and c.
drop trigger az_zzz_trigger;
create trigger az_zzz_trigger
before INSERT or UPDATE or DELETE ON az_employ
FOR EACH ROW
BEGIN
IF DELETING then
delete from za_payroll
delete from az_salary_audit
end if;
end;
while executing this trigger all data of table za_payroll is delete.
what should i do so that only the record which i delete from az_employ gets deleted from az_payroll and az_salary_auditutilize appropriate WHERE clause -
PL/SQL procedure for deleting rows
We have to delete rows from a table by initiating parallel processes depending on no of connections, and also variable commit frequency. The procedure has to start by itself in case of failure of 1 or more parallel processes, by identifying the position where it stopped. Please some one help me what would be th elogic needed to write the [rocedure.
Thanks in Advance
Edited by: 864979 on Jun 9, 2011 10:02 PMBe careful of how this is designed and coded. It is very easy to do it horribly wrong, causing contention and problems.
Have a look at DBMS_PARALLE_EXECUTE.
If the package is not available on your Oracle version, then look at {message:id=1534900} for a manual approach. -
Calling Stored Procedure for Multiple records
Hi,
I have an use case where I have more than 2000 item and for every item I need to fetch around 70 more values as out parameters. Also i need to show all thoes values on UI.
So calling SP in loop is a problem as I can see the rendering the values and it's very slow.
Can anyone suggest better way to handle this case?
-AjitHi...
I don't know about the function you have written but...
Procedure will be created like following
Take an example: i want to create a procedure to take only first letter from the city of City column.
For this...
1). Create a physical table manually under the schema folder.
2). Give the name and select Table Type as "Stored Proc".
3). In "Default Initialization String" field, you should write the query saying "select substr(city,1,1) as Col1 from Regions". In query Col1 is the alias name i have given for the new column. (Click OK)
4). So, now this column should be part of the table newly created. So create a physical column under this newly created table with "Col1" name.
5). Double-click the column and specify the data type of that particular column. (This should be done otherwise you can't move it to BMM layer)
6). Now you can add this table to BMM layer by performing necessary joins w/o any errors or warnings. (This would be depending on your business requirement, for this some times you need to add keys also to the procedure to perform the joins and all)
7). By adding it to the presentation layer, in answers you can watch the results..
NOTE:
1). While writing the function names in Stored procedures, DB you are using is important. Because, functions will vary between the DB's.
2). Column name of newly created should match with the name you specified in the procedure as alias.
3). If you are retrieving 'n' no. of columns from the procedure then you need to create 'n' no. of columns manually.
4). For physical columns created manually, you need to specify the data type according to the type of data it's retrieving.
It may helpful to you in achieving your requirement. If not sorry... but i am sure it's helpful to you...
mark as helpful if it's helpful else mark as correct if correct ;)
Thanks & Regards
Kishore Guggilla -
Procedure for creating Recording in LSMW with header data and line item
Hello Friends,
I have to do the Initial Upload of Model Service specification using LSMW ( Recording).
Transaction : ML10
The problem i am facing is that i have been given 2 files one with HEADER data and the other with LINE ITEM(Service data).
Can we use the RECORDING method to upload 2 files?
If not possible how do we proceed.
Thanks and regards
Ashish Naik.Step-by-Step Procedure:
Details of the BAPI used in this scenario:
Business Object: BUS2012
Method: CreateFromData
Details of Message Type and Basic IDoc Type:
Message Type: PORDCR
Basic IDoc Type: PORDCR02
Letu2019s have a look at the BAPI first, before proceeding to the LSMW:
1. Go to Transaction BAPI
2. Click on Search Button
3. Enter the value u201CBUS2012u201D and select u201CObj.type(Technical Object Nameu201D
4. Press ENTER
5. Following screen appears:
6. On the left side of the screen, Expand the u201CPurchaseOrderu201D.
7. Select u201CPurchaseOrderu201D and double-click on the same for details.
Building LSMW using BAPI:
1. Go to Transaction LSMW.
2. Enter the Project, Subproject and Object information and click on CREATE.
3. Enter the descriptions for Project, Subproject and Object as prompted.
4. Now select Settings à IDoc Inbound Processing
5. u201CIDoc Inbound Processingu201D screen appears. Enter the required details as shown below:
6. Click on u201CActivate IDoc Inbound Processingu201D.
7. Click on u201CYesu201D when prompted for u201CActivate IDoc Inbound?u201D
8. Hit on u201CBacku201D to return to the main screen.
9. Click on Continue (F8). Following Screen appears:
10. Select the Step 1 u201CMaintain Object Attributesu201D and select u201CExecuteu201D.
11. Select the radio button u201CBusiness Object Methodu201D and enter the following details:
Business Object: BUS2012
Method: CreateFromData
Hit ENTER
12. Save and click on BACK button. Following information message is displayed.
13. Now select step 2 u201CMaintain Source Structuresu201D and click u201CExecuteu201D.
14. In this step, we need to maintain the source structure. In our example, lets consider the example of a file with 2 structures Head and Item data as shown below:
Click on Create and name the source structure as HEADERDATA. Now select HEADERDATA and click on u201CCreateu201D again to create the child structure. Following popup appears:
Select u201CLower Levelu201D and click on Continue. Enter the Item data structure name.
Click Save and hit BACK button to go to the main screen.
15. Select step 3 u201CMaintain Source Fieldsu201D and hit execute.
16. Enter the fields as shown below:
17. Click SAVE and return to main screen.
18. Select step 4 u201CMaintain Structure Relationsu201D and click Execute.
Select E1PORDCR and click on CREATE RelationShip. Following screen appears:
Select HEADERDATA and hit ENTER
Similarly do the same for the structure E1BPEKKOA, E1BPEKPOC and E1BPPEKET.
Click Save and return to main screen.
19. Select the step u201CMaintain Field Mapping and Conversion Rulesu201D and click on execute. Maintain the Field Mapping as seen below:
20. Select step 7 u201CMaintain Source Filesu201D and provide the link for the test file created. (Create a test file with the same structure as defined earlier).
Save and return to main screen.
21. Select the step u201CAssign Filesu201D and click on Execute.
Assign the file provided to the source structure. Here the same file is provided for both the structures.
Save and return to the main screen.
22. Select the step u201CRead Datau201D and click on Execute.
Click on Execute.
Return to the main screen.
23. Select the step u201CDisplay read datau201D and click on execute.
Click on the structure name to get the field level values.
24. Return to main screen and now select u201CConvert Datau201D.
25. Return to the main screen and select u201CDisplay Converted datau201D.
26. Return to main screen and select u201CStart IDoc generationu201D.
27. Now select the step u201CStart IDoc Processingu201D on the main screen.
28. Return to main screen and click on u201CCreate IDoc overviewu201D. Here the data record and status records of the IDoc could be viewed:
Check this. This may help -
Start routine code for deleting records in different language
Hello,
can someone please specify the exact code to be used in start routine, and whre exactly it needs to be pasted?
this code is needed for master data notifaction type which is loaded for both languages German and English.
german records are to be avoided.
thanks,Ciao Claudio,
this issue about languages selection is an old situation...
The problem is that language selection is not possible, even if you have this field checked for selection !!!
Look at OSS Note 324684...
"If a field of a DataSource - typically with field name 'LANGU' or 'SPRAS' - is assigned to InfoObject '0langu', the field is not provided in the selection fields although the field actually can be selected. In this case, all languages of the language vector active in the BW System are requested by the source system but the language selection cannot be defined in the Scheduler.
A precondition is that the language field of the DataSource in the source system is maintained as selection field. This setting is done in Transaction RSA6 (or RSO2 for customer developments)."
Bye,
Roberto -
Sequence and procedure for updating records
I USED THE FOLLOWING CODE TO UPDATE THE COLUMNS
CURRT_USER_ID,
uPDATED_BY,
UPDATED_DATE
cURRT_USER_IS = SELECT USER FROM DUAL;
UPDATED_BY = CTUT_ID ;
UPDATED_DATE = SYSDATE
pROCEDURE COMPILED FINE AND TRIGGER CREATED FINE
bUT WHEN I UPDATE IT IS NOT UPDATING THE COLUMNS
CREATE OR REPLACE PROCEDURE UPD_CONSTITUENT(
CURRT_USER_ID out varchar2,UPDATED_DATE out DATE,UPDATED_BY out varchar2,CTUT_ID OUT NUMBER)
IS
puser varchar2(20);
pdate date;
pby varchar2(20);
pid number;
x_seq exception;
pragma exception_init(x_seq, -8004);
BEGIN
SELECT USER,SYSDATE INTO puser,pdate from dual;
CURRT_USER_ID := puser;
UPDATED_DATE := Pdate;
UPDATED_BY := ctut_id;
EXCEPTION WHEN x_seq THEN
RAISE_APPLICATION_ERROR(-8004, 'MY_SEQ has run out of numbers!');
END UPD_CONSTITUENT;
CREATE TRIGGER TU_CONSTITUENT
BEFORE INSERT ON K_CONSTITUENT FOR EACH ROW
BEGIN
UPD_CONSTITUENT(:NEW.CURRT_USER_ID,:NEW.UPDATED_DATE,:NEW.UPDATED_BY,:NEW.CTUT_ID);
END TU_CONSTITUENT;IT WORKED FOR ME
i GAVE INSERT INSTEAD OF UPDATE
Maybe you are looking for
-
Excise Invoice created twice for same billing document.
Hi All Excise Invoice ( J1IIN ) has been created twice for same billing document in 1 or 2 cases. How is this possible,if possible what is the config to restrict the same. Thanks in advance Samson
-
G4 Powerbook + 24" LED Display: Compatible?
Is my Powerbook G4 1Mhz compatible with the Apple 24" LED display (#A1267)? If not, what would be the most advanced display I can hook up to my Powerbook without trouble? Thanks, PP
-
I can't log into icloud from my Windows 8 PC, but I can from my Windows XP PC
I had my old Vista PC upgraded to Windows 8. I just tried to log into www.icloud.com, but after entering my username and my password nothing happens. No errors, nor messages. Fortunately, I can remotely log into my work PC which is a Windows XP.
-
Different permissions on separate Airdisk volumes
Hi there. I have a Drobo connected to an 802.11n Airport Extreme which acts as a Media Server. I'm in the process of ripping CDs and DVDs to it and want to try and make the files as secure as possible. I have set up the Drobo with two volumes. One 'S
-
I created a form based on the reports region. Is there any way that I can make the space between form fields on different lines to close to each other - i.e. 0 width between form fields "vertically". I tried to put valign="top" in either reports regi