Monday, August 12, 2013

Validate email address in Oracle


Until Oracle comes up with an in-built functionality to validate an email address, you can use the following custom stored function. Compile it in the database and pass an email address to see if the email address is VALID, INVALID or UNKNOWN.

For example, if you pass following email addresses, the returning result will be as follow:

   test_mail@gmail.com      -  VALID
   test_mail@gmailcom       -  INVALID
   @gmail.com               -  INVALID
   test.@.com               -  INVALID
   @gmail.                  -  INVALID
   test_mail@gmail.com      -  INVALID
   NULL                     -  UNKNOWN


CREATE OR REPLACE FUNCTION xxcc_validate_email(p_email  IN  VARCHAR2)
   RETURN VARCHAR2

   --===============================================================================
   -- Filename    :  XXCC_VALIDATE_EMAIL_FNC.sql
   ---------------------------------------------------------------------------------
   -- Programmer  :  test_mail
   -- Date        :  24-Jul-2013
   -- Language    :  PL/SQL
   -- Location    :  $XXCC_TOP/install/
   -- Purpose     :  This function validates an email address using PL/SQL
   ---------------------------------------------------------------------------------
   -- Description :
   --    Takes a string (p_email) as an input parameter. Through a series of
   --    validation checks, this function determines whether the email address is
   --    valid or invalid.
   --
   ---------------------------------------------------------------------------------
   -- Rules:
   --    The following rules are based on the article "Characters in the local part
   --    of a mail address" found in:
   --    <http://www.ramindia03.blogspot.com>
   --
   --      1) email cannot be NULL (length of NULL value is undetermined)
   --      2) email has to be minimum 5 characters long
   --      3) email requires at least one '@' and one '.' sign
   --      4) email cannot start or end with '@' sign
   --      5) email cannot end with '.' sign
   --      6) '.' sign cannot be before or after '@' sign
   --      7) double dots '..' are not permitted in an email
   --      8) invalid characters are: ` ~ ! # $ % ^ & * ( ) " | { } [ ] : ; , < > ? \ /
   --         and single quote and space characters
   --      9) domain part must consists of strings
   --     10) email cannot contain two '@' sign
   --
   -- Note:
   --    The returned value from this function is usually used against an email
   --    address, which will be (or is supposed to be) used with UNIX's "mail" command.
   --    Therefore, few more restrictions are applied to this functions.
   --
   ----------------------------------------------------------------------------------------------------
   -- Update History:
   -- Date       Updated By                          Description
   -- ---------  ---------------------------  ---------------------------------------------------------
   -- 24-Jul-13  Authour R  Added test for double 'at' symbol in email.
   --                                         Modified invalid character test to be in a single string.
   -- 12-Aug-13  Authour R  First version.
   --==================================================================================================

IS
   v_at_pos         PLS_INTEGER;                -- position variable for at (@) sign
   v_dot_pos        PLS_INTEGER;                -- position variable for dot (.) sign
   v_length         PLS_INTEGER;                -- holds the length of email

   v_email_ch       VARCHAR2(1);                -- check character in an email
   v_result         VARCHAR2(10)  DEFAULT  'VALID';   -- result variable

BEGIN
   ----------------------------------------------------------
   -- variable assignments
   ----------------------------------------------------------
   v_at_pos     :=  INSTR(p_email, '@', -1);  -- position for last occurrence of '@' sign
   v_dot_pos    :=  INSTR(p_email, '.', -1);  -- position for last occurrence of '.' sign
   v_length     :=  LENGTH(p_email);          -- length of entire email address

   ----------------------------------------------------------
   -- First Round Check:
   --   Rules for invalid email address
   ----------------------------------------------------------
   IF p_email IS NULL            OR   -- email cannot be null
      v_length  < 5              OR   -- email length should be at least 5 characters
      v_at_pos  = 0              OR   -- email requires at least one '@' sign
      v_dot_pos = 0              OR   -- email requires at least one '.' sign
      v_at_pos  = 1              OR   -- email cannot start with '@' sign
      v_dot_pos = v_at_pos - 1   OR   -- dot (.) sign cannot be right before at (@) sign
      v_dot_pos = v_at_pos + 1   OR   -- dot (.) sign cannot be right after at (@) sign
      v_dot_pos = v_length       OR   -- email cannot end with dot '.' sign
      v_at_pos  = v_length       OR   -- email cannot end with at '@' sign
   
      /* double dots are not permitted */
      INSTR(SUBSTR(p_email, 1, (v_at_pos - 1)), '..') > 0 OR
      INSTR(SUBSTR(p_email, v_at_pos + 1), '..')      > 0 OR
   
      /* requires one '.' sign after '@' sign */
      INSTR(SUBSTR(p_email, v_at_pos), '.') = 0           OR
      (INSTR(p_email, '@') > 0 AND INSTR(p_email, '@', INSTR(p_email, '@') + 1) > 0) OR
   
      /* this following code finds out if the domain part is a number or a string */
      UPPER(SUBSTR(p_email, v_at_pos, v_length)) = LOWER(SUBSTR(p_email, v_at_pos, v_length))
   THEN
      v_result := 'INVALID';
   END IF;

   ----------------------------------------------------------
   -- Second Round Check:
   --   Invalid characters should not be in the email address.
   --   Validate using INSTR method
   ----------------------------------------------------------
   FOR i IN 1..v_length
   LOOP
      v_email_ch  :=  SUBSTR(p_email, i, 1);
   
      IF INSTR(' `~!#$%^&*"|(){}[]:;,<>?\/''''', v_email_ch) > 0
      THEN
         v_result := 'INVALID';
         EXIT;
      END IF;
   
   END LOOP;

   RETURN (v_result);

