Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
7840 มุมมอง

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!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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 ( ' ).

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 15
4568
0
ก.พ. 25
1458
2
ม.ค. 25
7996
0
ก.ค. 24
1250
Odoo backend to Google Data Studio แก้ไขแล้ว
2
ม.ค. 24
10138