Oracle的CURRENT_TIMESTAMP函数真的是一个函数吗? [英] Is Oracle's CURRENT_TIMESTAMP function really a function?

查看:206
本文介绍了Oracle的CURRENT_TIMESTAMP函数真的是一个函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的印象是,在函数名称后面可以用空括号调用无参数函数,即其他数据库允许执行的操作:

  current_timestamp()

在Oracle中,我必须写

  current_timestamp 

使用用户定义的函数,此规则不适用(在11g中)。我可以同时写两个

  my_function 
my_function()

我的问题是: CURRENT_TIMESTAMP 真的是一个真正的函数,或者我应该认为它是一个语言结构/伪列Oracle SQL方言(与SQL标准兼容)?关于什么时候可以(可选地,强制性地)添加()以及什么时候必须省略它们?

背景信息:


  • SQL 1992 定义:

     < ;当前时间戳值函数> :: = 
    CURRENT_TIMESTAMP [< left paren> <时间戳精度> <右paren> ]


  • Derby,HSQLDB,Ingres,Postgres,SQLite,对于 CURRENT_TIMESTAMP


  • 不允许使用括号。Sybase SQL Anywhere知道 CURRENT TIMESTAMP code>函数(没有括号,没有下划线)
  • CUBRID,MySQL,Sybase ASE允许使用 CURRENT_TIMESTAMP()


解决方案

返回1992年的SQL标准将CURRENT_TIMESTAMP称为时变系统变量和日期时间值功能。例如,请参阅数据库语言SQL

但是AFAIK标准始终使用CURRENT_TIMESTAMP,从不 CURRENT_TIMESTAMP()。在兼容的dbms上使用CURRENT_TIMESTAMP()应该会失败,并且会出现语法错误。

我不确定标准对用户定义的函数有什么要说的。


I was under the impression that argument-less functions can be called with empty parentheses after the function name, i.e. what some other databases allow to do:

current_timestamp()

Whereas in Oracle, I have to write

current_timestamp

With user-defined functions, this rule doesn't apply (in 11g). I can write both

my_function
my_function()

My question is: Is CURRENT_TIMESTAMP really a true function or should I consider it to be a language construct / pseudo-column of the Oracle SQL dialect (compatible with the SQL standard)? Is there any formal definition about when I can (optionally, mandatorily) add the () and when I have to omit them?

Background-info:

  • SQL 1992 defines:

    <current timestamp value function> ::=
      CURRENT_TIMESTAMP [ <left paren> <timestamp precision> <right paren> ]
    

  • Derby, HSQLDB, Ingres, Postgres, SQLite, SQL Server behave like Oracle, where there are no parentheses allowed for CURRENT_TIMESTAMP

  • Sybase SQL Anywhere knows a CURRENT TIMESTAMP function (without parentheses, without underscore)
  • CUBRID, MySQL, Sybase ASE allow for using CURRENT_TIMESTAMP()

解决方案

SQL standards back to 1992 refer to CURRENT_TIMESTAMP as both a "time-varying system variable" and a "datetime value function". See, for example, Database Language SQL.

But AFAIK the standards always use CURRENT_TIMESTAMP, never CURRENT_TIMESTAMP(). Using CURRENT_TIMESTAMP() on a compliant dbms should fail with a syntax error.

I'm not sure what the standards have to say about user-defined functions.

这篇关于Oracle的CURRENT_TIMESTAMP函数真的是一个函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