sql queries not working anymore

Bug #781220 reported by Julien Martel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OCS Inventory: OCSReports
Fix Released
High
Erwan

Bug Description

The dynamic groups I created with the 1.x version are not working anymore. When I try to recalculate those groups I got an SQL error message. Same happens if I delete the group and recreate it from the multi-criterias search engine.

Revision history for this message
Julien Martel (j-martel) wrote :

Here is an example of SQL query as displayed in the administration console :

1) => select distinct id as HARDWARE_ID from hardware where id not in (select distinct HARDWARE_ID from groups_cache where ( ( GROUP_ID = 1847 OR GROUP_ID = 2731)))
2) => select distinct id as HARDWARE_ID from hardware where id not in (select distinct HARDWARE_ID from devices where ( ( NAME like 'DOWNLOAD' AND IVALUE IN IN (select id from download_enable where fileid=1288341377) )))

That query look correct as far as I can tell.

The result is :

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN (select id from download_enable where fileid=1288341377) ))) and id in (20,23' at line 1

Revision history for this message
Julien Martel (j-martel) wrote :

OK, I think there is a problem with that double "IN" next to IVALUE but I still don't understand where is that second "IN" coming from.

Erwan (airoine)
Changed in ocsinventory-server:
status: New → Confirmed
assignee: nobody → Erwan (airoine)
Revision history for this message
Erwan (airoine) wrote :

fix commited on stable branch commit 720

Update your /require/function_search.php

function traitement_cache($sql_temp,$field_modif,$field_value,$field_value_complement){
 if ($sql_temp != ""){
  if ($field_modif == "field_value")
   $field_value= " (".$sql_temp.") ";
  else{
   $value_complement_temp=explode('(',$field_value_complement);
   $value_complement_temp2=explode(')',$value_complement_temp[1]);
++ if (substr(trim($value_complement_temp[0]),-2) != 'IN')
++ $in='IN';
++ else
++ $in='';
-- $field_value_complement=$value_complement_temp[0]." IN (".$sql_temp.") ".$value_complement_temp2[1];
++ $field_value_complement=$value_complement_temp[0]." ".$in." (".$sql_temp.") ".$value_complement_temp2[1];
   //p($value_complement_temp);
   //$field_value_complement= " IN (".$sql_temp.") ";

  }
 }

After that, you have to create again your group.

Tx for your report

Changed in ocsinventory-server:
status: Confirmed → Fix Committed
importance: Undecided → High
Revision history for this message
Julien Martel (j-martel) wrote :

Thank you for the quick reply. After updating function_search.php, I got an error message when using the multi criterias search engine :

Parse error: syntax error, unexpected '"' in /usr/share/ocsinventory-reports/ocsreports/require/function_search.php on line 172

Attached is my updated function_search.php. I guess I did something wrong but I can't get exactly what.

Revision history for this message
Erwan (airoine) wrote :

you have a problem with your php code...
show modifications
http://bazaar.launchpad.net/~ocsinventory-dev/ocsinventory-ocsreports/stable-2.0/revision/720

best regards

affects: ocsinventory-server → ocsinventory-ocsreports
Revision history for this message
Julien Martel (j-martel) wrote :

It works now. Thank you very much.

Arthur Jaouen (arthur-z)
Changed in ocsinventory-ocsreports:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.