MySQL Query

Use this activity to execute a simple or a complex SQL query on an Oracle MySQL database. The MySQL Query activity returns information in the form of rows.

Settings

The Settings tab has the following field.

Field Description
Connection Name of the Oracle MySQL database connection from where information is retrieved.

Input Settings

Field Description
Query An SQL statement used to query the database. The query can be a simple query or a complex query. A complex query has nested SQL statements. Prepared SQL queries can be constructed by using substitution variables (or substitution parameters) of the form ?<fieldname> in the query statement. For example, select * from classroom where building like ?building;

Each substitution variable identifies an input parameter whose mapped value is substituted into the substitution variable at runtime. Input and Output tabs are populated based on the query.

End the query with semicolon (;) to fetch the metadata in the table at the bottom of the query.

Following are some examples of simple and complex queries:

  • Simple query example:

    SELECT * FROM classroom;

    For the above query, the output fields are generated from the columns of the table classroom.

    SELECT name, dept_name, tot_cred  
        FROM student 
        WHERE dept_name = ?dept_name and tot_cred >= ?tot_cred order by tot_cred;

    For the above query, output fields are generated for name, dept_name and tot_cred and input fields are generated for dept_name and tot_cred. Also, the mapped values for the fields dept_name and tot_cred are substituted into the substitution variables ?dept_name and ?tot_cred at run time.

  • Nested query example:

    SELECT firstname, lastname, total_quantity
        FROM (SELECT buyerid, sum(qtysold) total_quantity
                FROM sales
                GROUP BY buyerid
                ORDER BY total_quantity desc limit 10) Q, users
        WHERE Q.buyerid = userid
        ORDER BY Q.total_quantity desc;
    
  • Call Procedure and Call Functions Syntax:
    • With no parameters
      Call  Procedure_Name( );
      
      Select Function_Name( );
      
    • With prepared parameters
      Call  Procedure_Name(?Param1 , ?Param2);
      
      Select Function_Name(?Param1, ?Param2);
      

Manually Configure Metadata

Set the Manually Configure Metadata field to True to fetch table metadata manually. For more information, see Manually Configuring Metadata.

Fields Displays the database column metadata.

Input

This tab contains the input schema. The fields that are selected on the Input Settings tab are available in the schema. You can either hard code their values or map them to a field from the output of a preceding activity in the flow using the Mapper.

Output

This tab displays the activity output schema in a tree structure format. The output of an activity is displayed for informational purposes only and cannot be modified or altered. The information in this schema varies depending on the fields that you selected on the Input Settings tab.

The properties that are displayed on the Output tab schema correspond to the output of this activity and can be used as input by subsequent activities in the flow.

Loop

If you want this activity to iterate multiple times within the flow, enter an expression that evaluates the iteration details. Select a type of iteration from the Type menu. The default type is None, which means the activity does not iterate.

Retry on Error

For more information, see the Using the Retry on Error Feature in an Activity section in the Flogo® app documentation.