C#:Oracle 数据类型与 OracleDbType 的等效性 [英] C#: Oracle Data Type Equivalence with OracleDbType

查看:50
本文介绍了C#:Oracle 数据类型与 OracleDbType 的等效性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 C# 中创建一个应用程序,该应用程序使用 Oracle.DataAccess.Client (11g) 通过存储过程对 Oracle 数据库执行某些操作.我知道有一个包含 Oracle 数据类型的枚举 (OracleDbType),但我不确定对于某些类型使用哪一个.

I am creating an app in C# that uses Oracle.DataAccess.Client (11g) to do certain operations on a Oracle database with stored procedures. I am aware that there is a certain enum (OracleDbType) that contains the Oracle data types, but I am not sure which one to use for certain types.

  • 什么是等价的Oracle PL/SQL 数据type 中的每个枚举类型OracleDbType 枚举?

整型一共有三种
(Int16, Int32, Int64) 在 OracleDbType... 如何知道使用哪一个或它们都是
假设工作?

There are three types of integer
(Int16, Int32, Int64) in the OracleDbType... how to know which one to use or are they all
suppose to work?

推荐答案

OracleDbType 枚举的值在文档中定义.阅读ODP for .NET 开发人员指南.

The values of the OracleDbType Enumeration are defined in the documentation. Read the ODP for .NET Developer's Guide.

关于在Int16、Int32和Int64之间进行选择,它们都应该可以工作.选择与您的 .Net 变量的预期大小相匹配的一个:Int16 表示 -32768 和 32767 之间的值,Int32 表示 -2147483648 和 2147483647 之间的值,以及 Int64 表示更大的值.似乎有一些与转换 Int 和 PL/SQL 数据类型有关的有趣之处.检查 马克威廉姆斯的这篇博文.

With regards to choosing between Int16, Int32 and Int64, they are all supposed to work. Choose the one which matches the expected size of your .Net variable: Int16 for values between -32768 and 32767, Int32 for values between -2147483648 and 2147483647, and Int64 for anything larger. There appear to be some funnies relating to converting Ints and PL/SQL data types. Check this blog post by Mark Williams.

来自 2021 年的问候.这篇文章刚刚被点赞,所以想必搜索者仍在发现它并发现它很有用.但请注意,它已经有十多年历史了.因此,它提供的建议可能与更新版本的 ODP 无关,尤其是关于异常行为的建议.请不要在没有亲自验证的情况下遵循建议.(这是一般性建议,适用于您在 Internet 上阅读的任何内容,而不仅仅是软件开发!)

Greetings from 2021. This post has just been upvoted, so presumably Seekers are still finding it and finding it useful. But please note that it is more than ten years old. Consequently the advice it offers may not be relevant for more recent versions of ODP, particularly regarding unusual behaviour. Please don't follow recommendations without verifying them for yourself. (This is general advice which holds for anything you read on the Internet, and not just about software development!)

这是 Oracle 21c ODP 文档的相关链接.

这篇关于C#:Oracle 数据类型与 OracleDbType 的等效性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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