我的代码是:下面是我的光标声明,但它显示错误1324:未定义光标为什么?请帮帮我
Set v_sqlCmd1 = CONCAT('DECLARE endtCursor Cursor for Select endorsementId from TxnEndorsement where txnRecNo=' + Cast(p_txnRecNo As char (20)));
SET @stmt_str = v_sqlCmd1;
PREPARE stmt FROM @stmt_str;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
OPEN endtCursor;//shows error 1324:undefined endtCursor
是否有错误来取消游标?
答案 0 :(得分:0)
如果我没有错,你试图在MYSQL中编写存储过程 问题不在于Cursor。
由于您尚未粘贴整个存储过程,
标准存储过程就像这样
drop procedure if exists procname;
delimiter $$
create procedure procname
(
in arg int default 0
)
begin
## Do the operations you want here your cursor and whatever
end$$
delimiter ;
我建议粘贴整个存储过程!希望有所帮助。
答案 1 :(得分:0)
看起来好像你还没有完全问过这个问题,但游标的语法看起来应该类似于:
Sub addEquals
oDoc = ThisComponent
oVC = oDoc.getCurrentController.getViewCursor
linenum_original = getLinenum(oVC)
For insertEqual = 1 to 255
oVC.collapseToEnd
oVC.gotoEndofLine(False)
oVC.getText().insertString(oVC, "=", False)
If getLinenum(oVC) <> linenum_original Then
' Remove the last =
oVC.gotoEndofLine(False)
oVC.goLeft(1, True)
oVC.setString("")
oVC.goRight(0, False)
oVC.collapseToEnd
Exit For
End If
Next insertEqual
End Sub
Function getLinenum(oVC)
nY = 0 'How many lines from top of page
nPage = oVC.getPage
while oVC.goUp(1, False) and oVC.getPage = nPage
nY = nY + 1
wend
oVC.goDown(nY, False)
getLinenum = nY
End Function