EXCEPTION
   WHEN OTHERS THEN
      RETURN 'UNKNOWN';


END xxcc_validate_email;

Find Oracle Database Version

Run this SQL:
select * from v$version;
or
 select * from product_component_version;
or
SET SERVEROUTPUT ON
EXEC dbms_output.put_line( dbms_db_version.version );
for example
Description of Figure 1-1 follows

If you just want to check the version information of the Oracle database, simply connect and login to the Oracle database with SQL *Plus. Upon login, you will see:


use this below function to get exact database version
   CREATE FUNCTION fn_which_edition RETURN VARCHAR2 IS 

/*
   Purpose: determine which database edition

        MODIFICATION HISTORY
        Person      Date        Comments
        ---------   ------      -------------------------------------------
        Ram A        12-Aug-2013    Initial Build

    */

    -- Banner
    CURSOR c_get_banner
    IS
        SELECT banner
          FROM v$version
         WHERE UPPER(banner) LIKE UPPER('Oracle Database%');

    vrec_banner c_get_banner%ROWTYPE; -- row record
    v_database VARCHAR2(32767); --
BEGIN
    -- Get banner to get edition
    OPEN c_get_banner;
    FETCH c_get_banner INTO vrec_banner;
    CLOSE c_get_banner;

    -- Check for Database type
    IF INSTR( UPPER(vrec_banner.banner), 'EXPRESS') > 0
    THEN
        v_database := 'EXPRESS';
    ELSIF INSTR( UPPER(vrec_banner.banner), 'STANDARD') > 0
    THEN
        v_database := 'STANDARD';
    ELSIF INSTR( UPPER(vrec_banner.banner), 'PERSONAL') > 0
    THEN
        v_database := 'PERSONAL';
    ELSIF INSTR( UPPER(vrec_banner.banner), 'ENTERPRISE') > 0
    THEN
        v_database := 'ENTERPRISE';
    ELSE
        v_database := 'UNKNOWN';
    END IF;

    RETURN v_database;
EXCEPTION
    WHEN OTHERS
    THEN
        RETURN 'ERROR:' || SQLERRM(SQLCODE);
END fn_which_edition; -- function fn_which_edition
/

Tuesday, August 6, 2013

Oracle Forms – Remove List Element from List Item

This one is a little wily, so John suggested we post it. Removing a label/value from a drop down should be super-simple. In Oracle Forms, however, you ought to know the shortcut key:
CTRL + SHIFT + ,


Why that combination? Well, it might look strange in writing, but when you type it, you will notice that “SHIFT + ,” makes a less-than symbol “<“. I won’t go as far as to say this is completely intuitive, but I hope this helps someone.

Wednesday, July 24, 2013

Query to find Application Short Name of a module

The following query lists all the applications related information. This query can be used to find theAPPLICATION_SHORT_NAME of a module (eg. Payables, Receivables, Order Management, etc.) that are often used for downloading FNDLOAD LDT files, adding responsibility to a user and many more.

You can uncomment the FAT.APPLICATION_NAME condition (very bottom line of the query) to learn about a particular module. In this case, I used "Payables".


-------------------------------------------------------------------------------
-- Query to find all APPLICATION (module) information
-------------------------------------------------------------------------------
SELECT fa.application_id           "Application ID",
       fat.application_name        "Application Name",
       fa.application_short_name   "Application Short Name",
       fa.basepath                 "Basepath"
  FROM fnd_application     fa,
       fnd_application_tl  fat
 WHERE fa.application_id = fat.application_id
   AND fat.language      = USERENV('LANG')
   -- AND fat.application_name = 'Payables'  -- <change it>
 ORDER BY fat.application_name;

