This is a discussion on DECLARE SYNTAX within the MySQL forums, part of the Database Server Software category; --> declare @x int set @x = (SELECT max(ixBugEvent) FROM bugevent) UPDATE bugevent SET ixAttachment = (SELECT max(ixAttachment) FROM attachment), ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| declare @x int set @x = (SELECT max(ixBugEvent) FROM bugevent) UPDATE bugevent SET ixAttachment = (SELECT max(ixAttachment) FROM attachment), ixBug = (SELECT max(ixBug) FROM bug) WHERE ixBugEvent = @x; i have a problem in the given code, can anyone help me to tell what's wrong here? |
| |||
| harpalshergill@gmail.com wrote: > declare @x int > set @x = (SELECT max(ixBugEvent) FROM bugevent) > > UPDATE bugevent > SET ixAttachment = (SELECT max(ixAttachment) FROM attachment), > ixBug = (SELECT max(ixBug) FROM bug) > WHERE ixBugEvent = @x; > > i have a problem in the given code, can anyone help me to tell what's > wrong here? Would you care to tell us what problem you are seeing? |
| |||
| On 26 Jun 2006 14:39:09 -0700, harpalshergill@gmail.com wrote: >declare @x int >set @x = (SELECT max(ixBugEvent) FROM bugevent) > >UPDATE bugevent > SET ixAttachment = (SELECT max(ixAttachment) FROM attachment), > ixBug = (SELECT max(ixBug) FROM bug) > WHERE ixBugEvent = @x; > >i have a problem in the given code, can anyone help me to tell what's >wrong here? You left out the semicolons after the first two statements. -- ( Kees ) c[_] Giving power and money to government is like giving whiskey and car-keys to teenage boys. (PJ O'Rourke) (#181) |
| |||
| i am getting a syntax error for the code which posted before. i am using MySQL 4.0 and this is the error i am getting: _message "#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @bugrtr int SET @bugrtr = (SELECT max(ixBugEvent) FROM bugevent);UPDATE ' at line 1" string I also tried it with the ';' at the end of secound statement, but it still the same. any thing else u want to know?? Paul Lautman wrote: > harpalshergill@gmail.com wrote: > > declare @x int > > set @x = (SELECT max(ixBugEvent) FROM bugevent) > > > > UPDATE bugevent > > SET ixAttachment = (SELECT max(ixAttachment) FROM attachment), > > ixBug = (SELECT max(ixBug) FROM bug) > > WHERE ixBugEvent = @x; > > > > i have a problem in the given code, can anyone help me to tell what's > > wrong here? > > Would you care to tell us what problem you are seeing? |
| |||
| getziiiiiiiiiii wrote: > i am getting a syntax error for the code which posted before. i am > using MySQL 4.0 and this is the error i am getting: > _message "#42000You have an error in your SQL syntax; check the manual > that corresponds to your MySQL server version for the right syntax to > use near 'DECLARE @bugrtr int SET @bugrtr = (SELECT max(ixBugEvent) > FROM bugevent);UPDATE ' at line 1" string > > I also tried it with the ';' at the end of secound statement, but it > still the same. > any thing else u want to know?? > I think Kees was suggesting that you needed a semicolon after each of the first two statements. I hope that works for you, because I really don't like your attitude so you'll have to hope that someone else will help you after this. |
| |||
| On 27 Jun 2006 06:22:53 -0700, "getziiiiiiiiiii" <harpalshergill@gmail.com> wrote: >i am getting a syntax error for the code which posted before. i am >using MySQL 4.0 and this is the error i am getting: > _message "#42000You have an error in your SQL syntax; check the manual >that corresponds to your MySQL server version for the right syntax to >use near 'DECLARE @bugrtr int SET @bugrtr = (SELECT max(ixBugEvent) >FROM bugevent);UPDATE ' at line 1" string > >I also tried it with the ';' at the end of secound statement, but it >still the same. >any thing else u want to know?? Please read the suggestions more carefully next time: you still need a semicolon after the DECLARE statement. If that doesn't help, i'm out of options and you're on your own. Good luck. -- ( Kees ) c[_] Nostalgia. Sure ain't what it used to be.... (#26) |
| |||
| harpalshergill@gmail.com wrote: > declare @x int Is this within the body of a stored procedure? The manual page http://dev.mysql.com/doc/refman/5.0/en/declare.html says: "DECLARE is allowed only inside a BEGIN ... END compound statement and must be at its start, before any other statements." That means it works only inside stored procedures or stored functions. If you're trying to do this declare statement outside the definition of a stored routine, e.g. simply at a mysql CLI prompt, then it doesn't work. Regards, Bill K. |
| ||||
| This is SQL Server code, I assume. You don't have to DECLARE anything in loose MySQL scripts. Also, the variables live as long as the session (the connection). Best regards, Willem Bogaerts harpalshergill@gmail.com wrote: > declare @x int > set @x = (SELECT max(ixBugEvent) FROM bugevent) > > UPDATE bugevent > SET ixAttachment = (SELECT max(ixAttachment) FROM attachment), > ixBug = (SELECT max(ixBug) FROM bug) > WHERE ixBugEvent = @x; > > i have a problem in the given code, can anyone help me to tell what's > wrong here? > |