stored procedure syntax error
am 01.07.2010 09:49:06 von nayan.darekar
--_000_FDAA7D9540FD8E43B299D4BAFEB3ED8FB350F8E619INBANSXCHMB SA_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all !
I m getting an error while writing stored procedure, the code is as below a=
nd error
CODE
------------------------------------------------------------ ---------------=
-----------------------
DELIMITER $$
DROP PROCEDURE IF EXISTS `aaa` $$
CREATE DEFINER=3D`root`@`%` PROCEDURE `aaa`()
BEGIN
DECLARE b VARCHAR(255);
DECLARE c VARCHAR(255);
SET b=3D CONCAT(SUBDATE(CURDATE(), INTERVAL 15 DAY)," 00:00:00");
SET c=3D CONCAT("'","C://cells_summary.csv","'");
SELECT * INTO OUTFILE (c) FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '=
"' LINES TERMINATED BY '\n' FROM cells_summary WHERE PMMDATEANDTIME=3Db; //=
wrong
END $$
DELIMITER ;
------------------------------------------------------------ ---------------=
---------------------------
ERROR
------------------------------------------------------------ ---------------=
------------------------------------------------
Script line: 4 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 '=
(c) FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY=
'\n'' at line 7
------------------------------------------------------------ ---------------=
------------------------------
I guess there is a wronge syntax,
SELECT * INTO OUTFILE (c) FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '=
"' LINES TERMINATED BY '\n' FROM cells_summary WHERE PMMDATEANDTIME=3Db;
kindly anyone can help with correct syntax.....
Thanx
--_000_FDAA7D9540FD8E43B299D4BAFEB3ED8FB350F8E619INBANSXCHMB SA_--
Re: stored procedure syntax error
am 01.07.2010 10:09:05 von Nilnandan Joshi
I think, you have to use prepare() before run that select statement.
i.e
SET @s = CONCAT("SELECT * INTO OUTFILE", c ,"FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM cells_summary WHERE PMMDATEANDTIME=b");
PREPARE stmt FROM @s;
EXECUTE stmt;
regards,
nilnandan
DAREKAR, NAYAN (NAYAN) wrote:
> Hi all !
>
> I m getting an error while writing stored procedure, the code is as below and error
>
> CODE
>
> ------------------------------------------------------------ --------------------------------------
> DELIMITER $$
> DROP PROCEDURE IF EXISTS `aaa` $$
> CREATE DEFINER=`root`@`%` PROCEDURE `aaa`()
> BEGIN
> DECLARE b VARCHAR(255);
> DECLARE c VARCHAR(255);
> SET b= CONCAT(SUBDATE(CURDATE(), INTERVAL 15 DAY)," 00:00:00");
> SET c= CONCAT("'","C://cells_summary.csv","'");
> SELECT * INTO OUTFILE (c) FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM cells_summary WHERE PMMDATEANDTIME=b; //wrong
> END $$
> DELIMITER ;
> ------------------------------------------------------------ ------------------------------------------
>
> ERROR
> ------------------------------------------------------------ ------------------------------------------------------------ ---
> Script line: 4 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 '(c) FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'' at line 7
> ------------------------------------------------------------ ---------------------------------------------
>
> I guess there is a wronge syntax,
>
> SELECT * INTO OUTFILE (c) FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM cells_summary WHERE PMMDATEANDTIME=b;
>
>
>
> kindly anyone can help with correct syntax.....
>
>
>
> Thanx
>
> .
>
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org