<legend id='8ces7'><style id='8ces7'><dir id='8ces7'><q id='8ces7'></q></dir></style></legend>

    <small id='8ces7'></small><noframes id='8ces7'>

  • <i id='8ces7'><tr id='8ces7'><dt id='8ces7'><q id='8ces7'><span id='8ces7'><b id='8ces7'><form id='8ces7'><ins id='8ces7'></ins><ul id='8ces7'></ul><sub id='8ces7'></sub></form><legend id='8ces7'></legend><bdo id='8ces7'><pre id='8ces7'><center id='8ces7'></center></pre></bdo></b><th id='8ces7'></th></span></q></dt></tr></i><div id='8ces7'><tfoot id='8ces7'></tfoot><dl id='8ces7'><fieldset id='8ces7'></fieldset></dl></div>

      • <bdo id='8ces7'></bdo><ul id='8ces7'></ul>
        <tfoot id='8ces7'></tfoot>

        解析日期后从 Oracle Select 语句返回编号

        时间:2023-10-09
          <bdo id='Gm6bQ'></bdo><ul id='Gm6bQ'></ul>

            <tbody id='Gm6bQ'></tbody>

        • <tfoot id='Gm6bQ'></tfoot>

                  <small id='Gm6bQ'></small><noframes id='Gm6bQ'>

                1. <legend id='Gm6bQ'><style id='Gm6bQ'><dir id='Gm6bQ'><q id='Gm6bQ'></q></dir></style></legend>
                  <i id='Gm6bQ'><tr id='Gm6bQ'><dt id='Gm6bQ'><q id='Gm6bQ'><span id='Gm6bQ'><b id='Gm6bQ'><form id='Gm6bQ'><ins id='Gm6bQ'></ins><ul id='Gm6bQ'></ul><sub id='Gm6bQ'></sub></form><legend id='Gm6bQ'></legend><bdo id='Gm6bQ'><pre id='Gm6bQ'><center id='Gm6bQ'></center></pre></bdo></b><th id='Gm6bQ'></th></span></q></dt></tr></i><div id='Gm6bQ'><tfoot id='Gm6bQ'></tfoot><dl id='Gm6bQ'><fieldset id='Gm6bQ'></fieldset></dl></div>
                2. 本文介绍了解析日期后从 Oracle Select 语句返回编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想编写一个 Oracle SQL select 语句,通过返回代码来判断它是否可以解析给定格式的日期字符串 - 失败时为零(异常),成功时返回正数:

                  I want to write a Oracle SQL select statement that tells if it could parse a date string in the given format by returning a code - zero on failure (exception) and a positive number in case of success :

                      SELECT
                       CASE
                        WHEN PARSING SUCCESSFUL (ie. to_date('1-Jan-2001','dd-mon-yy') succeeds) THEN 1
                        ELSE 0
                       END  
                      FROM DUAL;
                  

                  我该怎么写?如果解析失败,ELSE 条件会返回一个值吗?我需要在 SELECT 语句本身中进行所有这些检查.请帮忙.

                  How do I write this ? If the parsing fails, will the ELSE condition return a value ? I need to do all these checks in the SELECT statement itself. Please help.

                  谢谢忧郁

                  推荐答案

                  如果您可以创建一个函数,那么您可以执行以下操作:

                  If you can create a function then you can do something like:

                  SQL 小提琴

                  Oracle 11g R2 架构设置:

                  CREATE OR REPLACE FUNCTION is_Valid_Date (
                    p_date   IN VARCHAR2,
                    p_format IN VARCHAR2 DEFAULT 'DD-MON-YY'
                  ) RETURN NUMBER
                  IS
                    d DATE;
                  BEGIN
                    d := TO_DATE( p_date, p_format );
                    RETURN 1;
                  EXCEPTION
                    WHEN OTHERS THEN
                      RETURN 0;
                  END;
                  /
                  

                  查询 1:

                  SELECT is_Valid_Date( '12-Feb-13' ),
                         is_Valid_Date( 'XX-Feb-13' )
                  FROM DUAL
                  

                  结果:

                  | IS_VALID_DATE('12-FEB-13') | IS_VALID_DATE('XX-FEB-13') |
                  |----------------------------|----------------------------|
                  |                          1 |                          0 |
                  

                  这篇关于解析日期后从 Oracle Select 语句返回编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:SQL 查找字符串中的第一个非数字字符 下一篇:SQL Server:5 列的动态数据透视

                  相关文章

                3. <tfoot id='0J2pY'></tfoot>

                    <legend id='0J2pY'><style id='0J2pY'><dir id='0J2pY'><q id='0J2pY'></q></dir></style></legend>
                    <i id='0J2pY'><tr id='0J2pY'><dt id='0J2pY'><q id='0J2pY'><span id='0J2pY'><b id='0J2pY'><form id='0J2pY'><ins id='0J2pY'></ins><ul id='0J2pY'></ul><sub id='0J2pY'></sub></form><legend id='0J2pY'></legend><bdo id='0J2pY'><pre id='0J2pY'><center id='0J2pY'></center></pre></bdo></b><th id='0J2pY'></th></span></q></dt></tr></i><div id='0J2pY'><tfoot id='0J2pY'></tfoot><dl id='0J2pY'><fieldset id='0J2pY'></fieldset></dl></div>
                      <bdo id='0J2pY'></bdo><ul id='0J2pY'></ul>

                    <small id='0J2pY'></small><noframes id='0J2pY'>