function to check the alphanumeric string of pan card

for example a pan card number ' * AAFCQ4563U *'

I wan to create a function that checks the first 5 digits as capital alphabets and total length of the string is 10.

Published by: arnaud August 2, 2011 22:45

Hi Arnaud,.

As already mentioned by Barend, you should always put the version number that you are using. You can use the REGEXP_LIKE expression to get the desired result. The TANK contains also the first 5 digits as the alphabets, nest 4 numbers and the last one like alphabet still once, then you should check the chain rest as well.

You can try. It works fine on Oracle 10 g and Oracle 11 g version 10.2.0.4 and 11.2.0.1.

CREATE OR REPLACE FUNCTION validate_pan_num (pan IN VARCHAR2)
   RETURN VARCHAR2
AS
BEGIN
   IF (REGEXP_LIKE (pan, '[A-Z]{5}[0-9]{4}[A-Z]{1}') AND LENGTH (pan) = 10)
   THEN
      RETURN 'true';
   ELSE
      RETURN 'false';
   END IF;
END;

Kind regards
Ankit

Tags: Database

Similar Questions

  • Model maching class of regular Expression to validate the alphanumeric string

    Hello
    MY version of DB is Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production 64-bit

    I wanted to use the model maching given by oracle classes to check whether a given input string is alphanumeric.

    Documentation Oracle 10 g said about classes like [: digit:], [: alnum:] and many others.

    http://www.DBA-Oracle.com/t_regular_expressions.htm

    However these classes seems not work with my version of DB.

    Can someone tell me the DB version in which these classes work?

    Here is the code I use to validate an input string.
    SQL> CREATE OR REPLACE FUNCTION fn_is_alphanumeric
      2  (
      3     pi_value             IN       VARCHAR2
      4  )
      5  RETURN VARCHAR2
      6  IS
      7     lv_length   NUMBER;
      8  BEGIN
      9     lv_length := length(pi_value);
     10     IF ( REGEXP_LIKE(pi_value,'[:alnum:]{'||lv_length||'}')) THEN
     11        RETURN 'TRUE';
     12     ELSE
     13        RETURN 'FALSE';
     14     END IF;
     15  END fn_is_alphanumeric;
     16  /
    
    Function created.
    
    SQL> 
    SQL> 
    SQL> SELECT fn_is_alphanumeric('abc123') alpha FROM DUAL;
    
    ALPHA
    --------------------------------------------------------------------------------
    FALSE
    
    SQL> 
    SQL> 
    SQL> CREATE OR REPLACE FUNCTION fn_is_alphanumeric
      2  (
      3     pi_value             IN       VARCHAR2
      4  )
      5  RETURN VARCHAR2
      6  IS
      7     lv_length   NUMBER;
      8  BEGIN
      9     lv_length := length(pi_value);
     10     IF ( REGEXP_LIKE(pi_value,'[A-z0-9]{'||lv_length||'}')) THEN
     11        RETURN 'TRUE';
     12     ELSE
     13        RETURN 'FALSE';
     14     END IF;
     15  END fn_is_alphanumeric;
     16  /
    
    Function created.
    
    SQL> SELECT fn_is_alphanumeric('abc123') alpha FROM DUAL;
    
    ALPHA
    --------------------------------------------------------------------------------
    TRUE

    Arun Kr Gupta says:
    Hi knani
    I need to check whether the input string is alphanumeric.

    That's why "ABC" all entries as '1234', '123ABc', must return true.

    Also can the alphanumeric string contains characters that are available on the keyboard which can be seized of it.

    Concerning
    Arun

    Published by: Arun Gupta of Kr on October 18, 2010 11:46

    I just read your requirement "all printable characters.

    Try:

    select regexp_like('string','^[[:print:]]$') from dual
    

    to get only the records that have only printable characters.

  • How to get the query of the region "PL/SQL function body returns the query string"?

    Hello

    is it possible to get the query string from the region of type "PL/SQL function body returns the query string"?

    I can get the definition of the region as a PL/SQL procedure, but I am interested in the returned query. I tried to write something like

    < pre > v_return_query: = «...» » ;
    : P49_QUERY: = v_return_query;
    Return v_return_query; < / pre >

    to save the return on hidden item P49_QUERY string, but it does not work. I get the error message: ERR-1002 cannot find the item for the "P49_QUERY" element ID in the application '4000 '.

    Kind regards
    Przemek

    If you need to make reference to a page element in the block then you can use this type of control to avoid having to use generic column names:

    if apex_application.get_current_flow_sgid(:APP_ID) = apex_application.get_sgid then-- runtime  :P9_SQL := vSQL;else-- design time  null;end if;
    

    But if all you want to do is capture the SQL debugging you can take all the references element in the block and use the insert statement (in a debug table) as I showed earlier.

    Scott

  • How do I check the particluar string in the xml data

    Dear oracle Experts.
    I'm using the following oracle database.

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Linux: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    I have a following xml data...
    p_msg_in CLOB: =.
    < DATA >
    < FLD FNR = DTE = '26 SEP 12' "ZZ0584" SRC = "DXB" OF the "DAC" = / >
    < AAA LBP = ETK '22334455' = ' 1234567/4' ACT = "123" / >
    < AAA LBP = ETK "223344" = "2345678/1" / >
    < AAA LBP = ETK "223344" = ' 1/123456' ACT = "345" / >
    < / DATA >

    then im go get the header like this information...

    v_msg_xml: = xmltype (p_msg_in);

    I'm IN multicur (v_msg_xml, ' / DATA/FLD ') LOOP
    V_1: = i.xml.extract('//@FNR').getstringval ();
    v_4: = to_date(i.xml.extract('//@DTE').getstringval(),'DDMONYY');
    v_5: = i.xml.extract('//@SRC').getstringval ();
    v_6: = i.xml.extract('//@DES').getstringval ();
    END LOOP;

    After that, I need all the real records one by one, use it for a loop in a loop. Here for each iteration, I should check that a string of characters (for example law) is there or not. in the example above, 1.3 records have value of law in it. Well, I need to check something like that. If instr ("< AAA LBP = ETK"223344 "=" 123456/1 "ACT =" 345 "/ > ',' law") > 0 before performing the step below.
    How to get there.
    I appreciate your help.
    Thank you.
    C IN multicur (v_msg_xml, ' / DATA/AAA ') LOOP
    v_7: = c.xml.extract('//@LBP').getstringval ();
    v_8: = c.xml.extract('//@ETK').getstringval ();

    If I understood corrrectly you must give the LBP and values ETK tags AAA who attribute the Act. If so, all you need is:

    declare
        p_msg_in CLOB :=
    '
    
    
    
    
    ';
        v_msg_xml xmltype;
        cursor v_cur
          is
            select  lbp,
                    etk
              from  xmltable(
                             '/DATA/AAA[@ACT]'
                             passing v_msg_xml
                             columns
                               lbp varchar2(10) path '@LBP',
                               etk varchar2(10) path '@ETK'
                            );
    begin
        v_msg_xml := xmltype(p_msg_in);
        for v_rec in v_cur loop
          dbms_output.put_line('LBP = "' || v_rec.lbp || '" ETK = "' || v_rec.etk || '"');
        end loop;
    end;
    /
    LBP = "22334455" ETK = "1234567/4"
    LBP = "223344" ETK = "123456/1"
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    SY.

  • How can blackBerry smartphones, I check the free memory on my card?

    I'm getting occasional "messages from memory", but I don't know that I have a lot of memory on my 2 GB SD card.

    In the management of media cards (or other) it is said: Total memory 1.8 GB free memory 1.8 GB, which is also difficult to believe because I have 2-3 fairly large programs installed, and a handful of photos, so the part of the memory should be used?

    Advice appreciated!

    Thank you!

    S.

    First thing? Check the file without Options > status, what is the number to the free file?

    Now, remove the battery from your device, hold a minute, replace, and restart. What is now the free file?

    Read this: http://www.blackberryforums.com/general-blackberry-discussion/116396-managing-your-bb-memory-lost-ca...

    And this: http://www.blackberryforums.com/general-blackberry-discussion/112029-losing-call-logs-sms-emails-opt...

    Other links to read:
    http://www.BlackBerry.com/BTSC/search.do?cmd=displayKC&docType=kc&externalId=KB15345&sliceId=SAL_Pub...
    http://www.BlackBerry.com/BTSC/search.do?cmd=displayKC&docType=kc&externalId=KB14320&sliceId=SAL_Pub...
    http://www.BlackBerry.com/BTSC/dynamickc.do?externalId=KB14213&sliceId=SAL_Public&command=show&forwa...

  • Save the alphanumeric string value

    Hello!
    How to save a value to a variable so that I can use it in the future? I have a string of output of a case structure proposed by an OK botton. I want to save the string value when I press the ok botton...
    Thanks in advance
    GM

    Just write the string in a text file.  When you want to use it later, to read the text file.

  • Laptop HP Stream - 11-d010wm: having to check the compatibility of a MicroSD card with my data flow specifications before buying the card

    A SanDisk Ultra 16 GB UHS-I/class 10 Micro SDHC memory is not compatible with a laptop HP of Stream - 11-d010wm (ENERGY STAR)?  I have a couple of Micro SD cards, but they are getting older and being not recognized when I put them in the card slot reader, so I guess that they are not compatible.  I'm looking to buy a new SD card, but not to run into the same problem, so want to check compatibility before you buy... any help would be appreciated.  Thank you.

    You can also consult the many Amazon comments and answered questions for the 11 waterways, as some say the real SD card they bought (although most seem to just mention 'micro SD' so I really think that everything you buy is going to work).  I can't explain why the 2 you have now are not unless they received a different kind of formatting.

    Ah wait however, this review has reported problems with the three different SanDisk class 10 cards, maybe you can search through the comments and find some that work.

  • The Windows XP Explorer crash when checking the USB SD OEM-builtin card reader properties

    Hello, people.

    It's my only known PC malfunction, and initially, it worked without problem. The question began at a time not very long before a recent update failure. The problem is related to the card reader SD OEM-builtin of the Pavilion. Windows XP is unable to connect to this player when my 4 GB SDHC card is slipped into the SD card reader, an error box quote as 'due to an error IO peripheral."  and somehow this blocks / crashes Windows explore (IE no.not) with the 4 GB card in drive F:-SD reader.  But Windows and the reader work very well when my 32 MB SDHC card reading. Both the 4 GB and 32 MB cards work fine in my Canon Power Shot and I can download the contents of the card of 4 GB (JPEG format) via a mini-USB cable for the camera as always, but burning the battery juice in the batteries in the camera. I'd rather take the camera SDHC card and empty its JPEG files in the SD drive. I don't think that it is able, barely used player until three or four months ago. I'll also post this question to the Canon forum and maybe HP forum, but I would like to have some ideas as well on the side of Windows.

    It occurs to me, I don't know how many contacts on the card is active in dealing with the 32 MB. I expect that the 4 GB card should use almost all of the pins; I was wondering if a unused pin in size of 32 MB can be failed do contact and this could corrupt the ease of use of the 4 GB card.

    FYI - my system is HP Pavilion a1020n, five years old. It includes the processor Intel P4 CPU, has 130 GB free on the system partition, and has been upgraded from two years to 2 GB RAM DDR2 PC2 - 4200. OS is Win XP Professional x 86 SP3 with .net all Frameworks 1.1, 2.0, 3.0, 3.5, 4 customer and extended 4, IE 8.00.6001.18702, most Silverlight 4.0.50917.0 to patched. All the .NET Frameworks are patched, except that the last .NET two patches for the version 2.0 and 3.5, KB2418241 and KB2416473, both failed several trying to install, and I'm looking for help with that in a posted question, but if you think of these malf are linked, please let me know.

    Any suggestions on Win Explorer and the card 4 GB SDHC, anybody?

    It's my only known PC malfunction...

    Given your other two sons, which does not seem to be the case:

    CF. http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/6e4db953-8811-438c-bffe-0ca401729b57

    CF. http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/79b90924-e2b3-4bff-b854-596632cdcef6

    Please answer all the questions of diagnostic following by number in your very next answer (no need to quote this post):

    1. when (date approximately) installed WinXP SP3?

    2. what application or antivirus security suite is installed and your current subscription?  What anti-spyware (other than Defender) applications?  What third-party firewall (if applicable)?

    3A give Norton or McAfee application already installed on this machine?

    4. do you have a Norton or McAfee free trial come preinstalled on the computer when you bought it? (No matter if you have never used or activated).

    5. have you already had the opportunity to do a Repair Installation or a clean installation of Windows XP for some reason any?

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • Help finishing a function which checks a table

    Hi guys,.

    I need help finishing a function that checks the 6 items (indiciesOfInterestShape) in a table dynamically updated (productCode) for two types of values. the number 0 or any number between 1 and 8.

    I need the result of this function to update the variable finalNumber to a number between 0 and 6.

    If a 0 is found in all 6 clues that it will result in the final number type argument no increase.

    If a number between 1-8 is located in one of the 6 index then the final number increases by 1. And because there are only 6 clues to check the maximum number only will never be 6.

    That's what I have so far

    // indicies that are dynamically updated           4        7      10     13     16     19
    public static var productCode:Array = [C,A,1,A,1,A,A,1,A,A,0,0,A,0,0,A,0,0,A,0,0,A]
    
    public static var indiciesOfInterestShape:Array = [4, 7, 10, 13, 16, 19];
    public static var finalNumber:int = new int;
    
    public static function countShapes(productCode:Array, indiciesOfInterestShape:Array){
        for (var i:int = 0; i < indiciesOfInterestShape.length; i++){
            var indexTolookAt:int = indiciesOfInterestShape[i];
            var item:String = productCode[indexTolookAt];
            if (item == 0){
                "add zero to finalNumber"     //help needed here changing the finalNumber
                }
            else{
                "add 1 to final number"        //help needed here changing the finalNumber
                }
            }
    }
    

    Something to keep in mind, if a certain product code adds 1 to the final number index (as 1-8), but is then changed dynamically to 0, I need the number back down by 1.

    Hope this has meaning and that someone could point me in the right direction at best.

    Thanks in advance!

    // indicies that are dynamically updated           4        7      10     13     16     19
    public static var productCode:Array = [C,A,1,A,1,A,A,1,A,A,0,0,A,0,0,A,0,0,A,0,0,A]
    public static var indiciesOfInterestShape:Array = [4, 7, 10, 13, 16, 19];

    public static var finalNumber:int = 0;

    finalNumber =countShapes(productCode, indiciesOfInterestShape);

    public static function countShapes(productCode:Array, indiciesOfInterestShape:Array):int {

        var finalNumber:int = 0;
        for (var i:int = 0; i < indiciesOfInterestShape.length; i++){
            var indexTolookAt:int = indiciesOfInterestShape[i];
            var item:int= productCode[indexTolookAt];

            if (item != 0){
                finalNumber++;
            }
        }

         return finalNumber;
    }


  • To check the State exists query

    Hello

    I have a query where I use is the function to check the weather dates fall between the dates, something like this

    Select 1 from T1 a

    where there are

    (select 1 from T2 b where a.col_1 between b.col_1 and b.col_2

    and a.col_2 between b.col_1 and b.col_2);

    I need to check if the a.col_2 is sysdate, then check only a.col_1 between b.col_1 and b.col_2 else check

    a.col_1 between b.col_1 and b.col_2

    and a.col_2 between b.col_1 and b.col_2

    SQL > select * from T2 a

    2 where exists (select 1 from T1 b where a.start_Date between b.start_date and b.end_Date

    3 and (a.end_date between b.start_date and b.end_Date or trunc (a.end_date) = trunc (sysdate)));

    START_DATE END_DATE

    ----------- -----------

    8/22/2000-7/2/2007

    7/3/2007-8/11/2008

    8/18/2008 7/10/2015

  • (Loader class AS3) How to check the charge of failure?

    Hi everyone, I used Loader class to load a JPEG file in my Flash movie during execution.

    my_loader.contentLoaderInfo.addEventListener (Event.COMPLETE, startListener);

    my_loader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESS, progressListener);

    I am only able to check the completed event and ongoing events. Is there a function to check the charge fail? I want my flash movie to show a textbox error pop when the class Loader is unable to find the JPEG file.

    my_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
    
    function ioErrorHandler(event:IOErrorEvent):void {
                trace("ioErrorHandler: " + event);
    }
    
  • Error in connection for the first time, then it works after that (with the same string)

    I have a problem of connection error strange that a "OracleConnection.ConnectionString is not valid" with my program ASP.net/c#, but when I try the page again once it works after that.
    I create the connection string in the code and then pass it a bit like this:

    * private readonly OracleConnection conn = new OracleConnection (oradb); variable in class *.

    * / / in the Page_Load method *.
    _oradb = "password =" + oraPassword + ";". " User ID =' + oraUserName + '; Data source = mydb; » « ;" *
    _conn. Open(); *


    User/login name are also generated and inserted in the connection string and when you debug checked the connection string and it's exactly the same every time. It is as if the connection is interrupted and the first time, it attempts to restore, it gives the error, but then it opens the connection after that and failed again in the same window.
    Any ideas what this might be caused by? I close the connection to another method, after all I want to be the DB and written on the screen.

    The web server is IIS, is the version of .NET 3.5 and the library referenced Oracle is Oracle.DataAccess.dll. In addition, the DB version is 10.2.0.4. Don't know if everything what is necessary, but I thought I'd throw out there, just in case.

    Edited by: psaleh may 24, 2010 23:37

    When you create here of the OracleConnection object.

    * private readonly OracleConnection conn = new OracleConnection (oradb); variable in class *.

    _oradb might be empty or invalid during the first.

    Instead, try this-

    * private readonly OracleConnection _conn = new OracleConnection(); variable in class *.

    * / / in the Page_Load method *.
    _conn. ConnectionString = "password =" + oraPassword + ";". " User ID =' + oraUserName + '; Data source = mydb; » « ;" *
    _conn. Open(); *

    There is a separate forum for the ODP. NET-
    http://forums.Oracle.com/Forums/Forum.jspa?forumid=146

  • To check the weather SD card is inserted or not.

    Hello

    Needs in my application to verify the presence of the sd card in the phone.

    can you please let me know, which api to use or all methods to check the presence of an sd card into the blackberry phone.

    Kind regards.

    It can be done...

    Check out this KB article...

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/1295814/How_To...

    See you soon...

  • Check the status of voice on the 4.0 unit cards (3)

    Hello

    I would like to know how can I test if the voice cards are correctly installed and setup of the unit has completed the installation of the voice card successfully?

    As far as I know is to open the DCM program and check the status of each voice card. Are there other means or tools to check voice cards in more detail?

    Moreover, I found the in Device Manager, the server could only recognize the cards as the unknown PCI devices. Is this normal?

    Thank you

    ---

    Ray

    DCM confirms that the card has been properly installed.

    Regarding the unknown PCI error, it is normal.

    "Note that if you view a voice card using the Windows Device Manager, the card can be displayed as an unknown device PCI with a warning indicating that the drivers for the device are not installed. A found new hardware wizard may also appear for each card during installation or to restart the computer in Cisco Unity. These conditions are the two expected behavior and do not indicate an error or a condition requiring action. You can disable the hardware detected Wizard to prevent it from appearing at restarting the Cisco Unity computer."

    http://www.Cisco.com/en/us/products/SW/voicesw/ps2237/products_installation_guide_chapter09186a00801ba4b6.html#1505050

    H. M.

  • How to check the value of a string is numeric, alphanumeric or characters?

    Hi all
    I have a task to validate an employee ID, assume that the employee Id is E121212. Now according to the validation rule, I need to check "the first letter of the employee Id is a character and rest are numbers." How can I do this? Please answer.



    Thanks and greetings
    Marie Laurence

    Hello

    You can opt for regexp_like in this case. See the code below

    with data as (
      select 'E121212' s from dual union all
      select '121212' from dual union all
      select 'EE121212' from dual union all
      select 'EE1212EE' from dual union all
      select 'É121212' s from dual
    )
    
    select
    *
    from data
    where
    regexp_like (s, '^[A-Z]\d+$')
    
    S
    E121212 
    

    ^ [A-Z] means that, at the beginnign (^), should be only between A - Z characters, uppercase. If you want to add lowercase letters, you can easily replace it [A-Za-z]. \d is a symbol for the numbers and + means it must complete at least one or more of her. $ means the end, so he stayed there until the end but nothig figures.

    If yoou want characters as allowed, you can change the character class to [: alpha:]

    select
    *
    from data
    where
    regexp_like (s, '^[[:alpha:]]\d+$')
    
    S
    E121212
    É121212 
    

    concerning

    Published by: chris227 on 26.07.2012 00:53
    fix

Maybe you are looking for

  • Cannot get past Boot Screen manufacturer

    I can't get my g62-149wm to go beyond the HP screen. I tried to hit escape to go into the boot options and f10 to enter the BIOS but nothing happens. It is blocked here. Anyone have any ideas?

  • I have a virus on my computer?

    My Windows Vista computer recently started acting funny. First he deleted all the links that I put in my Start menu. Instead, he had links to recently used programs. Then the URL in Windows Explorer bar was just empty. It seems that the text had turn

  • Over the isue of load

    Is there any isue when overloading my Z5? Because I left my Xperia load all night! Please tell me what to do how to do long battery! Thanks in advance!

  • Monitor issue - gray area in the middle of the display indicating "AutoConfig please wait."

    Original title: monitor question Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: I have an Acer monitor with my computer.  A gray box appears frequently in the middle of the display ind

  • Version of DEV BB10 has Simulator?

    I updated a game of mine to make it compatible with BB10 previously only moving on PlayBook. I was informed that it was rejected because only under OS 10.0.9. 1675 is not make properly. I can not find anywhere the image of this Simulator version. The