views:

26

answers:

1

Here, I have probleming in trim the value in postgresql. Please have a look. Ruby code ::

    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')+"',' ')

In above code, btrim is function of postgresql for triming but it occurs error. I think, I am missing something please help me.

+1  A: 

From the 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


So you need to cast as text:

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

vol7ron
Awesome, Reall It Works.... Thnx Bro
Rahul Patil
Glad we could help. PostgreSQL errors are pretty descriptive. If there's ever a problem with a native function that you know exists, it's generally due to the arguments passed in. If you ever see a message regarding `typecast`, it gives you a big help in knowing what to look for.
vol7ron