Wednesday, July 30, 2014

How to get explain plan from the database


How to get explain plan from the database

We would like to get explain plan for a SQL statement. The SQL statement is,

Select * from gl_interface

Execute the following code to generate the explain plan
1
2
3
4
5
EXPLAIN PLAN
SET
STATEMENT_ID = 'ray'
FOR
SELECT * FROM gl_interface;

After executing the previous statement you need to extract the explain plan from the database. Execute the following,

1
2
SELECT *
  FROM TABLE (DBMS_XPLAN.display ('plan_table', 'ray'));

On executing this SQL you will get,



You can now see the explain plan in the output of the query.



Challa.

Query to find the Duplicates in the Table and Delete them.

Use the below Query to find the duplicates in the table :

SELECT *
FROM TABLE_NAME A
WHERE A.ROWID IN
(SELECT MIN(B.ROWID)
FROM TABLE_NAME B
WHERE
A.COLUMN1=B.COLUMN1
GROUP BY B.COLUMN1,B.COLUMN2);

Use the below Query to delete the duplicates in the table :

DELETE
FROM TABLE_NAME A
WHERE A.ROWID IN
(SELECT MIN(B.ROWID)
FROM TABLE_NAME B
WHERE
A.COLUMN1=B.COLUMN1
GROUP BY B.COLUMN1,B.COLUMN2);

Tuesday, July 22, 2014

To find the Nth Record from Comma Separated String

REGEXP_SUBSTR :

SELECT REGEXP_SUBSTR(MYCOL, '[^,]+', 1, 2) AS VAL
FROM
( SELECT 'ORACLE IS A,OCEAN,TRY,TO SWIM,AS MUCH AS,YOU CAN' AS MYCOL FROM DUAL);

O/P :
DOG

to get 4th value just change as below
REGEXP_SUBSTR(MYCOL, '[^,]+', 1, 4)

Related Posts :

Elimination of Special Characters In the String

Challa.

Monday, July 21, 2014

Elimination of Special Characters In the String.

I have come across a situation where I was supposed to eliminate all the special characters
( %$#(@!&)^*_+ ) in the string.

And, here is the way I just sorted everything back using REGEXP_REPLACE function.

Syntax : REGEXP_REPLACE( <Your_String> ,'[^[:alnum:]'' '']', NULL)

You can eliminate the special characters as shown in the below example else you can replace the special characters.The example1 shows to eliminate the special characters and example2 shows to replace the special characters.

Example1:
SELECT REGEXP_REPLACE('@$$My%%Blog&&*()','[^[:alnum:]'' '']', NULL) FROM dual;

O/P :
Myblog

Using TRANSLATE function

Example2:
SELECT translate('@$$My%%Blog&&*()', '[0-9]#@%%$&&!_','[0-9]') FROM dual;

O/P :
MyBlog*()

Related Posts : 

To find the Nth Record from Comma Separated String.

Challa.

Thursday, July 17, 2014

RICE and CEMLI Terminology in Oracle Apps.

I was little confused about what is RICE? and what is CEMLI? since my experience, in Oracle Apps. So i found a good article while browsing which depicts the real time scenario of what is what. And here I post the article which will be useful to you guys too, to make really understandable..

AIM (Applications Implementation Methodology) =>
During packaged ERP(enterprise resource planning) implementations, Clients often have additional requirements apart from the existing (standard) business process, for which they need to create/change theVanila system (Unchanged ERP Implemented system) processes, and its these changes that come under RICE/RICEW components. AIM is the methodology/standards/published guidelines, which Oracle suggests it's Clients to follow while developing RICE/RICEW components for their business requirements.

RICE stands for Reports, Interfaces, Conversions, Enhancements / Extensions.
Sometimes extended to FRICE > F for Forms (or) RICEW > W for Workflows.

Forms/Reports/Workflows :
Create/Change existing forms/reports/workflows available in ERP system to meet the Clients business requirements.

Interfaces :
Linking (Programs) between other systems to ERP system in order to synchronize the data.They can be Manual, Batch or Real-Time. Interfaces can be either outbound or inbound. An outbound interface reads data from Oracle Apps tables and usually creates output files in the third party tool specified format. An inbound interface reads data from flat files (usually) and calls Oracle APIs to upload data into Oracle Apps.

Conversion :
It is converting the data structure and data design of legacy system data to satisfy the customer’s business rules before importing it into Oracle. It is like a one time run of an inbound interface except that the amount of data processed during conversion could be potentially huge since all the required data from the legacy system would be transferred to Oracle.

Enhancements/Extensions :
 In R12 RICE components have been extended to CEMLI components.

CEMLI Stands for Configurations/Customization, Extension, Modification, Localization, and Integration.
  • Configurations : Configure the existing, pre-built application features according to your client's requirement.Changing setups and profile values can be the example of configurations.
  • Customization : Customization means altering/changing the standard objects or creation of custom object to meet client's business need. It may be Extensions or Modifications.
  • Extensions : Extension means creating custom code from scratch, existing objects (views, packages and java classes etc) can be used. It is having different behaviour from seeded one.
  • Modifications : Modifications is enhancing/changing the existing code to meet the client's requirements. It is the modification of seeded behaviour.
  • Localization : It is to define the different legislative support provided by oracle Applications based on country/region/language requirements.
  • Integration : It can be Data Integration or Application Integration, options for these two are Open Interface tables, APIs, EAI(Enterprise Application Integration Tools), BPEL, AQ, EDI etc.
Apart from these there is one more term called Personalization.

Personalization : Tailoring the layout or visibility of page content to meet client requirements.Changing the user interface (UI) look-and-feel, making any field visible/enabled/disabled/mandatory/non mandatory comes under Personalization.For more articles on Forms Personalization click Me :)

