What is the difference between odbcparameter and oledbparameter when adding char type values?











up vote
0
down vote

favorite












I'm migrating from Oracle to Tibero database using C#.



Issue is when adding parameter of "CHAR" type using OleDbParameter, data can not be retrieved unless it is filled with following spaces according to DB column size.



(Using OracleParameter or using OdbcParameter, it is possible to query normally without filling empty space as the actual column size)?



String sSQL = @"SELECT *
FROM V_PROD_MA
WHERE CAR_TYPE = :CAR_TYPE
AND BODY_NO = :BODY_NO";

OleDbDataAdapter adapter = null;
//OracleDataAdapter adapter = null;
DataTable table = new DataTable();

try
{
Open();

adapter = new OleDbDataAdapter(sSQL, Connetion);

adapter.SelectCommand.Parameters.Add("CAR_TYPE", OleDbType.Char, 4).Value = sCarType;
adapter.SelectCommand.Parameters.Add("BODY_NO", OleDbType.Char, 6).Value = sBodyNo;

adapter.Fill(table);
}


Above is a test source code and when i set sCarType = 'D0F ' then data is retrieved, but when i set sCarType = 'D0F' data is not retrieved.



Actual coloumn size is char(4).



you might suggest to change the sql where statement like trim(car_type), but we have about 2,000 sqls to change so we want to avoid that kind of solution.



And also we use a framework for wrapping each sql command, parameters and framework doesn't have information of column size to fill with empty spaces.



Is there any other way to avoid this kind of issue??










share|improve this question









