什么是ROWNUM的OracleType [英] What is the OracleType of ROWNUM

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

问题描述

我试图对其进行参数我们所有现有的SQL,但下面的code是给了我一个问题:

I am trying to parameterise all our existing sql, but the following code is giving me a problem:

command.CommandText = String.Format("SELECT * FROM({0}) 
       WHERE ROWNUM <= :maxRecords", command.CommandText);
command.Parameters
       .Add("maxRecords", OracleType.Int32).Value = maxRecords;

报告的错误是ORA-01036:非法的变量名/编号。

The error reported is "ORA-01036: illegal variable name/number".

我认为,这是因为OracleType.Int32是不正确的数据类型ROWNUM。那么是什么呢?

I assume that this is because OracleType.Int32 is not the correct datatype for ROWNUM. So what is it?

推荐答案

在sqlplus中,我们可以创建一个视图包含 ROWNUM 来看看到底是什么使用数据类型Oracle使用:

In SQLPlus we can create a view that includes rownum to see exactly what datatype Oracle uses:

TEST>create view v_test as select rownum rn, dummy from dual;

View created.

TEST>desc v_test
 Name     Null?    Type
 -------- -------- -------------
 RN                NUMBER
 DUMMY             VARCHAR2(1)

所以到Oracle,这虚列是一个数字。其中基于此链接(<一href="http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#i16209">http://download.oracle.com/docs/cd/B28359_01/server.111/b28318/datatype.htm#i16209 )可容纳:

The following numbers can be stored in a NUMBER column:

-Positive numbers in the range 1 x 10^-130 to 9.99...9 x 10^125 with up to 38 significant digits
-Negative numbers from -1 x 10^-130 to 9.99...99 x 10^125 with up to 38 significant digits
-Zero
-Positive and negative infinity (generated only by importing from an Oracle Database, Version 5)

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

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