Challa.

Friday, July 11, 2014

FNDLOAD to migrate objects between instances.

DOWNLOAD

 

1 – Printer Styles

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afcppstl.lct file_name.ldt STYLE PRINTER_STYLE_NAME="printer style name"

2 – Lookups

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/aflvmlu.lct file_name.ldt FND_LOOKUP_TYPE APPLICATION_SHORT_NAME="FND"
LOOKUP_TYPE="lookup name"

3 – Descriptive Flexfield with all of specific Contexts

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt DESC_FLEX P_LEVEL=COL_ALL:REF_ALL:CTX_ONE:SEG_ALL APPLICATION_SHORT_NAME="FND" DESCRIPTIVE_FLEXFIELD_NAME="desc flex name" P_CONTEXT_CODE="context name"

4 – Key Flexfield Structures

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt KEY_FLEX P_LEVEL=COL_ALL:FQL_ALL:SQL_ALL:STR_ONE:WFP_ALL:SHA_ALL:CVR_ALL:SEG_ALL APPLICATION_SHORT_NAME="FND" ID_FLEX_CODE="key flex code" P_STRUCTURE_CODE="structure name"

5 – Concurrent Programs

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afcpprog.lct file_name.ldt PROGRAM APPLICATION_SHORT_NAME="FND" CONCURRENT_PROGRAM_NAME="concurrent name"

6 – Value Sets

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt VALUE_SET_VALUE FLEX_VALUE_SET_NAME="value set name"

7 – Value Sets with values


FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct file_name.ldt VALUE_SET FLEX_VALUE_SET_NAME="value set name"

8 – Profile Options


FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afscprof.lct file_name.ldt PROFILE PROFILE_NAME="profile option" APPLICATION_SHORT_NAME="FND"

9 – Request Groups

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afcpreqg.lct file_name.ldt REQUEST_GROUP REQUEST_GROUP_NAME="request group" APPLICATION_SHORT_NAME="FND"

10 – Request Sets


FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afcprset.lct file_name.ldt REQ_SET APPLICATION_SHORT_NAME="FND" REQUEST_SET_NAME="request set"

11 – Responsibilities


FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afscursp.lct file_name.ldt FND_RESPONSIBILITY RESP_KEY="responsibility"


12 – Menus


FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $FND_TOP/patch/115/import/afsload.lct file_name.ldt MENU MENU_NAME="menu_name"

13 – Forms Personalization

FNDLOAD apps/$APPS_PWD 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct file_name.ldt FND_FORM_CUSTOM_RULES function_name=FUNCTION_NAME

14 - XML Data Definition and Associated Template Definition ***Doesn't download attachments.

FNDLOAD apps/$APPS_PWD O Y DOWNLOAD $XDO_TOP/patch/115/import/xdotmpl.lct file_name.ldt XDO_DS_DEFINITIONS APPLICATION_SHORT_NAME='FND' DATA_SOURCE_CODE='DATA SOURCE CODE' TMPL_APP_SHORT_NAME='FND' TEMPLATE_CODE='TEMPLATE_CODE'

15 - Workflow Download

WFLOAD apps/$APPS_PWD 0 Y DOWNLOAD file_name.ldt WF_INTERNAL_NAME

UPLOAD

 

