Question

My Questions:

  • Is there a way to add quotes around %{macro_name} in my SQL query ?
  • Is there a better way to create the required report (i.e. not using RapidMiner)?

    My Process:

    I'm currently trying to create a custom report of data stored in a MySQL database. Here is an hypothetical example of my table data:

    Item_Name  Item_Price Item_Stock Item_Timestamp
    Dish Soap    3.99        25      1/1/2013 12:00am
    Frogs        0.69        26      1/1/2013 12:00am
    Frogs        0.69        19      1/1/2013 1:00am
    Dish Soap    3.99        28      1/1/2013 1:00am
    

    Item_Timestamp refers to the datetime of when the entry was made.

    I'm attempting to use RapidMiner to do the following:

  • Provide a summation of increases in Item_Stock for each unique Item_Name
  • Provide a summation of decreases in Item_Stock for each unique Item_Name
  • Provide the average rate of change over a specified time period

    My goal is to create a report that tells me whether items are being restocked at a rate of equilibrium with demand.

    In order to create a report for each unique Item_Name, I have created a RapidMiner process which loads unique Item_Name as an example set, then attempts to loop through the exampleset by using the extract macro operator which sends the Item_Name from each example to another SQL query. RapidMiner uses %{macro_name} as the syntax for the macro. My SQL query looks like:

    Select Item_Name
    From thisTable
    Where Item_Name = %{macro_name}
    

    The problem is that this query throws an exception, but I'm not sure why. Perhaps the problem is that %{macro_name} returns a string without the necessary quotes, but I am unsure.

    My questions are:

  • Is there a way to add quotes around %{macro_name} in my SQL query ?
  • Is there a better way to create the required report (i.e. not using RapidMiner)?

  • Was it helpful?

    Solution

    I figured out the main problem:

    My current SQL string has a syntax problems. I needed to capitalize and there should be no space before %{macro_name}

    SELECT Item_Name
    FROM `thisTable`
    WHERE Item_Name =%{macro_name}
    
    Licensed under: CC-BY-SA with attribution
    Not affiliated with StackOverflow
    scroll top