Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Typecast int to char?

By
evon_dun
on 7/3/13, 7:49 AM 1,916 views

I am trying to work on a query in openerp 6.1, but it gives an error:

ProgrammingError: operator does not exist: character varying = integer LINE 1: SELECT debit,credit FROM account_move_line WHERE ref = 434 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

And my query:

move_obj = self.pool.get('account.move.line')
cr.execute("SELECT debit,credit FROM account_move_line WHERE  ref = %s",(move_id,))

Please help i tried looking at the typecast methods tried few but it always have some error or probably the module to be imported was missing. Its damn too urgent!

2

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 7/3/13, 10:51 AM

The issue is that ref expects a string. In SQL, strings need to be surrounded by single quotes ( ' )

So the following (add a ' before and after %s) should do the trick:

move_obj = self.pool.get('account.move.line')
cr.execute("SELECT debit,credit FROM account_move_line WHERE  ref = '%s'",(move_id,))

You do not get string errors, becausew you start and end with a double quote ( " ), which does NOT end with a single quote ( ' ).

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 7/3/13, 7:49 AM
Seen: 1916 times
Last updated: 3/16/15, 8:10 AM