New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You could complain to your database vendor. ANSI SQL mandates that 'D0F ' and 'D0F' compare equal (e.g. trailing spaces are ignored) precisely because of this issue. Oracle respects this, so does SQL Server. (It can cause other surprises, of course.) Tibero might have a setting that governs this (I don't know). Even if the parameter were passed as a CHAR(3), in the comparison it should be padded by promotion to CHAR(4) (the type of the column). Does this query work if you use a literal 'D0F'? If so, the error is in the DB driver; if not, it's in the engine itself.
    – Jeroen Mostert
    yesterday















up vote
0
down vote

favorite












I'm migrating from Oracle to Tibero database using C#.



Issue is when adding parameter of "CHAR" type using OleDbParameter, data can not be retrieved unless it is filled with following spaces according to DB column size.



(Using OracleParameter or using OdbcParameter, it is possible to query normally without filling empty space as the actual column size)?



String sSQL = @"SELECT *
FROM V_PROD_MA
WHERE CAR_TYPE = :CAR_TYPE
AND BODY_NO = :BODY_NO";

OleDbDataAdapter adapter = null;
//OracleDataAdapter adapter = null;
DataTable table = new DataTable();

try
{
Open();

adapter = new OleDbDataAdapter(sSQL, Connetion);

adapter.SelectCommand.Parameters.Add("CAR_TYPE", OleDbType.Char, 4).Value = sCarType;
adapter.SelectCommand.Parameters.Add("BODY_NO", OleDbType.Char, 6).Value = sBodyNo;

adapter.Fill(table);
}


Above is a test source code and when i set sCarType = 'D0F ' then data is retrieved, but when i set sCarType = 'D0F' data is not retrieved.



Actual coloumn size is char(4).



you might suggest to change the sql where statement like trim(car_type), but we have about 2,000 sqls to change so we want to avoid that kind of solution.



And also we use a framework for wrapping each sql command, parameters and framework doesn't have information of column size to fill with empty spaces.



Is there any other way to avoid this kind of issue??










share|improve this question









New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • You could complain to your database vendor. ANSI SQL mandates that 'D0F ' and 'D0F' compare equal (e.g. trailing spaces are ignored) precisely because of this issue. Oracle respects this, so does SQL Server. (It can cause other surprises, of course.) Tibero might have a setting that governs this (I don't know). Even if the parameter were passed as a CHAR(3), in the comparison it should be padded by promotion to CHAR(4) (the type of the column). Does this query work if you use a literal 'D0F'? If so, the error is in the DB driver; if not, it's in the engine itself.
    – Jeroen Mostert
    yesterday













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm migrating from Oracle to Tibero database using C#.



Issue is when adding parameter of "CHAR" type using OleDbParameter, data can not be retrieved unless it is filled with following spaces according to DB column size.



(Using OracleParameter or using OdbcParameter, it is possible to query normally without filling empty space as the actual column size)?



String sSQL = @"SELECT *
FROM V_PROD_MA
WHERE CAR_TYPE = :CAR_TYPE
AND BODY_NO = :BODY_NO";

OleDbDataAdapter adapter = null;
//OracleDataAdapter adapter = null;
DataTable table = new DataTable();

try
{
Open();

adapter = new OleDbDataAdapter(sSQL, Connetion);

adapter.SelectCommand.Parameters.Add("CAR_TYPE", OleDbType.Char, 4).Value = sCarType;
adapter.SelectCommand.Parameters.Add("BODY_NO", OleDbType.Char, 6).Value = sBodyNo;

adapter.Fill(table);
}


Above is a test source code and when i set sCarType = 'D0F ' then data is retrieved, but when i set sCarType = 'D0F' data is not retrieved.



Actual coloumn size is char(4).



you might suggest to change the sql where statement like trim(car_type), but we have about 2,000 sqls to change so we want to avoid that kind of solution.



And also we use a framework for wrapping each sql command, parameters and framework doesn't have information of column size to fill with empty spaces.



Is there any other way to avoid this kind of issue??










share|improve this question









New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm migrating from Oracle to Tibero database using C#.



Issue is when adding parameter of "CHAR" type using OleDbParameter, data can not be retrieved unless it is filled with following spaces according to DB column size.



(Using OracleParameter or using OdbcParameter, it is possible to query normally without filling empty space as the actual column size)?



String sSQL = @"SELECT *
FROM V_PROD_MA
WHERE CAR_TYPE = :CAR_TYPE
AND BODY_NO = :BODY_NO";

OleDbDataAdapter adapter = null;
//OracleDataAdapter adapter = null;
DataTable table = new DataTable();

try
{
Open();

adapter = new OleDbDataAdapter(sSQL, Connetion);

adapter.SelectCommand.Parameters.Add("CAR_TYPE", OleDbType.Char, 4).Value = sCarType;
adapter.SelectCommand.Parameters.Add("BODY_NO", OleDbType.Char, 6).Value = sBodyNo;

adapter.Fill(table);
}


Above is a test source code and when i set sCarType = 'D0F ' then data is retrieved, but when i set sCarType = 'D0F' data is not retrieved.



Actual coloumn size is char(4).



you might suggest to change the sql where statement like trim(car_type), but we have about 2,000 sqls to change so we want to avoid that kind of solution.



And also we use a framework for wrapping each sql command, parameters and framework doesn't have information of column size to fill with empty spaces.



Is there any other way to avoid this kind of issue??







c# oracle11g database-migration tibero






share|improve this question









New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited yesterday









JohnB

848715




848715






New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









justin.kim

11




11




New contributor




justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






justin.kim is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • You could complain to your database vendor. ANSI SQL mandates that 'D0F ' and 'D0F' compare equal (e.g. trailing spaces are ignored) precisely because of this issue. Oracle respects this, so does SQL Server. (It can cause other surprises, of course.) Tibero might have a setting that governs this (I don't know). Even if the parameter were passed as a CHAR(3), in the comparison it should be padded by promotion to CHAR(4) (the type of the column). Does this query work if you use a literal 'D0F'? If so, the error is in the DB driver; if not, it's in the engine itself.
    – Jeroen Mostert
    yesterday


















  • You could complain to your database vendor. ANSI SQL mandates that 'D0F ' and 'D0F' compare equal (e.g. trailing spaces are ignored) precisely because of this issue. Oracle respects this, so does SQL Server. (It can cause other surprises, of course.) Tibero might have a setting that governs this (I don't know). Even if the parameter were passed as a CHAR(3), in the comparison it should be padded by promotion to CHAR(4) (the type of the column). Does this query work if you use a literal 'D0F'? If so, the error is in the DB driver; if not, it's in the engine itself.
    – Jeroen Mostert
    yesterday
















You could complain to your database vendor. ANSI SQL mandates that 'D0F ' and 'D0F' compare equal (e.g. trailing spaces are ignored) precisely because of this issue. Oracle respects this, so does SQL Server. (It can cause other surprises, of course.) Tibero might have a setting that governs this (I don't know). Even if the parameter were passed as a CHAR(3), in the comparison it should be padded by promotion to CHAR(4) (the type of the column). Does this query work if you use a literal 'D0F'? If so, the error is in the DB driver; if not, it's in the engine itself.
– Jeroen Mostert
yesterday




You could complain to your database vendor. ANSI SQL mandates that 'D0F ' and 'D0F' compare equal (e.g. trailing spaces are ignored) precisely because of this issue. Oracle respects this, so does SQL Server. (It can cause other surprises, of course.) Tibero might have a setting that governs this (I don't know). Even if the parameter were passed as a CHAR(3), in the comparison it should be padded by promotion to CHAR(4) (the type of the column). Does this query work if you use a literal 'D0F'? If so, the error is in the DB driver; if not, it's in the engine itself.
– Jeroen Mostert
yesterday

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






justin.kim is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183875%2fwhat-is-the-difference-between-odbcparameter-and-oledbparameter-when-adding-char%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








justin.kim is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















justin.kim is a new contributor. Be nice, and check out our Code of Conduct.













justin.kim is a new contributor. Be nice, and check out our Code of Conduct.












justin.kim is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53183875%2fwhat-is-the-difference-between-odbcparameter-and-oledbparameter-when-adding-char%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

横浜市

Prokocim

Hungria