Professional Web Applications Themes

DECLARE SYNTAX - MySQL

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?...

  1. #1

    Default DECLARE SYNTAX

    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 Guest

  2. #2

    Default Re: DECLARE SYNTAX

    [email]harpalshergill[/email] 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?


    Paul Lautman Guest

  3. #3

    Default Re: DECLARE SYNTAX

    On 26 Jun 2006 14:39:09 -0700, [email]harpalshergill[/email] 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)
    Kees Nuyt Guest

  4. #4

    Default Re: DECLARE SYNTAX

    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:
    > [email]harpalshergill[/email] 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 Guest

  5. #5

    Default Re: DECLARE SYNTAX

    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.


    Paul Lautman Guest

  6. #6

    Default Re: DECLARE SYNTAX

    On 27 Jun 2006 06:22:53 -0700, "getziiiiiiiiiii"
    <harpalshergill> 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)
    Kees Nuyt Guest

  7. #7

    Default Re: DECLARE SYNTAX

    [email]harpalshergill[/email] wrote:
    > declare x int
    Is this within the body of a stored procedure? The manual page
    [url]http://dev.mysql.com/doc/refman/5.0/en/declare.html[/url] 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.
    Bill Karwin Guest

  8. #8

    Default Re: DECLARE SYNTAX

    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

    [email]harpalshergill[/email] 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?
    >
    Dikkie Dik Guest

Similar Threads

  1. Can we declare external Application API ?
    By psoum in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: March 3rd, 05:54 PM
  2. how to declare the CURSOR in mysql
    By zhongdai in forum MySQL
    Replies: 1
    Last Post: March 2nd, 02:24 AM
  3. Call/Declare Functions
    By Myrddraal webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 4
    Last Post: January 30th, 08:55 PM
  4. declare one variable
    By [ZaToPeK] in forum PHP Development
    Replies: 3
    Last Post: December 5th, 01:27 AM
  5. Replies: 1
    Last Post: August 24th, 03:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139