我的MySql存储过程查询有什么问题?

时间:2018-04-11 07:34:39

标签: mysql sql stored-procedures cursor

我是mysql存储过程的新手。我希望我的商店程序检查字段日期中的日期值并与当前日期进行比较。如果当前日期大于表中的日期值,我想将字段status_number中的值更新为“0”。

这是我的问题:

string httpVersion = null;
if (state.RequestMessage.Version == HttpVersionInternal.Version10)
{
    httpVersion = "HTTP/1.0";
}
else if (state.RequestMessage.Version == HttpVersionInternal.Version11)
{
    httpVersion = "HTTP/1.1";
}

// ...

// Create an HTTP request handle.
state.RequestHandle = Interop.WinHttp.WinHttpOpenRequest(
    connectHandle,
    state.RequestMessage.Method.Method,
    state.RequestMessage.RequestUri.PathAndQuery,
    httpVersion,
    Interop.WinHttp.WINHTTP_NO_REFERER,
    Interop.WinHttp.WINHTTP_DEFAULT_ACCEPT_TYPES,
    flags);

// WILL USE HTTP/1.1 by default
[DllImport(Interop.Libraries.WinHttp, CharSet = CharSet.Unicode, SetLastError = true)]
public static extern SafeWinHttpHandle WinHttpOpenRequest(
    SafeWinHttpHandle connectHandle,
    string verb,
    string objectName,
    string version,
    string referrer,
    string acceptTypes,
    uint flags);

错误讯息:

enter image description here

感谢回答。

2 个答案:

答案 0 :(得分:0)

int

答案 1 :(得分:0)

检查一下。它在mssql上测试过。我尝试将其转换为mysql但未在mysql上进行测试,但我希望它能正常工作。

DELIMITER //

CREATE PROCEDURE check_status()

BEGIN
DECLARE NOT_FOUND INT DEFAULT 0;

DECLARE v_dd DATE;
-- DECLARE @bDone INT;
-- DECLARE @Count INT;


DECLARE v_name VARCHAR(50); -- database name 
DECLARE v_path VARCHAR(256); -- path for backup files 
DECLARE v_fileName VARCHAR(256); -- filename for backup 
DECLARE v_fileDate VARCHAR(20); -- used for file name 

DECLARE db_cursor CURSOR FOR 

SELECTdates INTO v_dd 
FROM t_date

OPEN 
DECLARE CONTINUE HANDLER FOR NOT FOUND SET NOT_FOUND = 1;db_cursor  
 -- SET @bDone = 0;
FETCH NEXT FROM; db_cursor INTO v_dd  

WHILE NOT_FOUND = 0  
DO  

        IF (v_dd < cast (Now() as date) )
        Then
                    UPDATE t_date SET status_number   =  1;
        END IF; 

      FETCH NEXT FROM; db_cursor INTO v_dd  
END WHILE; 

CLOSE db_cursor;  
END;
//

DELIMITER ;