我的光标有什么问题? [英] whats wrong with my cursor?

查看:63
本文介绍了我的光标有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我将光标声明为:

DECLARE DISCSR CURSOR

SELECT JOB_I
来自ALI.TDSP_JOB_XRF

WHERE ORD_I =:wsOrdI

AND DSP_NBR = 1

WITH UR;


但我一直收到错误:

SQL0104N一个意外的令牌:"发现在WHERE ORD_I =之后。预期的令牌可以包括:< space>。 LINE NUMBER = 33。 SQLSTATE = 42601


但如果我删除了:,我会收到错误:WSORDI在使用它的上下文中无效。 LINE NUMBER = 30。 SQLSTATE = 42703


如何解决此问题?

Hi all,

I have a cursor declared as:
DECLARE dispCSR CURSOR FOR
SELECT JOB_I
FROM ALI.TDSP_JOB_XRF
WHERE ORD_I = :wsOrdI
AND DSP_NBR = 1
WITH UR;

but i keep getting the error:
SQL0104N An unexpected token ":" was found following "WHERE ORD_I =". Expected tokens may include: "<space>". LINE NUMBER=33. SQLSTATE=42601

but if i do remove the ":", i get the error: "WSORDI" is not valid in the context where it is used. LINE NUMBER=30. SQLSTATE=42703

how do i fix this?

推荐答案


大家好,


我将光标声明为:

DECLARE dispCSR CURSOR

SELECT JOB_I

FROM ALI.TDSP_JOB_XRF

WHERE ORD_I =:wsOrdI

AND DSP_NBR = 1

WITH UR;


但我一直收到错误:

SQL0104N一个意外的令牌:"发现在WHERE ORD_I =之后。预期的令牌可以包括:< space>。 LINE NUMBER = 33。 SQLSTATE = 42601


但如果我删除了:,我会收到错误:WSORDI在使用它的上下文中无效。 LINE NUMBER = 30。 SQLSTATE = 42703


我该如何解决这个问题?
Hi all,

I have a cursor declared as:
DECLARE dispCSR CURSOR FOR
SELECT JOB_I
FROM ALI.TDSP_JOB_XRF
WHERE ORD_I = :wsOrdI
AND DSP_NBR = 1
WITH UR;

but i keep getting the error:
SQL0104N An unexpected token ":" was found following "WHERE ORD_I =". Expected tokens may include: "<space>". LINE NUMBER=33. SQLSTATE=42601

but if i do remove the ":", i get the error: "WSORDI" is not valid in the context where it is used. LINE NUMBER=30. SQLSTATE=42703

how do i fix this?






我知道你正在使用动态游标。

我需要一些更多信息...

WSORDI是变量吗?

干杯

Hi,

I understand u are using a dynamic cursor.
I need some more info...
Is WSORDI a variable?
Cheers


是的,WSORDI是一个INTEGER变量。光标将根据WSORDI的值获取数据(这将是用户输入的形式)


谢谢!

yes, WSORDI is an INTEGER variable. The cursor will fetch data depending on the value of WSORDI (this will be form user input)

thanks!





我知道你正在使用动态游标。

我需要更多信息...

WSORDI是变量吗?

干杯
Hi,

I understand u are using a dynamic cursor.
I need some more info...
Is WSORDI a variable?
Cheers




是的,WSORDI是一个INTEGER变量。光标将根据WSORDI的值获取数据(这将是用户输入的形式)


谢谢!
yes, WSORDI is an INTEGER variable. The cursor will fetch data depending on the value of WSORDI (this will be form user input)

thanks!



我认为你已经使用了oracle语法。

你可以在游标声明中有一个动态语句

代码块可以是:


声明v_variable整数;

声明v_sql varchar(500);


为v_sql_stmt声明v_cursor游标;


set v_sql =''从表中选择*,其中col1 =?'';


从中准备v_sql_stmt v_sql;

使用v_variable打开v_cursor;


fetch循环.....

关闭v_cursor;


希望这篇文章有用..

干杯

I think you have used the oracle syntax.
You can have a dynamic statement in the cursor declaration
The code block can be like:

declare v_variable integer;
declare v_sql varchar(500);

declare v_cursor cursor for v_sql_stmt;

set v_sql=''Select * from table where col1 = ?'';

Prepare v_sql_stmt from v_sql;
open v_cursor using v_variable;

fetch loop.....
close v_cursor;

Hope this post was helpful..
Cheers


这篇关于我的光标有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