Hi,

I am writing a MySQL script. I used a parameter file to set a user variable

set @log_file = "C:/logs/table_creation.txt";

I used the variable in another file in the tee command as follows

set @log = concat("tee ", @log_file);
prepare stmt from @log;
execute stmt;

But it throws the following error.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tee C:/logs/table_creation.txt' at line 1
ERROR 1243 (HY000): Unknown prepared statement handler (stmnt) given to EXECUTE

I used to set variables in Oracle and use it for the entire session. I am trying to do a similar thing in MySQL. Could someone help me please.

Thanks
Shiny

try this

SET @LOG = CONCAT('tee ', @log_file);

Please read more here.

it seems tee is a string not a function name .

Hi,

Thanks for the response. But I got the same error again. Is there any other way to pass my log file dir from a parameter file?

Shiny

what is the code that you are using ?

what is the error ?

Hi,

I'm using the following code:

Parameter file

set @log_dir = "C:/logs/table_creation.txt";

Main file

set @log = concat('tee ', @log_dir);

prepare stmt from @log;
execute stmt;

Error Message

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'tee C
:/logs/table_creation.txt' at line 1
ERROR 1243 (HY000): Unknown prepared statement handler (stmt) given to EXECUTE

To my knowledge there is no tee statement in mysql server. You have to process the log file from the OS level or use the mysql command line client which knows how to tee.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.