UPLOAD command is same for all except replacing the .lct and passing any extra parameters if you want to
pass

FNDLOAD apps/$APPS_PWD 0 Y UPLOAD $FND_TOP/patch/115/import/corresponding.lct upload_file.ldt

Use the condition below to override the existing.

FNDLOAD apps/$APPS_PWD 0 Y UPLOAD $FND_TOP/patch/115/import/corresponding.lct upload_file.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE

Challa.

Submitting concurrent program using FND_REQUEST.SUBMIT_REQUEST along with XML Publisher layout and printer options

FND_REQUEST.SUBMIT_REQUEST is to submit a concurrent program.

Using fnd_request.submit_request,will only submits the program and will not attach any layout or print option. Code below will help you to set XML publisher template/layout along with print option.

*****Add_layout and Add_printer procedures are optional in calling submit_request. Use only if you need to set them.(Based on requirement)

--Layout is submitted to a concurrent request using below procedure.

fnd_request.add_layout (
                    template_appl_name   => 'Template Application',
                    template_code            => 'Template Code',
                    template_language      => 'en', --Use language from template definition
                    template_territory       => 'US', --Use territory from template definition
                    output_format            => 'PDF' --Use output format from template definition
                     );

--Setting printer while submitting concurrent program

fnd_submit.set_print_options (printer      => lc_printer_name
                                             ,style        => 'PDF Publisher'
                                           ,copies       => 1
                                               );

fnd_request.add_printer (
                    printer => printer_name,
                    copies  => 1);

Example1:

DECLARE
   lc_boolean           BOOLEAN;
   ln_request_id       NUMBER;
   lc_printer_name   VARCHAR2 (100);
   lc_boolean1         BOOLEAN;
   lc_boolean2         BOOLEAN;
BEGIN

  -- Initialize Apps 
      fnd_global.apps_initialize (>USER_ID<
                                             ,>RESP_ID<
                                             ,>RESP_APPL_ID<
                                             );

  -- Set printer options
   lc_boolean :=
      fnd_submit.set_print_options (printer      => lc_printer_name
                                                    ,style        => 'PDF Publisher'
                                                  ,copies       => 1
                                                   );

  --Add printer
   lc_boolean1 :=
                fnd_request.add_printer (printer      => lc_printer_name
                                                    ,copies       => 1);
 --Set Layout
  lc_boolean2 :=
               fnd_request.add_layout (
                            template_appl_name   => 'Template Application',
                            template_code            => 'Template Code',
                            template_language       => 'en', --Use language from template definition
                            template_territory        => 'US', --Use territory from template definition
                            output_format             => 'PDF' --Use output format from template definition
                                    );
   ln_request_id :=
      fnd_request.submit_request ('FND',                -- application
                                  'COCN_PGM_SHORT_NAME',-- program short name
                                  '',                   -- description
                                  '',                   -- start time
                                  FALSE,                -- sub request
                                  'Argument1',          -- argument1
                                  'Argument2',          -- argument2
                                  'N',                  -- argument3
                                  NULL,                 -- argument4
                                  NULL,                 -- argument5
                                  'Argument6',          -- argument6
                                  CHR (0)               -- represents end of arguments
                                 );
   COMMIT;

   IF ln_request_id = 0
   THEN
      dbms.output.put_line ('Concurrent request failed to submit');
   END IF;
END;

Example2:

Scheduling/Adding Layout/Delivery Options.

