Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. MySQL Stored Procs -

MySQL Stored Procs -

Scheduled Pinned Locked Moved Database
helpdatabasemysqlsql-serveroracle
4 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ericgahn
    wrote on last edited by
    #1

    Hi all; I am learning to write stored procs on MySQL and am going crazy.

    DELIMITER $$

    DROP PROCEDURE IF EXISTS CleanCopyEnvData$$

    CREATE PROCEDURE CleanCopyEnvData ()
    BEGIN

    insert into EnvData(UserDate, XAction, Balance, UserID)
    select
    CAST(udate as Date)
    , CAST(amount1 as Decimal(6,3))
    , CAST(amount2 as Decimal(6,3))
    , CAST(UID as UnSigned)
    from
    DataLoad;

    END $$

    DELIMITER ;

    I get an error:

    Error starting at line : 17 in command -
    END $$
    Error at Command Line : 17 Column : 1
    Error report -
    SQL Error: 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 'END $$' at line 1

    I am using Oracle SQL Developer and the INSERT statement works ok when executed on its own. I can do these things blindfolded with my arms tied on MSSQL. Any help appreciated. EG.

    W 1 Reply Last reply
    0
    • E ericgahn

      Hi all; I am learning to write stored procs on MySQL and am going crazy.

      DELIMITER $$

      DROP PROCEDURE IF EXISTS CleanCopyEnvData$$

      CREATE PROCEDURE CleanCopyEnvData ()
      BEGIN

      insert into EnvData(UserDate, XAction, Balance, UserID)
      select
      CAST(udate as Date)
      , CAST(amount1 as Decimal(6,3))
      , CAST(amount2 as Decimal(6,3))
      , CAST(UID as UnSigned)
      from
      DataLoad;

      END $$

      DELIMITER ;

      I get an error:

      Error starting at line : 17 in command -
      END $$
      Error at Command Line : 17 Column : 1
      Error report -
      SQL Error: 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 'END $$' at line 1

      I am using Oracle SQL Developer and the INSERT statement works ok when executed on its own. I can do these things blindfolded with my arms tied on MSSQL. Any help appreciated. EG.

      W Offline
      W Offline
      Wayne Gaylard
      wrote on last edited by
      #2

      You don't need the delimiter expression $$ after your END statement.

      DELIMITER $$

      DROP PROCEDURE IF EXISTS CleanCopyEnvData$$

      CREATE PROCEDURE CleanCopyEnvData ()
      BEGIN

      insert into EnvData(UserDate, XAction, Balance, UserID)
      select
      CAST(udate as Date)
      , CAST(amount1 as Decimal(6,3))
      , CAST(amount2 as Decimal(6,3))
      , CAST(UID as UnSigned)
      from
      DataLoad;

      END

      Everyone dies - but not everyone lives

      E 1 Reply Last reply
      0
      • W Wayne Gaylard

        You don't need the delimiter expression $$ after your END statement.

        DELIMITER $$

        DROP PROCEDURE IF EXISTS CleanCopyEnvData$$

        CREATE PROCEDURE CleanCopyEnvData ()
        BEGIN

        insert into EnvData(UserDate, XAction, Balance, UserID)
        select
        CAST(udate as Date)
        , CAST(amount1 as Decimal(6,3))
        , CAST(amount2 as Decimal(6,3))
        , CAST(UID as UnSigned)
        from
        DataLoad;

        END

        Everyone dies - but not everyone lives

        E Offline
        E Offline
        ericgahn
        wrote on last edited by
        #3

        Thanks Wayne.

        W 1 Reply Last reply
        0
        • E ericgahn

          Thanks Wayne.

          W Offline
          W Offline
          Wayne Gaylard
          wrote on last edited by
          #4

          Glad to help.

          Everyone dies - but not everyone lives

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups