<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 语句返回编号

        Return number from Oracle Select statement after parsing date(解析日期后从 Oracle Select 语句返回编号)
          <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 语句返回编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Building a comma separated list?(建立一个逗号分隔的列表?)
                  Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                  How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                  Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                  Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                  SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)
                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'>

                              <tbody id='0J2pY'></tbody>