declare
l_conc_id     number;
l_boolean     boolean;
e_add_del     exception;
e_add_layout  exception;
e_set_option  exception;
e_set_repeat  exception;
begin
   -- intialize the apps.
   fnd_global.apps_initialize (<user_id>,<resp_id>,<resp_app_id>);

   -- Adding delivery option to send the request output as email
   l_boolean := fnd_request.add_delivery_option
                   (type => 'E' -- this one to speciy the delivery option as email
                   ,p_argument1 => 'Delivery Option Test' -- subject for the mail
                   ,p_argument2 => 'xyz@ab.bc.uk' -- from address
                   ,p_argument3 => 'rty@ab.bc.uk' -- to address
                   ,p_argument4 => 'klm@ab.ac.uk' -- cc address to be specified here.
                   ,nls_language => ''); -- Optional

   -- Adding Template to the request
   if l_boolean then
      l_boolean := fnd_request.add_layout
                     (template_appl_name => 'XXAK'
                     ,template_code      => 'XX_TEST_FND_REQUEST'
                     ,template_language  => 'en' -- English
                     ,template_territory => null
                     ,output_format      => 'PDF'
                     );
   else
      raise e_add_del;                                              
   end if; 

   if l_boolean then
      l_boolean := fnd_request.set_options ('YES');
   else
      raise e_add_layout;
   end if;

   -- Scheduling the request
   if l_boolean then
      l_boolean :=fnd_request.set_repeat_options
                     (repeat_time     => null--to_char(sysdate,'hh24:mi:ss'),
                     ,repeat_interval => 2   --Applies only when releat_time is null
                     ,repeat_unit     => 'MINUTES'--Applies only when releat_time is null
                     ,repeat_type     => 'START' --Applies only when releat_time is null
                     --,repeat_end_time  =>
                     --,increment_dates  => 'Y'-- Increment the date parameters for next run
                     );
   else
      raise e_set_option;                                                
   end if;
                                  
   if l_boolean then
      l_conc_id := fnd_request.submit_request
                      (application => 'XXAK'
                      ,program     => 'XX_TEST_FND_REQUEST'
                      ,start_time  => null
                      ,sub_request => null
                      ,argument1   => <argument1>
                      ,argument2   => <argument2>
                         );
   else
      raise e_set_repeat;                                             
   end if;
  
   if l_conc_id > 0 then
      dbms_output.put_line('Concurrent Program Id: '||l_conc_id);
   else
      dbms_output.put_line('Error: submit_request');
   end if;
   commit;
exception
   when e_add_del then
      dbms_output.put_line('Error: add_delivery_option');
   when e_add_layout then
      dbms_output.put_line('Error: add_layout');
   when e_set_option then
      dbms_output.put_line('Error: set_options');
   when e_set_repeat then
      dbms_output.put_line('Error: set_repeat_options'); 
   when others then
      dbms_output.put_line('Error: '||sqlerrm);      
end;


Challa.

Monday, July 7, 2014

Calling Stored procedure through Forms Personalization

Steps:

1. Personalize the form
2. Create an action of type “BuiltIn”
3. BuiltIn Type for Action should be “Execute a Procedure”
4. Argument should be as below
=’declare
v_field_value VARCHAR2(200) ;
begin
plsql_package.procedurenameHere ;
end’

or alternately

=’declare
v_field_value VARCHAR2(200) ;
begin
XX_PRC(”’||${item.PO_CONTROL_RULES.OBJECT_CODE_DISPLAYED_VALUE.value}||”’);
end’

Note the syntax, after =, entire declare begin end is within single quote.

Also, there is no semi colon after “end”
You can pass field values as
”’||${item.BLOCKNAME.FIELDNAME.value}||”’

Example:
 
A simple way to understand is the begin end block should be enclosed in single quotes and the fields should be enclosed in double quotes.

=‘begin
test_procedure( “’||:GLOBAL.field||’”,”‘||${item.block.field.value}||’”);
end’

Challa.

Tables for Forms Personalization

Below is the list of tables that are populated when any Forms Personalization is done

FND_FORM_CUSTOM_RULES
FND_FORM_CUSTOM_SCOPES
FND_FORM_CUSTOM_ACTIONS
FND_FORM_CUSTOM_PARAMS
FND_FORM_CUSTOM_PROP_VALUES
FND_FORM_CUSTOM_PROP_LIST

You can use the FNDLOAD utility to move the peronalizations from one instance to another.

Example Synatx shown below to download or upload Form Personalizations.

Download Personalizations

1) FNDLOAD apps/appspwd 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct XX_OEXOEORD.ldt FND_FORM_CUSTOM_RULES form_name=”OEXOEORD”

2) FNDLOAD apps/appspwd 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct XX_OEXOETEL.ldt FND_FORM_CUSTOM_RULES form_name=”OEXOETEL”

Upload Personalizations

1) FNDLOAD apps/appspwd 0 Y UPLOAD $FND_TOP/patch/115/import/affrmcus.lct XX_OEXOEORD.ldt

2) FNDLOAD apps/appspwd 0 Y UPLOAD $FND_TOP/patch/115/import/affrmcus.lct XX_OEXOETEL.ldt

The below script list all the forms in Oracle Applications that have been customized using Forms Personlization:

/* Formatted on 2014/07/17 19:02 (Formatter Plus v4.8.8) */
SELECT   ffv.form_id, ffv.form_name, fat.application_name, ffv.user_form_name,
                 ffv.description "Form Description", ffcr.SEQUENCE,
                 ffcr.description "Personalization Rule Name"
    FROM fnd_form_vl ffv, fnd_form_custom_rules ffcr, fnd_application_tl fat
   WHERE ffv.form_name = ffcr.form_name
     AND    fat.application_id = ffv.application_id
