473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Oracle 9i: Problems with SQL parameters

Hello All.

Currently we are porting some software from NSK (HP Hon-Stop) SQL to Oracle
and I faced with the following problem...
The SQL statement:

select * from BOM where ordnr = :1

where value of parameter ":1" is "ORD195" returns no data (sqlcode 1403).
But the SQL:

select * from BOM where ordnr = 'ORD195'

returns 12 rows of data.
The field ORDNR is CHAR(16) and that should be so (VARCHAR(n) is not
acceptable here by requirements!).
I have tried to bind this parameters value as VARCHAR (not null-terminated)
and as STRING (null terminated) data types but the result was the same. :-(
As I got the

EXEC SQL DESCRIBE BIND VARIABLES FOR SqlDynaStmt INTO SqlDaIn;

does not provide information about parameters data types and lengthes then I
can not make any assumption about expected parameters values, datatypes,
lengthes, etc.

Later I found that this SQL statement works fine:

select * from BOM where trim(ordnr) = :1

But I do not wish to add TRIM() anywhere for CHAR(n) fields!!! :-\

It is pretty big problem for us because we want to use SQL parameters (like
it was in NSK SQL).
I wondering that even examples that delivered with Oracle9i (ansidyn1.pc,
sample10.pc) does not work correctly with CHAR(n) parameters in this case!

Could you please share some your experience concerning the case?
Could you please provide us with some adivices, etc.?
WBR, Dmitry.

ps. To repeat this case you can get SAMPLE10.EXE example from standard
Oracle, create "BOM" table with some CHAR(16) field, fill table with some
test data, enter that SQL with parameter and with constant instead of
parameter and compare results - that is exactly this case.
Jul 19 '05 #1
2 12470
"Dmitry Bond." <di******@ukr.net> wrote in message news:<10***************@moxa.united.net.ua>...
Hello All.

Currently we are porting some software from NSK (HP Hon-Stop) SQL to Oracle
and I faced with the following problem...
The SQL statement:

select * from BOM where ordnr = :1

where value of parameter ":1" is "ORD195" returns no data (sqlcode 1403).
But the SQL:

select * from BOM where ordnr = 'ORD195'

returns 12 rows of data.
The field ORDNR is CHAR(16) and that should be so (VARCHAR(n) is not
acceptable here by requirements!).
I have tried to bind this parameters value as VARCHAR (not null-terminated)
and as STRING (null terminated) data types but the result was the same. :-(
As I got the

EXEC SQL DESCRIBE BIND VARIABLES FOR SqlDynaStmt INTO SqlDaIn;

does not provide information about parameters data types and lengthes then I
can not make any assumption about expected parameters values, datatypes,
lengthes, etc.

Later I found that this SQL statement works fine:

select * from BOM where trim(ordnr) = :1

But I do not wish to add TRIM() anywhere for CHAR(n) fields!!! :-\

It is pretty big problem for us because we want to use SQL parameters (like
it was in NSK SQL).
I wondering that even examples that delivered with Oracle9i (ansidyn1.pc,
sample10.pc) does not work correctly with CHAR(n) parameters in this case!

Could you please share some your experience concerning the case?
Could you please provide us with some adivices, etc.?
WBR, Dmitry.

ps. To repeat this case you can get SAMPLE10.EXE example from standard
Oracle, create "BOM" table with some CHAR(16) field, fill table with some
test data, enter that SQL with parameter and with constant instead of
parameter and compare results - that is exactly this case.


String data stored in CHAR columns is padded to be the length of the
column. E.g 'ORD195 ' (of length 16) is actually stored in
the ordnr column.

String literals are of datatype CHAR. When comparing CHARs the shorter
string is right padded to the length of the longer one. Thus select *
from BOM where ordnr = 'ORD195' and select * from BOM where ordnr =
'ORD195 ' are equivalent.

Can you bind using a CHAR variable? If not, and you don't want to use
TRIM, then you could consider using RPAD to pad the variable value to
the length of the column, e.g.

select * from BOM where ordnr = rpad(:1,16)
Jul 19 '05 #2
"Ben Graham" <be*******@xsmail.com> wrote in message
news:f8**************************@posting.google.c om...
"Dmitry Bond." <di******@ukr.net> wrote in message news:<10***************@moxa.united.net.ua>...
[...] String data stored in CHAR columns is padded to be the length of the
column. E.g 'ORD195 ' (of length 16) is actually stored in
the ordnr column.

[...]

Thank you very much!
It is working when I set input parameter type to CHAR (96)...
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: susmita_ganguly | last post by:
Hi I am trying to upgrade from oracle 8i to oracle 9i on the same server ..I don't know much abt migration . Can anyone help me out. Thanks. Susmita
1
by: A.M. de Jong | last post by:
When I perform a query on a linked Oracle server in the Query analyser I have no prboblem' to perform this query. However, when I create this query in a stored procedure I get a compilation error...
9
by: AnandaSim | last post by:
Hi All, I've had Access 97, 2000 connections to the corporate Oracle database for a few years now - but seldom use it. When I did use it years ago, performance was not fast but the features were...
19
by: Parveen | last post by:
I am having trouble setting the update command of my oracle adapter to the name of an Oracle stored procedure. My data adapter is a global variable that I use in multiple functions. But the...
2
by: André Nobre | last post by:
I don't know if this is the right place to make this question, so, if isn't, let me know... I have an oracle package with some procedures, and i need to access one procedure using vb.net. The...
1
by: James | last post by:
I am getting frustrated of the PHP 5 releases chocking on OCI8 -- they just seem really unstable as do recent ISAPI filters when run on Windows 2003 Server. As an example the newest PHP 5.1.4...
9
by: Frank | last post by:
Hi, imagine there's a WEB application reading data from an Oracle database to visualize in using DataGrids in the clients browser. Yes, sounds simple, just create OracleConnection + OracleCommand...
2
by: vvenk | last post by:
Hello: I wrote a small program to insert a row into an Oracle Table: CREATE TABLE case_list (case_list_name_c VARCHAR2(100) NOT NULL, expiry_dt DATE NOT...
3
by: hakiran | last post by:
Hello all, I have been using Perl DBI the last 6months or so. I use it extensively with MySQL. But recently i tried to access Oracle DB with it and was having trouble. Any help would be...
7
by: samayjain | last post by:
Dear , Please let me know the correct answer for the following 1.Which three statements about subqueries are true? (Choose three.) A. A single row subquery can retrieve only one column and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.