Using the Read from action

Use the Read from action to retrieve records from the database and save the retrieved data in a CSV file. This action enables you to retrieve up to one million records from the database.

Note: In Automation 360, the bot displays an error when you use Read from action to copy the table records using Select * into tablename from sourcetable, whereas this functionality is supported in Enterprise 11. If you have such bots created in Enterprise 11 and migrated to Automation 360, we recommend modifying your bots and use Insert/Update/Delete action to perform this operation.

Procedure

To automate the task of selecting and saving a set of records, follow these steps:

  1. Enter the name of the session you used to connect to the database server in the Connect action.
    You do not have to provide the details of the database server here because you have already associated those details with the session name when using the Connect action.
  2. Enter the SELECT statement to specify the column and table names.
    This field supports SQL syntax. For example, SELECT CustomerName,City FROM Customers
    Note: CTE (Common Table Expression) is supported using WITH keyword in the SQL compliant databases such as Oracle and MySQL. For example,
    WITH customers_in_usa AS (SELECT CustomerName, state FROM customers WHERE country = 'USA') 
    SELECT cName FROM customers_in_usa WHERE state = 'LA' ORDER BY CustomerName
    
  3. Enter the maximum number of records to retrieve.
  4. Optional: Enter a timeout value.
    When the specified time expires, the statement execution stops even if the execution is not completed.
  5. Select the Export data to CSV option to save the retrieved data.
    1. Select the file path from the Bots folder, the local device, or an existing file variable.
    2. Select the CSV file encoding to be either ANSI, UNICODE, or UTF8.
    3. Select whether to export the CSV file with or without the column headers.
      With column headers
      CustomerName City
      Manny Pittsburgh
      Kate Los Angeles
      John Boston
      Without column headers
      Manny Pittsburgh
      Kate Los Angeles
      John Boston
    4. Select this check box if you do not want a CSV file to be created when the SQL query does not return any data.
    5. Specify whether to overwrite the file or append the data to the existing file if a CSV file with the same name exists.
  6. Click Save.