【问题标题】:Why this simple postgresql function call does not work?为什么这个简单的 postgresql 函数调用不起作用?
【发布时间】:2015-01-09 03:58:13
【问题描述】:

即使我尝试了不同的变体并且搜索了互联网也找不到解决此问题的方法? 我的函数调用是

select get_byte( md5('key')::text , 0);

不起作用。

根据这个http://www.postgresql.org/docs/9.1/static/functions-string.htmlmd5接受字符串输入并产生文本,而get_byte期望字符串输入(http://www.postgresql.org/docs/8.0/static/functions-binarystring.html)。我在这里想念什么?错误是HINT: No function matches the given name and argument types. You might need to add explicit type casts.

【问题讨论】:

    标签: postgresql


    【解决方案1】:

    您需要将 md5 返回值强制转换为 bytea,而不是 text

    > SELECT get_byte(MD5('key')::bytea, 0);
     get_byte
    ----------
           51
    (1 row)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-25
      • 2011-10-25
      • 2012-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多