Error while trying to execute several statements in case

219
April 06, 2017, at 8:22 PM

I have some trouble by creating an mysql-statement like the following:

# Mandatory values
SET @thermalCondition = 'Hot Condition (Cruise)';
SET @partID = 2;                    # partID from xml-file
SET @partPos = 1;                       # Airfoil position
SELECT CASE @thermalCondition
   WHEN 'Hot Condition (Cruise)'
   THEN (
      SELECT @componentID := `componentID` FROM `inspection_airfoil` WHERE `partID` = @partID;
      # Generate entry for same part in hot condition in table `inspection_airfoil`
      INSERT INTO `inspection_part`(`ThermalPartCondition`, `partPos`, `componentID`)
      VALUES ('Hot Condition (Cruise)', @partPos,@componentID);
      # Get part id for hot stuff
      SET @partID = (SELECT LAST_INSERT_ID());
  )
END;

If variable @thermalCondition is named like "Hot Condition (Cruise)" I would like to create a new entry in table 'inspection_part' and store the generated primary key to and variable (here: @partID).

I am very interested in your ideas to improve my pice of code and appreciate your help.

READ ALSO
Ansible: make queries on mySQL database

Ansible: make queries on mySQL database

I've created a mySQL database named "mydb" on a Linux machine, using mysql_db module by AnsibleNow I have to perform some queries on it, still using Ansible

691
SQL calculate the number of row in a specific range

SQL calculate the number of row in a specific range

There's two table in my database:

336
Mysql Query List order in LIKE

Mysql Query List order in LIKE

My Table Structure is

359
Import huge data from csv files and stored in PHP & Mysql

Import huge data from csv files and stored in PHP & Mysql

I am working on a module of a projectIn which server generates logs for every day

280