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. stored procedures in mysql

stored procedures in mysql

Scheduled Pinned Locked Moved Database
mysqlhelp
9 Posts 3 Posters 0 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.
  • M Offline
    M Offline
    Member 10263519
    wrote on last edited by
    #1

    hi, am not getting what's wrong in this procedure: create procedure getpassword( in member varchar(20)) begin select password from admin where member_id = member end am getting error at "end" syntax error unexpected end,expecting ;

    G W 2 Replies Last reply
    0
    • M Member 10263519

      hi, am not getting what's wrong in this procedure: create procedure getpassword( in member varchar(20)) begin select password from admin where member_id = member end am getting error at "end" syntax error unexpected end,expecting ;

      G Offline
      G Offline
      GuyThiebaut
      wrote on last edited by
      #2

      Try this:

      create procedure getpassword(@member varchar(20))
      as
      begin

      select password from admin where member_id = @member

      end

      “That which can be asserted without evidence, can be dismissed without evidence.”

      ― Christopher Hitchens

      M 1 Reply Last reply
      0
      • G GuyThiebaut

        Try this:

        create procedure getpassword(@member varchar(20))
        as
        begin

        select password from admin where member_id = @member

        end

        “That which can be asserted without evidence, can be dismissed without evidence.”

        ― Christopher Hitchens

        M Offline
        M Offline
        Member 10263519
        wrote on last edited by
        #3

        am executing it in workbench, am i right. still am getting error at @

        G 1 Reply Last reply
        0
        • M Member 10263519

          hi, am not getting what's wrong in this procedure: create procedure getpassword( in member varchar(20)) begin select password from admin where member_id = member end am getting error at "end" syntax error unexpected end,expecting ;

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

          You need to put a semi-colon at the end of your statement before the END keyword :

          CREATE PROCEDURE getpassword( IN member varchar(20))
          BEGIN
          SELECT password FROM admin WHERE member_id = member**;**
          END

          When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

          M 3 Replies Last reply
          0
          • M Member 10263519

            am executing it in workbench, am i right. still am getting error at @

            G Offline
            G Offline
            GuyThiebaut
            wrote on last edited by
            #5

            How are you calling the procedure? It should work if you call the stored procedure in one of the two following ways:

            getpassword @member = 'fred smith'

            getpassword 'fred smith'

            “That which can be asserted without evidence, can be dismissed without evidence.”

            ― Christopher Hitchens

            1 Reply Last reply
            0
            • W Wayne Gaylard

              You need to put a semi-colon at the end of your statement before the END keyword :

              CREATE PROCEDURE getpassword( IN member varchar(20))
              BEGIN
              SELECT password FROM admin WHERE member_id = member**;**
              END

              When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

              M Offline
              M Offline
              Member 10263519
              wrote on last edited by
              #6

              How to test it in workbench, whether it's working or not.

              1 Reply Last reply
              0
              • W Wayne Gaylard

                You need to put a semi-colon at the end of your statement before the END keyword :

                CREATE PROCEDURE getpassword( IN member varchar(20))
                BEGIN
                SELECT password FROM admin WHERE member_id = member**;**
                END

                When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                M Offline
                M Offline
                Member 10263519
                wrote on last edited by
                #7

                thanq , how can i test in workbench, whether in query, or at stored procedures

                1 Reply Last reply
                0
                • W Wayne Gaylard

                  You need to put a semi-colon at the end of your statement before the END keyword :

                  CREATE PROCEDURE getpassword( IN member varchar(20))
                  BEGIN
                  SELECT password FROM admin WHERE member_id = member**;**
                  END

                  When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

                  M Offline
                  M Offline
                  Member 10263519
                  wrote on last edited by
                  #8

                  how can i test whether it's working or not in workbench. am testing in query as: execute getpassword 'stl123'; but it's giving errors. and in my c# code is:

                  MySqlCommand command = new MySqlCommand("getpassword", con);
                  command.CommandType = System.Data.CommandType.StoredProcedure;
                  command.Parameters.AddWithValue("@member", txtuser.Text);
                  con.Open();
                  using (MySqlDataReader rdr = command.ExecuteReader())
                  {
                  if (rdr.Read())
                  {

                  reader object rdr is showing no rows.

                  G 1 Reply Last reply
                  0
                  • M Member 10263519

                    how can i test whether it's working or not in workbench. am testing in query as: execute getpassword 'stl123'; but it's giving errors. and in my c# code is:

                    MySqlCommand command = new MySqlCommand("getpassword", con);
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@member", txtuser.Text);
                    con.Open();
                    using (MySqlDataReader rdr = command.ExecuteReader())
                    {
                    if (rdr.Read())
                    {

                    reader object rdr is showing no rows.

                    G Offline
                    G Offline
                    GuyThiebaut
                    wrote on last edited by
                    #9

                    Change this:

                    Member 10263519 wrote:

                    command.Parameters.AddWithValue("@member", txtuser.Text);

                    To this(remove the @ as it is not required from .net):

                    Member 10263519 wrote:

                    command.Parameters.AddWithValue("member", txtuser.Text);

                    “That which can be asserted without evidence, can be dismissed without evidence.”

                    ― Christopher Hitchens

                    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