ORDER BY  ffv.form_name, ffcr.SEQUENCE;
Challa.

Forms Personalization.

With the Oracle E-Business Suite release 11.5.10, the Oracle has introduced a mechanism which revolutionizes the way the forms can be customized to fulfill the customer needs. For many years, Oracle Applications has provided a custom library using which the look and behavior of the standard forms can be altered, but the custom library modifications require extensive work on SQL and PL/SQL. In the release 11.5.10, Oracle has provided a simple and easy feature to implement the customer specific requirements without modifying the underlying forms code or CUSTOM library. Although CUSTOM library still can be used for forms customization to implement the complex business logic, the personalization feature provided in the latest release is easy, faster and requires minimum development effort.

Why Forms Personalization?
  • Oracle Supports personalization unlike customization.
  • Personalizations are stored in tables rather than files.
  • Will not have a bigger impact when you upgrade or apply patches to the environment.
  • Can be moved easily through FNDLOAD from one instance to other.
  • Can be restricted at site/responsibility/user level.
  • Easy to disable/enable with click of a button.
  • Personalization stores who columns with which we have the ability to track who created/modified it where as in CUSTOM.PLL we don’t have that ability.
  • Can be applied to new responsibilities/users easily.
  • Can be restricted to a function or form.
What can be implemented through Forms Personalization?

The below can be done using Personalization:
  • Zoom from one form to another.
  • Pass data from one form to another through global variables.
  • Change LOV values dynamically.
  • Enable/Disable/Hide fields dynamically
  • Display user friendly messages when required
  • Launch URL directly from oracle form
  • Execute PL/SQL programs through FORM_DDL package
  • Call custom libraries dynamically
Personalization Tables:
  • FND_FORM_CUSTOM_RULES
  • FND_FORM_CUSTOM_ACTIONS
  • FND_FORM_CUSTOM_SCOPES
  • FND_FORM_CUSTOM_PARAMS
  • FND_FORM_CUSTOM_PROP_LIST
  • FND_FORM_CUSTOM_PROP_VALUES
Invoking the Personalization screen:

The personalization form should be used to implement the custom rules on a specific form. The specific form refers to the desired form on which you want to apply the custom business logic or modify the form behavior.

The personalization form is invoked by…

Menu Navigation: Help > Diagnostics > Custom Code > Personalize

Disable the personalization feature:

It is possible that a change you make completely breaks a form, to the point that it will not even run! Here’s how to recover:
  • On the pulldown menu, choose Help > Diagnostics > Custom Code > Off
  • This will disable all callouts to Forms Personalization
  • Run the form of interest
  • It should run now, because your changes were skipped
  • Invoke the Personalization screen and correct the problem
  • On the pulldown menu, choose Help > Diagnostics > Custom Code > Normal to re-enable processing of Personalizations
Limitations:

Although it is faster than a speeding bullet, it is not able to leap over tall buildings:
  • You can only change what Forms allows at runtime:
  1. Cannot create new items
  2. Cannot move items between canvases
  3. Cannot display an item which is not on a canvas
  4. Cannot set certain properties
  5. Cannot change frames, graphics, boilerplate
  • You can only respond to certain Trigger Events:
  1. WHEN-NEW-FORM-INSTANCE, WHEN-NEW-BLOCK-INSTANCE, WHEN-NEW-RECORD-INSTANCE, WHEN-NEW-ITEM-INSTANCE
  2. WHEN-VALIDATE-RECORD (not in all forms)
  3. Product-specific events
  • May interfere with, or be overridden by, base product code
  • Expected user is an Admin/Developer
  1. Knowledge of Oracle Developer is extremely desirable
  2. Knowledge of PL/SQL, Coding Standards and/or APIs required in some cases
  • Normal rules for customizations apply
  1. Extensive testing in a Test environment is required!
Relationship with CUSTOM library:
  • CUSTOM is a stub library Oracle ships that receives Trigger Events. Customers are free to add any code they like to it.
  • CUSTOM and Form Personalizations drive off the same Trigger Events.
  • Form Personalizations are processed first, then the event is sent to CUSTOM
  • CUSTOM can do more because it has complete access to all PL/SQL and SQL.
  • But for most changes, Form Personalizations is adequate and is significantly simpler. 

Challa.

Friday, July 4, 2014

