【问题标题】:How to execute H2db generated statment in postgres如何在 postgres 中执行 H2db 生成的语句
【发布时间】:2016-03-09 07:00:41
【问题描述】:

下面是从h2生成的statmen

 INSERT INTO EPSG_ALIAS
   (ALIAS_CODE, OBJECT_TABLE_NAME, OBJECT_CODE, NAMING_SYSTEM_CODE, ALIAS, REMARKS) 
 VALUES 
   (1431, 'Datum', 6123, 7300, STRINGDECODE('Kartastokoordinaattij\ufffdrjestelm\ufffd (1966)'), NULL);

当我在 postgresql 中执行上述语句时,出现以下错误。

ERROR: function stringdecode(unknown) does not exist
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 140

【问题讨论】:

  • stringdecode 是做什么的,在 postgres 中找到一个等效的函数并使用它。
  • 它将Unicode字符串(\ufffd)转换为实际字符(即特殊字符)
  • 这个正则表达式有什么关系?
  • 您是否调查过是否可以在 PostgreSQL 中通过 CREATE FUNCTION STRINGDECODE(text) ... 来模拟相应 H2 函数的行为?

标签: postgresql jdbc h2db


【解决方案1】:

STRINGDECODE是H2读取'ASCII写的UTF-8字符'的方式。

对于 Postgres,它是一个简单的 'E' 在你的字符串之前:

STRINGDECODE('Kartastokoordinaattij\ufffdrjestelm\ufffd (1966)')

变成

E'Kartastokoordinaattij\ufffdrjestelm\ufffd (1966)'

【讨论】:

    猜你喜欢
    • 2012-09-12
    • 2020-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多