<small id='2a7hE'></small><noframes id='2a7hE'>

        <tfoot id='2a7hE'></tfoot>
      1. <legend id='2a7hE'><style id='2a7hE'><dir id='2a7hE'><q id='2a7hE'></q></dir></style></legend>
          <bdo id='2a7hE'></bdo><ul id='2a7hE'></ul>
        <i id='2a7hE'><tr id='2a7hE'><dt id='2a7hE'><q id='2a7hE'><span id='2a7hE'><b id='2a7hE'><form id='2a7hE'><ins id='2a7hE'></ins><ul id='2a7hE'></ul><sub id='2a7hE'></sub></form><legend id='2a7hE'></legend><bdo id='2a7hE'><pre id='2a7hE'><center id='2a7hE'></center></pre></bdo></b><th id='2a7hE'></th></span></q></dt></tr></i><div id='2a7hE'><tfoot id='2a7hE'></tfoot><dl id='2a7hE'><fieldset id='2a7hE'></fieldset></dl></div>

      2. 更新变量的MYSQL存储过程为0

        MYSQL stored procedure for update variables are 0(更新变量的MYSQL存储过程为0)
              <bdo id='ab1lY'></bdo><ul id='ab1lY'></ul>

                  <tbody id='ab1lY'></tbody>

                  <i id='ab1lY'><tr id='ab1lY'><dt id='ab1lY'><q id='ab1lY'><span id='ab1lY'><b id='ab1lY'><form id='ab1lY'><ins id='ab1lY'></ins><ul id='ab1lY'></ul><sub id='ab1lY'></sub></form><legend id='ab1lY'></legend><bdo id='ab1lY'><pre id='ab1lY'><center id='ab1lY'></center></pre></bdo></b><th id='ab1lY'></th></span></q></dt></tr></i><div id='ab1lY'><tfoot id='ab1lY'></tfoot><dl id='ab1lY'><fieldset id='ab1lY'></fieldset></dl></div>

                • <legend id='ab1lY'><style id='ab1lY'><dir id='ab1lY'><q id='ab1lY'></q></dir></style></legend><tfoot id='ab1lY'></tfoot>

                  <small id='ab1lY'></small><noframes id='ab1lY'>

                  本文介绍了更新变量的MYSQL存储过程为0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 MYSQL 数据库中有以下存储过程.存储过程得到 lon、lat 并且我正在对不同的数据库和表进行更新.

                  I have the following stored procedure in a MYSQL database. The stored procedure gets lon,lat and than I'm doing an update on a different database and table.

                  DROP PROCEDURE IF EXISTS annuals.updateSalesFlorida;
                  CREATE DEFINER=`dddd`@`%` PROCEDURE `updateSales`(propertyId int)
                  BEGIN
                  
                     DECLARE lat   FLOAT;
                      DECLARE lon FLOAT;
                  
                  
                    SELECT  SitusLongitude,SitusLatitude
                    INTO lon,lat
                    FROM annuals.florida
                    WHERE PropertyID=propertyId
                    LIMIT 1 FOR UPDATE;
                  
                    UPDATE sales.florida
                    SET
                      `SitusLongitude` = lon,
                      `SitusLatitude` = lat
                    WHERE PROPERTYUNIQUEID=propertyId;
                  
                  END;
                  

                  每次运行存储过程时,SitusLongitudeSitusLatitude 列都是 0.我知道之前选择的 SitusLongitudeSitusLatitude 在那里有实际值.出于某种原因,变量没有设置在纬度,经度.知道我做错了什么吗?

                  Every time I run the stored procedure the SitusLongitude and SitusLatitude columns are 0. I know for a fact that the previous selected SitusLongitude and SitusLatitude have actual values in there. For some reason the variables are not being set in lat,lon. Any idea what I'm dong wrong?

                  推荐答案

                  问题是过程参数与表中的列同名.当您在查询中引用 propertyid 时,它使用的是列,而不是参数.列名和变量名不区分大小写,因此您拼写其中一个 PropertyID 和另一个 propertyId 无关紧要.

                  The problem is that the procedure parameter has the same name as a column in the tables. When you refer to propertyid in the queries, it uses the column, not the parameter. Column and variable names are case-insensitive, so it doesn't matter that you spelled one of them PropertyID and the other propertyId.

                  为参数使用不同的名称,例如p_propertyId

                  Use a different name for the parameter, e.g. p_propertyId

                  此外,不需要两个查询,您可以使用 JOIN 将其合二为一.

                  Also, there's no need for two queries, you can do it in one with a JOIN.

                  UPDATE sales.florida AS s
                  CROSS JOIN (
                      SELECT *
                      FROM annuals.florida
                      WHERE propertyId = p_propertyId
                      LIMIT 1) AS a
                  SET s.SitusLongitude = a.SitusLongitude, s.SitusLatitude = a.SitusLatitude
                  WHERE s.PROPERTYUNIQUEID = p_propertyId
                  

                  请注意,使用 LIMIT 而没有 ORDER BY 意味着被选中的行将是不可预测的.

                  Note that using LIMIT without ORDER BY means that the row that's selected will be unpredictable.

                  这篇关于更新变量的MYSQL存储过程为0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Accessing another user#39;s table within an Oracle Stored Procedure(在 Oracle 存储过程中访问另一个用户的表)
                  How to View Oracle Stored Procedure using SQLPlus?(如何使用 SQLPlus 查看 Oracle 存储过程?)
                  How to Pass Java List of Objects to Oracle Stored Procedure Using MyBatis?(如何使用 MyBatis 将 Java 对象列表传递给 Oracle 存储过程?)
                  Set the variable result, from query(设置变量结果,来自查询)
                  What is dynamic SQL?(什么是动态 SQL?)
                  Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)
                    <tbody id='68bHj'></tbody>

                    <small id='68bHj'></small><noframes id='68bHj'>

                  1. <legend id='68bHj'><style id='68bHj'><dir id='68bHj'><q id='68bHj'></q></dir></style></legend>
                  2. <i id='68bHj'><tr id='68bHj'><dt id='68bHj'><q id='68bHj'><span id='68bHj'><b id='68bHj'><form id='68bHj'><ins id='68bHj'></ins><ul id='68bHj'></ul><sub id='68bHj'></sub></form><legend id='68bHj'></legend><bdo id='68bHj'><pre id='68bHj'><center id='68bHj'></center></pre></bdo></b><th id='68bHj'></th></span></q></dt></tr></i><div id='68bHj'><tfoot id='68bHj'></tfoot><dl id='68bHj'><fieldset id='68bHj'></fieldset></dl></div>
                  3. <tfoot id='68bHj'></tfoot>

                        <bdo id='68bHj'></bdo><ul id='68bHj'></ul>