This is a pretty important topic that you will want to gain some expertise in.

In mysql you can create stored procedures.

https://www.w3resource.com/mysql/mysql-procedure.php

This will allow you to do much more powerful data manipulation than you can do 
with simple queries.

http://www.mysqltutorial.org/stored-procedures-parameters.aspx

An example of a stored procedure:

DELIMITER $$

CREATE PROCEDURE GetOrderCountByStatus (
    IN  orderStatus VARCHAR(25),
    OUT total INT
)
BEGIN
    SELECT COUNT(orderNumber)
    INTO total
    FROM orders
    WHERE status = orderStatus;
END$$

DELIMITER ;


Within the context of a stored procedure you can do a whole bunch of stuff MUCH 
FASTER than terascribe can do it.

For example you can pass in a value like ‘1,2,3,4;5,6,7,8’ and parse it and 
enter the values in multiple inserts inside the stored procedure.

http://www.mysqltutorial.org/mysql-cursor/

mysql also natively supports json so you can pass it a complex dataset.

https://stackoverflow.com/questions/43796685/how-to-pass-list-of-objectsa-dto-as-single-in-parameter-to-stored-procedure

Interacting with a stored procedure is very simple. Just use the direct dbms 
action.

You simply pass the name of the stored procedure and put your values inside the 
brackets:

GetOrderCountByStatus(‘active’)

By the way, using the direct dbms action and stored procedures is significantly 
faster and more scalable than using the search/insert/delete functions. I don’t 
even touch those.


Peter Dobbs
President | ENGINESS | P: 416.901.6151<tel:416.901.6151;118> | F: 
416.901.6150<tel:416.901.6150> | 
www.enginess.io<applewebdata://8216EA48-43EA-4400-A4E3-F4C824DFF588/www.enginess.io>


From: Robert Shubert <rshub...@tronics.com> on behalf of Robert Shubert 
<rshub...@tronics.com>
Reply-To: "TeraScript-Talk@terascript.com" <TeraScript-Talk@terascript.com>
Date: Wednesday, October 16, 2019 at 10:22 AM
To: "TeraScript-Talk@terascript.com" <TeraScript-Talk@terascript.com>
Subject: RE: TeraScript-Talk: Writing array back into MySQL DB

SQL only provides for updating a row or rows with one set of values. Assuming 
that you're revising your array with different values per row, there's no way 
to do this except to iterate the array and do an Update action per row.

Inserting is a different situation, since INSERT's VALUES clause can take 
multiple value sets. TeraScript doesn't help you do this, however, so you have 
to write a custom query. I plan to add a multi-insert action in the future.

I'm not sure if I would ever support a multi-update action since it would rely 
on some convention, such as the first column being the primary key.

Robert

From: Fogelson, Steve [mailto:foge...@askics.net]
Sent: Monday, October 14, 2019 6:30 PM
To: TeraScript-Talk@terascript.com
Subject: TeraScript-Talk: Writing array back into MySQL DB

I use MySQL for my DB.

If you read a set of data into an array, can you write the revised array back 
to the DB with one write or do you need to write back a row at a time?

If you can, how?

Thanks

Steve Fogelson
Internet Commerce Solutions

________________________________
To unsubscribe from this list, please send an email to 
lists...@terascript.com<mailto:lists...@terascript.com> with "unsubscribe 
terascript-talk" in the body.

________________________________
To unsubscribe from this list, please send an email to 
lists...@terascript.com<mailto:lists...@terascript.com> with "unsubscribe 
terascript-talk" in the body.


----------------------------------------

To unsubscribe from this list, please send an email to lists...@terascript.com 
with "unsubscribe terascript-talk" in the body.

Reply via email to