Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Declare Variable

forums forums SQLyog SQLyog: Bugs / Feature Requests Declare Variable

  • This topic is empty.
Viewing 2 reply threads
  • Author
    Posts
    • #10392
      ant1
      Member

      Is there any reason why SQLyog does not allow me to declare variables?

      In my code I use: Declare QueryStr varchar(50);

      and I get “You have an error in your SQL syntax.”

    • #24280
      peterlaursen
      Participant

      It is not SQLyog that sends this error messsage.  It is MySQL that does!

      There is no (My)SQL “DECLARE” statement.

      However you can DECLARE inside (BEGIN .. END) of a Stored procedure or Function (or Trigger or Event etc).

      an example:

      Code:
      DELIMITER $$

      DROP FUNCTION IF EXISTS `test`.`qs`$$

      CREATE FUNCTION `test`.`qs`() RETURNS varchar(50)
      BEGIN
      declare querystr varchar(50);
      — more operations here
      return querystr;
      END$$

      DELIMITER;

      You can also use 'user variables' like

      SET @querystr = 'something'.

      (and the type of a user variable is not declared)

    • #24281
      ant1
      Member

      Thank you!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.