BI Publisher XDO_TOP - MSword Debugging in Oracle Apps

The easiest way to configure BI Publisher and debug the BI Publisher APIs for MSword template builder.

1. Create a directory on your C: drive called xdo_top
2. Create a sub-directory called temp: C:\xdo_top\temp
    Create a sub-directory called resource: C:\xdo_top\resource
3. Create a xdodebug.cfg file in the resource directory with the following 2 lines:
LogLevel=STATEMENT
LogDir=C:\xdo_top\temp
4. Optionally copy an existing version xdo.cfg file if you need it for barcodes, micr fonts, etc.
Note: You can find this in one of the oracle bi publisher template builder directory's.
5. In MSWord goto the Add-ins menu for BIP, Click on -> tools->options->java options, Add the following: -DXDO_TOP=C:\\xdo_top



Note: The screen shot also has a memory parameter, you do not need the memory option -Xmx256M

6. Restart msword* Not really needed but a good idea

When you start bi publisher and preview a template from MSword the following should happen:

xdo.log should be created under c:\xdo_top\temp.
The log file should contain rich debugging information to help you with your troubleshooting.

When would I need to use debugging?

As an example, let's say you wanted to use the xdo.cfg file to configure a font, but that insolent micr font isn't working in your template. You can review the log to see if it's indeed being pulled in.

Challa.

Deleteing XML Publisher Data Definition and Template from Backend

How often do you create a XML publisher definition with a wrong Codes (Template or Data Definition)? Or you want to change the Code so that it is more meaningful?

Oracle application is not providing any option to delete the data definition and template but here I'm providing a script by which you can delete both from back end. But before running the script you have to take care of two things:

a)Give the proper template code in the variable var_template code of the script because you can't rollback.
b)If you to delete the data definition file with template then make the variable boo_deleteDataDef true unless make it as false.

The reason is that: concurrent program with XML output matches the Short Name with the template Code to find out which XML Publisher template to use for post processing. If you delete this template, the Post Processor cannot find the template, and then give errors.

/* Formatted on 2014/07/04 19:11 (Formatter Plus v4.8.8) */
SET SERVEROUTPUT ON

DECLARE
-- Change the following two parameters
   var_templatecode    VARCHAR2 (100) := 'Order_Details';    -- Template Code
   boo_deletedatadef   BOOLEAN        := TRUE;
                                           -- delete the associated Data Def.
BEGIN
   FOR rs IN (SELECT t1.application_short_name template_app_name,
                     t1.data_source_code,
                     t2.application_short_name def_app_name
                FROM xdo_templates_b t1, xdo_ds_definitions_b t2
               WHERE t1.template_code = var_templatecode
                 AND t1.data_source_code = t2.data_source_code)
   LOOP
      xdo_templates_pkg.delete_row (rs.template_app_name, var_templatecode);

      DELETE FROM xdo_lobs
            WHERE lob_code = var_templatecode
              AND application_short_name = rs.template_app_name
              AND lob_type IN ('TEMPLATE_SOURCE', 'TEMPLATE');

      DELETE FROM xdo_config_values
            WHERE application_short_name = rs.template_app_name
              AND template_code = var_templatecode
              AND data_source_code = rs.data_source_code
              AND config_level = 50;

      DBMS_OUTPUT.put_line (   'Selected template has been '
                            || var_templatecode
                            || ' deleted.'
                           );

      IF boo_deletedatadef
      THEN
         xdo_ds_definitions_pkg.delete_row (rs.def_app_name,
                                            rs.data_source_code
                                           );

         DELETE FROM xdo_lobs
               WHERE lob_code = rs.data_source_code
                 AND application_short_name = rs.def_app_name
                 AND lob_type IN
                        ('XML_SCHEMA', 'DATA_TEMPLATE', 'XML_SAMPLE',
                         'BURSTING_FILE');

         DELETE FROM xdo_config_values
               WHERE application_short_name = rs.def_app_name
                 AND data_source_code = rs.data_source_code
                 AND config_level = 30;

         DBMS_OUTPUT.put_line (   'Selected Data Defintion has been '
                               || rs.data_source_code
                               || ' deleted.'
                              );
      END IF;
   END LOOP;

   COMMIT;
EXCEPTION
   WHEN OTHERS
   THEN
      ROLLBACK;
      DBMS_OUTPUT.put_line (   'Unable to delete XML Publisher Template '
                            || var_templatecode
                           );
      DBMS_OUTPUT.put_line (SUBSTR (SQLERRM, 1, 200));
END;
/

Challa.