Using CallableStatement.wasNull() after getObject()
In our aplpication we are returning ResultSets from PL/SQL functions. We use CallableStatement.getObject()
to return the ResultSet. After calling getObject we call wasNull() to make sure
we did receive something.
Originally we were using the jcbd thin driver provided by Oracle and our code
ran fine. We had problems with that driver and switched to the OCI driver. The
OCI driver does not like our code calling wasNull after getObject(). It throws
and exception saying we have not called a getXXX method yet.
The specification is kind of vague on this, it says wasNull can be called after
any getXXX method. My question is, is there a problem with the OCI driver or
is or code wrong?
Below is a snippet of code that worked with the thin driver but not with the OCI
driver:
CallableStatement _stmt = null;
int _arg = 1;
try {
stmt = connection.prepareCall(GET_OTHER_PERFORMANCE_ASSETS_STMT);
stmt.registerOutParameter(arg++, sonymusic.util.JDBCHelper.SONYMUSIC_CURSOR);
if (inSiteId == null) {
stmt.setNull(arg++, java.sql.Types.BIGINT);
} else {
stmt.setLong(arg++, inSiteId.longValue());
if (inPerformanceId == null) {
stmt.setNull(arg++, java.sql.Types.BIGINT);
} else {
stmt.setLong(arg++, inPerformanceId.longValue());
if (authUserIdIn == null) {
stmt.setNull(arg++, java.sql.Types.BIGINT);
} else {
stmt.setLong(arg++, authUserIdIn.longValue());
_stmt.execute();
java.sql.ResultSet result = (java.sql.ResultSet)stmt.getObject(1);
if (_stmt.wasNull())
return null;
else
return _result;
Hi Jeff,
as mentioned in the spec, refereing to the doc you refered to earlier:
You should be able to get the resultset first and then read the param on the
resultset and then make a call to CallableStatement.wasNull to discover if
the read returned a SQL "NULL". (if this value read from the resultset is a
SQL "NULL" the wasNull() call will return a true).
Hope this answers your questions here and clears up any confusion with the
java null and, the SQL NULL that the wasNull call detects.
getObject() is basically returning you what you asked it to return when you
registered the out parameter.
http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec/jdbc-spec.frame7.html
7.3.2 Retrieving NULL values as OUT parameters
As with ResultSets, in order to determine if a given OUT parameter value is
SQL "NULL" you must first read the parameter and then use the
CallableStatement.wasNull method to discover if the read returned a SQL
"NULL".
When you read a SQL "NULL" value using one of the CallableStatement.getXXX
methods, you will receive a value of null, zero, or false, following the
same rules specified in section 7.1.2 for the ResultSet.getXXX methods.
sree
"J Drost" <[email protected]> wrote in message
news:[email protected]...
>
I am comfortable with a getXXX on available returning an empty result setif the
pl/sql function itself returned an empty result set (if you do 'where 1 =0');
Just as I am comfortable with a getInt invocation returning a 0 if thepl/sql
function itself returned a 0. Or Course.
I do however expect to be able to check wasNull on the CallableStatementafter
getting a ResultSet from an out parameter. If the pl/sql function itselfdid
not return a result set (it is possible in Oracle to simply not return avalue
from a function), then I expect wasNull to return true.
I would imaging that it is open to discussion what the getXXX shouldreturn if
the database doesn't return anything. I would expect a null (after all Iam calling
getObject, and you wouldn't expect the driver any other kind of emptyobject,
so why an empty result set) but you could argue that an empty result setwould
be acceptable. Regardless of that argument; if a function didn't returnthe result
set, after the getXXX the wasNull should return true. Otherwise thedriver is
hiding the actual results of the database call.
Jeff
"Sree Bodapati" <[email protected]> wrote:
And I would like to add this note from 'Joe' here :
"an empty result set is still a result set, not a null.
Applications may well run queries that return no rows, but the
application
may still want the result set metadata, which is only available from
the resultset. In fact some applications purposely execute queries
with a clause like 'where 1 = 0' to ensure no rows are returned, but
guarantee that they get the metadata."
"Sree Bodapati" <[email protected]> wrote in message
news:[email protected]...
If you read through the same doc an little furture, They talk about
resultsets,
7.3.2 Retrieving NULL values as OUT parameters
As with ResultSets, in order to determine if a given OUT parametervalue
is
SQL "NULL" you must first read the parameter and then use the
CallableStatement.wasNull method to discover if the read returned aSQL
"NULL".
When you read a SQL "NULL" value using one of the
CallableStatement.getXXX
methods, you will receive a value of null, zero, or false, followingthe
same rules specified in section 7.1.2 for the ResultSet.getXXX methods.
hth
sree
"J Drost" <[email protected]> wrote in message
news:[email protected]...
Is their any explanation as to why a default value (an empty result
set)
is returned
without setting the wasNull flag? This behavior seems to be
inconsistent
with
the way other out parameters work. For example, when a function
that is
expected
to return a number doesn't return a value, the default value (zero)
is
returned
from the CallableStatement.getInt() method, but the wasNull flag
is set
to
true.
I don't know, it just doesn't seem consistent to me.
Also, you are saying that if I have a pl/sql function that returns
a
REFCURSOR
(a weakly typed cursor), and that function doesn't return a value,
then
the driver
is going to create a ResultSet for me that contains no rows and has
a
ResultSetMetaData
with a columnCount of zero? I would expect to get a java null based
on
what the
spec, as well as they way other parameter types work.
http://java.sun.com/j2se/1.3/docs/guide/jdbc/spec/jdbc-spec.frame7.html
7.1.2 Null result values
* A Java "null" value for those getXXX methods that return Javaobjects.
* A zero value for getByte, getShort, getInt, getLong, getFloat,and
getDouble
* A false value for getBoolean.
"Sree Bodapati" <[email protected]> wrote:
wasNull() checks to see if the last OUT param value is SQL NULL.
if
you
have a CURSOR (ResultSet equivalent) as the OUT param then it willnot
be
SQL NULL if no results are returned.
The Weblogic oci driver returns an empty resultset object in sucha
case.
I
dont think it sets the wasNull() to return true in such a scenario.
HTH
Sree
"Robert DeWilder" <robert@[email protected]> wrote in message
news:[email protected]...
In our aplpication we are returning ResultSets from PL/SQL
functions.
We
use CallableStatement.getObject()
to return the ResultSet. After calling getObject we call
wasNull()
to
make sure
we did receive something.
Originally we were using the jcbd thin driver provided by Oracle
and
our
code
ran fine. We had problems with that driver and switched to the
OCI
driver. The
OCI driver does not like our code calling wasNull after
getObject().
It
throws
and exception saying we have not called a getXXX method yet.
The specification is kind of vague on this, it says wasNull can
be
called
after
any getXXX method. My question is, is there a problem with the
OCI
driver
or
is or code wrong?
Below is a snippet of code that worked with the thin driver but
not
with
the OCI
driver:
CallableStatement _stmt = null;
int _arg = 1;
try {
_stmt =
connection.prepareCall(GETOTHER_PERFORMANCE_ASSETS_STMT);
stmt.registerOutParameter(arg++,sonymusic.util.JDBCHelper.SONYMUSIC_CURSOR);
if (inSiteId == null) {
stmt.setNull(arg++, java.sql.Types.BIGINT);
} else {
stmt.setLong(arg++, inSiteId.longValue());
if (inPerformanceId == null) {
stmt.setNull(arg++, java.sql.Types.BIGINT);
} else {
stmt.setLong(arg++, inPerformanceId.longValue());
if (authUserIdIn == null) {
stmt.setNull(arg++, java.sql.Types.BIGINT);
} else {
stmt.setLong(arg++, authUserIdIn.longValue());
_stmt.execute();
java.sql.ResultSet _result =
(java.sql.ResultSet)_stmt.getObject(1);
if (_stmt.wasNull())
return null;
else
return _result;
Similar Messages
-
Downloads used to open after download. NOw they just end up in the download folder and I have to go to the folder to find it and open it. I did not change seettings, maybe an update changed it? I cannot find a way to change this in settings.
== This happened ==
Every time Firefox opened
== A week or two ago. Not sure if result of most recent update.Downloads used to open after download. NOw they just end up in the download folder and I have to go to the folder to find it and open it. I did not change seettings, maybe an update changed it? I cannot find a way to change this in settings.
== This happened ==
Every time Firefox opened
== A week or two ago. Not sure if result of most recent update. -
I am unable to update my album art on my iMac since I started using Match (and after upgrading to Yosemite 10.10.3). A message advises that it's not possible to removed old artwork if it's embedded. How can I 'unembed' old cover art and replace?
Normally artwork recovered with iTunes is stored as a separate artwork file and iTunes refers to that file to display artwork when you click on a track. However, if you then copy the file to another player the artwork file is left behind and the track will not display the artwork on the other player. To get around this it is possible to embed the artwork in the music file itself so it always travels with the file. Artwork can be embedded by you or files from third party sources may arrive with embedded artwork. iTunes apparently now won't replace artwork for such files. You can accomplish this by completely deleting artwork for a file or set of files in Get Info, then getting iTunes to fetch artwork which will then be set as a reference file rather than being embedded.
I use an old iTunes so unless you are using an ancient iTunes it won't help for me to give you great details. To erase artwork I simply get info on a series of files and check the box next to the artwork box without adding any artwork and close. To do it for single file I Get Info, go to the artwork display tab and click delete. Here's a Windows reference for a newer iTunes (but the "old Get Info" reference is for early iTunes 12 and no longer works with newer):I cannot delete embedded album artwork in iTunes 12 -
I have chosen to fil migrate from old ibook to new MacBook Pro using Time Machine after establishing admin account. I now have two admin. accounts and wish to delete the later one and transfer files manually. I am worried I will loose both accounts. ??
Use the Office for Mac and ignore using Parallels for that. If you have PC only apps you have to run that are MS Windows only then consider Parallels. Just transfer your main PC, using Migration Assistant. If you don't know how then simply read over Pondini's article called Lion or Mountain Lion Setup Assistant tips and look for the section on migrating from a PC. Millions have done what you are about to, it's far from leading edge these days, if you go to an Apple Store to purchase they will offer this as a service, something you might be interested in.
-
Why can't i use my ipod after the battery died during a reformatting? i've tried many things to fix it.
I do not understand your question. You do not formate an iPod. Please explain better the problem. what lead up to the problem and what you have tried so far.
-
Why can't I use my ID after I reset my passward
my problem is why can't I use my ID after I reset my passward
please help me!!!
thanks a lot!!!I do not understand your question. You do not formate an iPod. Please explain better the problem. what lead up to the problem and what you have tried so far.
-
I'm using Iphone 5 .After updating it with the latest software i.e iOS 7.0.6 I'm not able to see the wats app and imsg on my notification center when my phone is locked until and unless i activate the "Show on Lock Screen" under each application. which was not same as in the earlier software version.I dnt want my messages or watsapp msges to be displayed on home screen when locked but should be displayed on the notification center on lock condition.
Please suggest a solution or @Apple please get a software release which can remove this bug .We aren't Apple, just users like you. Have you tried a reset? Hold down the home button along with the sleep/wake button until the screen goes black and you see the Apple, then let go. (No data loss)
-
How do I find the address -thread - of a file. I used to use spotlight but after switching to Mountain Lion it no longer gives me this.
Hold Command-Option while pointing to an item in the Spotlight list. Or Command-Click will show the item in the Finder.
-
I did an icloud backup on my old 4S with iOS 8.3 and wanted to install on my new iPhone 6 but it only has iOS 8.1.3! Can I do/use the backup after I chose "install as new iPhone"?
Because I cannot update the software until I chose if I want to begin with a new phone setting or download a backup.
But the backup is of course not compatible with the old iOS.
So will it be possible to get the new iPhone going, then do the software update to 8.3 and then download / use the data from
my 4S icloud backup?1. Settings > General > Software Update > Update the to 8.3
2. Settings > General > Reset > Erase All Content & Settings
3. Reactivate phone and follow prompts to restore iCloud (or iTunes) backup. -
There was some updayts for my iPad 4 automatically downloaded. After installing it, the iPad began to restart itself every few minutes.
I tryed to update my iPad using iTunes. After connecting to MacBook Pro, where is installed all latest software, iPad is recognised as "iPad", Serial Number: n/a. iTunes run recovery mode, trying to restore iPad firmware, and in the end unknown error occured (3). Tried many times, not results. And now iPad stays only in recovery mode, can't switch it off. How can I solve this problem please?When I restart my iPad the connect to iTunes comes up and stays on until it shuts down again, I have read a report from Apple support suggesting I reinstall iTunes so I might try that again and also your suggestion which i shall also try, but thanks again - rg1547
-
I have a pc that is one year old and the hard drive is crashing we use it only for quick books to run our small business I would like to buy a macmini and install the OS from the pc to the apple product i will not use the pc after, can i use the OS off the pc or do I have to purchase another?
I think you can get Windows 7 for around $99. Install the 64bit version as the 32bit version will not be able to use all your new computer's ram if you have more than about 3.5gb.
Back up your quick books data now before the old hard drive dies. You can copy your data over to your new installation of Windows and quick books.
By the way, there is quick books for Mac http://quickbooks.intuit.com/mac/?sc=BNR-000-COR-quickbooks&priorityCode=4902000 000&cid=ppc_google_QB-Intuit-Core-Brand-Mac_quick-books-for-mac_exact&site=&ad_i d=9347918288&raw_keyword=quick%20books%20for%20mac
So you may not need to install Windows at all. -
how do i get my photos back on usb after editing. i used export but after checking my photos were not back on usb?
You're really going to need to explain that. What's "USB"? Do you mean a Disk, Drive or volume connected by USB? How is your iphoto set up? What version are you using?
Regards
TD -
Just bought a used MacBook pro after my previous died. I want to migrate my applications, data, etc from a time machine backup of the old computer to the new. Will this affect, or overwrite the Apps., data, etc existing on the new machine?
No. Only those Apps that are not installed on the new will migrate over.
-
How can I return to use OSX (Yosemite) after installing Windows 8.1?
How can I return to use OSX (Yosemite) after installing Windows 8.1?
I cannot find Boot Camp on my iMac (late 2013) with windows installed. So I downloaded it, but I cannot run it because of an error (x64...). I tried to use my USB stick with bootcamp installed but nothing. When I turn my iMac on it starts automatically with windows. I tried to search it, but I found only the setup and it doesn't work. How can I get back to my APPLE iMac? How can I use OSX?
Excuse me for the (maybe) uncorrect language, I speak Italian.Hello!
You can start your Mac up with the [alt] (sometimes [option]) key pressed and you will get the Startup Manager. -
in on asset class i have created 2 assets by using of aso1 after that i acquired one asset for that i run the depreciation for first 5 periods, it has been showing depreciation for those period but if i am trying to run the depreciation for second asset it is not showing first 5 periods why it is not showing? Is there any reason?
Hi
Repeat run you can do only for the last depreciation period. For the asset which you are tryin to post depreciation from July to Jan, please check the asset value date which you have given while posting the transactions or in the asset master.
If the asset value date is in July, then deprecaition from July - Jan will get posted in the current month depreciation in total. You will not be able to post depreciation individually month wise using AFAB.
REgards
Malathi
Maybe you are looking for
-
Hello. How is it I can make a gradient swatch with a 90º angle (for example) a saved swatch? Whenever I have saved a gradient swatch it does not allow me to specify (or save) the angle I would like the gradient to run. So whenever I create a shape an
-
Permissions not being propagated to files
Hi. Wondering if anyone can help me. Iv recently updated to Mavericks & Server 3.0.2. Iv setup permissions on a shared folder using the server app. Works fine apart from files aren't getting the correct permissions. Instead they get a permission call
-
HTTP API to submit messages on SMPP: http://<server>:<port>/bulksms/bulksms?username=XXXX&password=YYYYY&type=Y&dlr=Z&destination=QQQQQQQQQ&source=RRRR&message=SSSSSSSS<&url=KKKK> <server>: smpp1.kapsystem.com.com, smpp2.kapsystem.com, smpp3.kapsyste
-
BO Edge 3.1 Where is the SDK?
Where can I find the sdk in BO Edge 3.1? I have developed using the SDK a few years back and looking to integrate BO into my ASP.NET application again. Thanks Tom
-
Get Error message "Key not valid in this status" using Win 8 Pro.
Hello Community, While I try to install the program i get the error message in the title. I downloaded it with t-online Homepage-plan. On both: Premiere Elements and Photoshop Elements 12. I using a 64bit based PC. Already tried: Running in XP-Mode S