在循环中创建var plsql oracle 11g
我的功能将数字放在var(var1
)中。如果var1 = 3
,则创建 3 新变量,并为以后在OUT类型中发送该值的值。我不知道该怎么做,我的代码是这样的,其中“ pos”
的作用就像instr()
我知道它的每个 13 < /strong> chars。和“ newvar || var1”
是因为我希望我的var名称为newvar1
,newvar2
,newvar3
等。
FOR n IN 1..var1
LOOP
pos NUMBER(4):= 0;
newvar||var1 NUMBER(3);
newvar||var1 := SUBSTR(TO_NUMBER(numberInsideString), 1, 1+pos);
pos := pos+13;
END LOOP;
谢谢。
i have a function that puts a number in a var (var1
). if var1 = 3
then create 3 new variables and assign a value for later send that values in an out type. I don't know how can i do, my code is something like this where "pos"
acts like an INSTR()
that i know its each 13 chars. And "newvar||var1"
is because i want my vars names be newvar1
, newvar2
, newvar3
, etc.:
FOR n IN 1..var1
LOOP
pos NUMBER(4):= 0;
newvar||var1 NUMBER(3);
newvar||var1 := SUBSTR(TO_NUMBER(numberInsideString), 1, 1+pos);
pos := pos+13;
END LOOP;
My question is, how a person who really know PLSQL would do that, im learning PLSQL please help. thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想尝试做的事情表明,您需要一个维数数组,以重复为循环中的每个迭代分配新值。
OWA
的类型之一,例如vc_arr
(由varchar2 组成代码>数据类型值
)很方便地定义数组。
进入代码,您可以从将变量移动到声明部分开始,然后编写一个简单的代码,例如示例练习
What you want to try to do suggests that you need a one dimensional array in order repeatedly to assign new values for each iteration within the loop. One of the types in
OWA
package such asvc_arr
(composed ofVARCHAR2
data type values) is handy to define an array.Coming to the code, you can start with moving the variables into the declaration section, and write such a simple code as a sample exercise