Oracle Applications Shortcut Keys

Function
Hot Key
Clear Field
F5
Clear Form
F8
Clear Record
F6
Clear Block
F7
Commit / Save
Ctrl-S
Delete Record
Ctrl-↑
Down
Duplicate Field
Shift-F5
Duplicate Record
Shift-F6
Edit
Ctrl-E
Enter Query
F11
Execute Query
Ctrl-F11
Exit
F4
Insert Record
Ctrl-↓
List of Values
Ctrl-L
Next Block
Shift-PgDn
Next Record
Previous Block
Shift-PgUp
Previous Field
Shift-Tab
Previous Record
Next Field
Tab
Print
Ctrl-P
Scroll Down
PgDn
Scroll Up
PgUp
Show Keys
Ctrl-K
Up

Oracle R12 Application Modules

Taken from Oracle eBusiness Suite Electronic Technical Reference Manual (eTRM), following are the application modules in Oracle R12.


AD  - Applications DBA
AHL - Complex Maintenance Repair and Overhaul
AK  - Common Modules-AK
ALR - Alert
AME - Approvals Management
AMS - Marketing
AMV - Marketing Encyclopedia System
AMW - Internal Controls Manager
AN  - Sales Analysis
AP  - Payables
AR  - Receivables
AS  - Sales Foundation
ASF - Sales Online
ASG - CRM Gateway for Mobile Devices
ASL - Sales Offline
ASN - Sales
ASO - Order Capture
ASP - Oracle Sales for Handhelds
AST - TeleSales
AU  - Application Utilities
AX  - Global Accounting Engine
AZ  - Application Implementation
BEN - Advanced Benefits
BIE - eCommerce Intelligence
BIL - Sales Intelligence
BIM - Marketing Intelligence
BIN - Communications Intelligence
BIS - Applications BIS
BIV - Service Intelligence
BIX - Interaction Center Intelligence
BIY - Systems Intelligence
BLC - Utility Billing
BNE - Web Applications Desktop Integrator
BOM - Bills of Material
BSC - Balanced Scorecard
CCT - Telephony Manager
CDR - Oracle Clinical Data Repository
CE - Cash Management
CHV - Supplier Scheduling
CLA - APAC Consulting Localizations
CLE - EMEA Consulting Localizations
CLJ - Japan Consulting Localizations
CLL - LAD Consulting Localizations
CLN - Supply Chain Trading Connector for RosettaNet
CN  - Incentive Compensation
CRP - Capacity
CS  - Service
CSC - Customer Care
CSD - Depot Repair
CSE - Asset Tracking
CSF - Field Service
CSI - Install Base
CSL - Field Service/Laptop
CSM - Field Service/Palm
CSN - Call Center
CSP - Spares Management
CSR - Scheduler
CST - Cost Management
CTB - Clinical Transaction Base
CUA - Capital Resource Logistics - Assets
CUC - Revenue Accounting
CUF - Capital Resource Logistics - Financials
CUG - Citizen Interaction Center
CUI - Network Logistics - Inventory
CUP - Network Logistics - Purchasing
CUR - Mass Market Receivables for Comms
CUS - Network Logistics
CZ  - Configurator
DDD - CADView-3D
DDR - Demand Signal Repository
DNA - Development
DOM - Document Managment and Collaboration
DPP - Oracle Price Protection
DT  - DateTrack
EAM - Enterprise Asset Management
EC  - e-Commerce Gateway
ECX - XML Gateway
EDR - E-Records
EGO - Advanced Product Catalog
EMS - Environment Management System
ENG - Engineering
ENI - Product Intelligence
EVM - Value Based Management
FEM - Enterprise Performance Foundation
FF  - FastFormula
FII - Financial Intelligence
FLM - Flow Manufacturing
FND - Application Object Library
FPA - Project Portfolio Analysis
FRM - Report Manager
FTE - Transportation Execution
FTP - Transfer Pricing
FUN - Financials Common Modules
FV  - Federal Financials
GCS - Financial Consolidation Hub
GHR - US Federal Human Resources
GL  - General Ledger
GMA - Process Manufacturing Systems
GMD - Process Manufacturing Product Development
GME - Process Manufacturing Process Execution
GMF - Process Manufacturing Financials
GMI - Process Manufacturing Inventory
GML - Process Manufacturing Logistics
GMO - Manufacturing Execution System for Process Manufacturing
GMP - Process Manufacturing Process Planning
GMS - Grants Accounting
GMW - Process Manufacturing Portal
GNI - Genealogy Intelligence
GR  - Process Manufacturing Regulatory Management
HCA - Healthcare
HCC - iHCConnect
HCN - iHCIntegrate
HCP - Healthcare Intelligence
HCT - Healthcare Terminology Server
HRI - Human Resources Intelligence
HXC - Time and Labor Engine
HXT - Time and Labor
IA  - iAssets
IAM - Digital Asset Management
IBC - Content Manager
IBE - iStore
IBP - Bill Presentment & Payment
IBT - iAuction
IBU - iSupport
IBW - Oracle Web Analytics
IBY - Payments
ICX - Oracle iProcurement
IEB - Interaction Blending
IEC - Advanced Outbound Telephony
IEM - Email Center
IEO - Interaction Center Technology
IEP - Predictive
IES - Scripting
IET - Call Center Connectors
IEU - Universal Work Queue
IEV - IVR Integrator
IEX - Collections
IGC - Contract Commitment
IGF - Financial Aid
IGI - Public Sector Financials International
IGS - Student System
IGW - Grants Proposal
IMC - Customers Online
INL - Oracle Landed Cost Management
INV - Inventory
IPA - Capital Resource Logistics - Projects
IPM - Oracle Imaging Process Management
IRC - iRecruitment
ISC - Supply Chain Intelligence
ISX - iSettlement
ITA - Information Technology Audit
ITG - Internet Procurement Enterprise Connector
IZU - Oracle E-Business Suite Diagnostics
JA  - Asia/Pacific Localizations
JE  - European Localizations
JG  - Regional Localizations
JL  - Latin America Localizations
JMF - Supply Chain Localizations
JTF - CRM Foundation
JTM - Mobile Application Foundation
JTS - CRM Self Service Administration
LNS - Loans
MFG - Manufacturing
MIA - Mobile Applications for Inventory Management
MIV - Media Interactive
MQA - Mobile Quality Applications
MRP - Master Scheduling/MRP
MSC - Advanced Supply Chain Planning
MSD - Demand Planning
MSO - Constraint Based Optimization
MSR - Inventory Optimization
MST - Transportation Planning
MTH - Oracle Manufacturing Operations Center
MWA - Mobile Applications
OAM - Oracle Applications Manager
ODQ - Data Query
OE  - Order Entry
OFA - Assets
OKC - Contracts Core
OKE - Project Contracts
OKI - Contracts Intelligence
OKL - Leasing and Finance Management
OKS - Service Contracts
OKT - Royalty Management
OKX - Contracts Integration
ONT - Order Management
OPI - Operations Intelligence
OTA - Learning Management
OUC - University Curriculum
OZF - Trade Management
PA  - Projects
PAY - Payroll
PBR - Budgeting and Planning
PER - Human Resources
PFT - Oracle Profitability Manager
PJI - Project Intelligence
PJM - Project Manufacturing
PMI - Process Manufacturing Intelligence
PN  - Property Manager
PO  - Purchasing
POA - Purchasing Intelligence
POM - Exchange
PON - Sourcing
POS - iSupplier Portal
PQH - Public Sector HR
PQP - Public Sector Payroll
PRP - Proposals
PSA - Public Sector Financials
PSB - Public Sector Budgeting
PSP - Labor Distribution
PSR - Public Sector Receivables
PTX - Patch Tracking System
PV  - Partner Management
QA  - Quality
QOT - Quoting
QP  - Advanced Pricing
QPR - Oracle Deal Management
QRM - Risk Management
RG  - Application Report Generator
RLM - Release Management
RMG - Risk Manager
RRC - Retail Core
RRS - Site Management
SHT - Applications Shared Technology
SSP - SSP
SYSADMIN - System Administration
VEA - Automotive
WIP - Work in Process
WMA - Manufacturing Mobile Applications
WMS - Warehouse Management
WPS - Manufacturing Scheduling
WSH - Shipping Execution
WSM - Shop Floor Management
XDO - XML Publisher
XDP - Provisioning
XLA - Subledger Accounting
XLE - Legal Entity Configurator
XNA - Service Assurance for Communications
XNB - Oracle Telecommunications Billing Integrator
XNP - Number Portability
XNT - TeleBusiness for Telecom/Utilities
XTR - Treasury
ZFA - Financial Analyzer
ZPB - Enterprise Planning and Budgeting
ZSA - Sales Analyzer
ZX  - E-Business Tax