sql - Btrim 函数在 PostgreSQL 中无法正常工作

标签 sql ruby-on-rails postgresql controller

在这里,我在 PostgreSQL 中的 trim() 函数的值中遇到问题:

Ruby 代码:

    if(this.modelName=="ClientOffice")
       {    this.params="model_name="+this.modelName+"&action_name="+this.actionName+"&
find_condition=btrim(clients_corporate_billings.id,' ') %3D 
btrim('"+validString('populateValue0','text')+"',' ')
  & object_id="+this.objectId;
      }

 &action_name="+this.actionName+"
    &find_condition=btrim(clients_corporate_billings.id,' ') %3D
     btrim('"+validString('populateValue0','text')+"',' ')

在上面的代码中,btrim 是 PostgreSQL 的 function 用于修剪,但它给出/产生错误。

最佳答案

来自documentation .

Function: btrim(string text [, characters text])
Return Type: text
Description: Remove the longest string consisting only of characters in characters (a space by default) from the start and end of string
Example: btrim('xyxtrimyyx', 'xy')
Result: trim


所以你需要转换为文本:

&find_condition=btrim(clients_corporate_billings.id::text,' ') %3D

关于sql - Btrim 函数在 PostgreSQL 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3864967/

相关文章:

postgresql - 如何在 postgres 中克隆或复制同一个表中的记录?

python - 使用 psycopg2/Python DB-API 和 PostgreSQL 的参数化查询

c# - 如何解决 "Index was outisde the bound of the array"错误?

ruby-on-rails - (config.filter_parameters) 相当于 Rails 2.3.5

ruby-on-rails - rails 3 条路线 : different auto route for model

sql - rails 和 PSQL : how to convert a column of type STRING to UUID with a fallback value

postgresql - 如何有效地选择先前的非空值?

sql - 如何在sql server 2008中使用子查询?

mysql - 计算最大值 (100%)

mysql - 如何在两个字段上使用 COUNT 和 GROUP BY