Simple PL/SQL function to test if a string is a number

前端 未结 1 1228
攒了一身酷
攒了一身酷 2020-12-21 07:23

I\'m experienced with T-SQL from SQL Server, but have recently begun working on a project utilizing an Oracle database (11g) and am having some issues writing what seems to

相关标签:
1条回答
  • 2020-12-21 07:24

    Return a SQL datatype, e.g. VARCHAR2. Also, I'd recommend against using WHEN OTHERS. Also, you don't need a query on dual:

    create or replace 
    function IS_NUMBER(str in varchar2) return varchar2
    IS
      n number;
    BEGIN
      n := to_number(str);
      return 'Y';
    EXCEPTION WHEN VALUE_ERROR THEN
      return 'N';
    END;
    
    0 讨论(0)
提交回复
热议问题