Sun Oct 13, 2019 11:23 pm
Login Register Lost Password? Contact Us


EMBED MySQL Insert using dataset

Questions around writing code and queries

Fri Sep 27, 2019 11:56 am Change Time Zone

Hi Richard,
Logging was just was an example , Once I can dump data to SQL Database , Dashboard tools can be connected run time .
Hence I am looking to pass dataset to sqlembbed and insert same data in tables .That respective tables can be views in BI Tools.
harshdesai
 
Posts: 12
Joined: Fri Feb 23, 2018 8:30 am

Fri Sep 27, 2019 12:15 pm Change Time Zone

A file containing examples of ECL interacting with MySQL can be found within the HPCC Systems source code: https://github.com/hpcc-systems/HPCC-Platform/blob/master/initfiles/examples/embed/mysql-simple.ecl. From that file:

Code: Select all
initialize(dataset(childrec) values) := EMBED(mysql : user('rchapman'),database('test'),server('127.0.0.1'), port('3306'))
  INSERT INTO tbl1 values (?, ?, ?, ?, ?, ?, ?, ?, ?);
ENDEMBED;

There are a few things to note:

* The function does not specify a data type for a returned value. Therefore, the function is defined as an action. This affects how you invoke it. It will be similar to how you would use OUTPUT() within your ECL code.

* A dataset is passed into the function as an argument. The binding of each record's values is positional: The first field in each record is bound to the first '?' in the SQL statement, the second field to the second '?' and so on.

* The MySQL plugin accepts a number of options for connecting to the database. The general form is EMBED(mysql : option(value) [, option(value)]*). The options let you define things like the IP address of the MySQL server, the user and password for connecting, the database to connect to, etc. The example file uses most of those options in one function or another.

Hope this helps!

Dan
DSC
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 565
Joined: Tue Oct 18, 2011 4:45 pm

Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest