MySQL Forums
Forum List  »  Triggers

Create outfile trigger with appended text
Posted by: Pete Tromblee
Date: June 17, 2016 02:03PM

Hi,

I have a trigger that exports a record to a csv and this works fine, however I want to add two lines of text to the beginning of the file.

This is my trigger:

CREATE DEFINER=`3pl`@`%` TRIGGER `3pl`.`app_Skus_AFTER_INSERT` AFTER INSERT ON `app_Skus` FOR EACH ROW
BEGIN
Select id,client,sku,qty,printer_name into outfile '/share/labels/labels1.csv'
fields terminated by ';'
lines terminated by '\n'
from app_Skus
where id=new.id;
END


This creates a csv file with the 5 fields I need. Now I want to add these two lines of text the the file for our label printing software:

%BTW% /AF=C:\labelfolder\ManualproductLabel.btw /D=%Trigger File Name% /PRN="IT0312" /R=3 /P
%END%

But I need the text IT0312 to be what is the field called printer_name. Is this possible with a trigger? Currently I export the file and then have a script that writes the data to the file and re-saves it. However this delays the printing of the label by a couple seconds.

Options: ReplyQuote


Subject
Views
Written By
Posted
Create outfile trigger with appended text
2584
June 17, 2016 02:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.