Distinguishing between empty string and null values
hi all,
I am using an ODBC connection to connect my java app to database using JDBCODBC driver. I have 2 columns 'aColumn' and 'bColumn' in my table, both allow null values. I have one row in it, which has null value in aColumn and empty string in bColumn. I retrieve this row's data and assign it to 2 columns : 'aColumnVar' and 'bColumnVar' respectively. I find out that both 'aColumnVar' and 'bColumnVar' variables has null values (although bColumnVar should has an empty string as its value). Now my ODBC connection Data Source has the option "Use ANSI nulls, paddings, and warnings" ON. I turn it off and try again. This time both 'aColumnVar' and 'bColumnVar' variables has empty string as values (although aColumnVar should has null as its value).
How can I make sure that i can get the data exactly as it is in the database in my variables?
Thanks
there is a wasNull() method on ResultSet. After you
have obtained the value of a column e.g. by calling a
method like getString you can call wasNull and if it
returns true then the value on the database is null.
Check the java docs, it might explain it better
http://java.sun.com/j2se/1.4.1/docs/api/java/sql/Result
et.html#wasNull()I am using MS SQL Server 7.0 under Windows NT 4.0 with JDK 1.2. My ODBC connection Data Source has to have the option "Use ANSI nulls, paddings, and warnings" ON.
I try the wasNull() method but it is doing the same thing i.e. telling me that a column is null when in database it is null (right); and a column is null when in database it is an empty string (wrong). I suspect it is something to do with the JDBC-ODBC driver I am using.
Similar Messages
-
Hi,
Does oracle treat empty string as NULL.
If it is so,Can we force db to treat both as different things.
Thanx11g.DBA wrote:
Hi,
Does oracle treat empty string as NULL.Yes.
If it is so,Can we force db to treat both as different things.No.
Please read in SQL Reference:
http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements005.htm#SQLRF3003 -
How to check empty string and null? Assign same value to multiple variables
Hi,
1.
How do I check for empty string and null?
in_value IN VARCHAR2
2. Also how do I assign same value to multiple variables?
var_one NUMBER := 0;
var_two NUMBER := 0;
var_one := var_two := 0; --- Gives an error
ThanksMichaelS wrote:
Not always: Beware of CHAR's:
Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL:
SQL> declare
2 l_str1 char (10) := '';
3 l_str2 char (10) := null;
4 begin
5
6 if l_str1 is null
7 then
8 dbms_output.put_line ('oh STR1 is null');
9 elsif l_str1 is not null
10 then
11 dbms_output.put_line ('oh STR1 is NOT null');
12 end if;
13
14 if l_str2 is null
15 then
16 dbms_output.put_line ('oh STR2 is null');
17 elsif l_str2 is not null
18 then
19 dbms_output.put_line ('oh STR2 is NOT null');
20 end if;
21 end;
22 /
oh STR1 is NOT null
oh STR2 is null
PL/SQL procedure successfully completed.
SQL> alter session set events '10932 trace name context forever, level 16384';
Session altered.
SQL> declare
2 l_str1 char (10) := '';
3 l_str2 char (10) := null;
4 begin
5
6 if l_str1 is null
7 then
8 dbms_output.put_line ('oh STR1 is null');
9 elsif l_str1 is not null
10 then
11 dbms_output.put_line ('oh STR1 is NOT null');
12 end if;
13
14 if l_str2 is null
15 then
16 dbms_output.put_line ('oh STR2 is null');
17 elsif l_str2 is not null
18 then
19 dbms_output.put_line ('oh STR2 is NOT null');
20 end if;
21 end;
22 /
oh STR1 is null
oh STR2 is null
PL/SQL procedure successfully completed.
SQL> SY. -
How to differentiate the EMPTY Records and Null Values in DSO
Hello....how is everyone here?? Ehehehe!
I try to load some data from the flat file which contains some EMPTY data and Null Values for the records. The data type for the InfoObjects of the fields "Quantity" is "number". The sample data from the flat file (CSV) are as below:
Food Quantity
Hamburger - 12
Cheese - 0
Vegetable - (Empty)
When I try to load the above sample data to the DSO, I get the results of the data as follow:
Food Quantity
Hamburger - 12.000
Cheese - 0.000
Vegetable - 0.000
In this case, how can the user differentiate whether the records is contain empty value of null values in DSO? This is kinda of hard to differentiate the both scenarios above. Is there any way to differentiate the scenarios described here?
Thanks alot =)Hi Fluffy,
It depends on the initial values of the data type
The inital values For quantity/Currency/ Numbers it takes spaces as 0
for char it is SPACE
We cannot differeniate between space and null values.
IF you have to force this then define quantity as char and load the data. we will not have units and aggregation in this case.
Hope this helps.
PV -
Varchar2, empty strings and NULL
Hi all,
When inserting an empty string into a column of type varchar2 - is a NULL value stored in the column by the database? I've seen conflicting reports, and I know that the SQL 1992 spec specifies that empty strings not be treated as a NULL value, but that Oracle has traditionally treated zero length strings stored in a varchar2 column as NULL.
So, is there a way to store an empty string in a varchar2 column as an empty string and not a NULL value?
TIA,
SethIt can be even more complicated or annoying than NULL not equal to ASCII NULL.
example:
create table test_null
(fld1 varchar2(10),
fld2 varchar2(10),
fld3 varchar2(20));
insert into test_null values (chr(0),null, 'chr(0) and null');
insert into test_null values (null, null, 'null and null');
insert into test_null values ('', chr(0), ''''' and chr(0)');
insert into test_null values ('', null, ''''' and null');
select * from test_null;
FLD1 FLD2 FLD3
chr(0) and null
null and null
'' and chr(0)
'' and null
1 DECLARE
2 BEGIN
3 for c1 in (select fld1, fld2, fld3 from test_null) loop
4 if c1.fld1 = c1.fld2 then
5 dbms_output.put_line(c1.fld3||' Are equal'||
6 ' Length fld1 = '||to_char(length(c1.fld1))||
7 ' Length fld2 = '||to_char(length(c1.fld2)));
8 else
9 dbms_output.put_line(c1.fld3||' Are NOT equal'||
10 ' Length fld1 = '||to_char(length(c1.fld1))||
11 ' Length fld2 = '||to_char(length(c1.fld2)));
12 end if;
13 dbms_output.put_line(' ');
14 end loop;
15* END;
SQL> /
chr(0) and null Are NOT equal Length fld1 = 1 Length fld2 =
null and null Are NOT equal Length fld1 = Length fld2 =
'' and chr(0) Are NOT equal Length fld1 = Length fld2 = 1
'' and null Are NOT equal Length fld1 = Length fld2 =
PL/SQL procedure successfully completed. -
Is empty string and Null same?
create table x
(empid number);
Table created.
insert into x values ('');
1 row created.
insert into x values (null);
1 row created.
SQL> set null <<>>
SQL> select * from x;
EMPID
<<>>
<<>>So i can safely change an Insert statement like
insert into x values ('');to
insert into x values (null);Right?michaels2 wrote:
char pads with spaces to the length of the data itemdon't think so - at least not on my 11.2.0.1.0Good. Oracle finally fixed it. Before 11.2 it was pretty much as ajallen noted:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
SET SERVEROUTPUT ON
DECLARE
flag CHAR(2);
PROCEDURE check_null (p_flag IN CHAR)
IS
BEGIN
IF p_flag = ' '
THEN
dbms_output.put_line ('flag is equal to '' ''');
ELSIF p_flag IS NULL
THEN
dbms_output.put_line ('flag is null');
ELSE
dbms_output.put_line ('other');
END IF;
END;
BEGIN
flag := '';
check_null (flag);
flag := NULL;
check_null (flag);
END;
flag is equal to ' '
flag is null
PL/SQL procedure successfully completed.
alter session set events '10932 trace name context forever, level 16384';
DECLARE
flag CHAR(2);
PROCEDURE check_null (p_flag IN CHAR)
IS
BEGIN
IF p_flag = ' '
THEN
dbms_output.put_line ('flag is equal to '' ''');
ELSIF p_flag IS NULL
THEN
dbms_output.put_line ('flag is null');
ELSE
dbms_output.put_line ('other');
END IF;
END;
BEGIN
flag := '';
check_null (flag);
flag := NULL;
check_null (flag);
END;
flag is null
flag is null
PL/SQL procedure successfully completed.
SQL>
Bug 727361: ZERO-LENGTH STRING DOES NOT RETURN NULL WHEN USED WITH CHAR DATA TYPE IN PL/SQL
SY. -
ORACLE treats empty Strings as NULL, Any workaround?
Hi,
ORACLE treats empty Strings as NULL.
I am writing, rather modifying Java code to make it work with both SQLServer and Oracle. Since our code is already working for SQLServer, now I have the problem in porting to Oracle wherever I have empty strings. I used to insert empty strings into coulumns in SQLServers, the same SQLs give errors in SQL Server.
Any workaround on the DB end or in JDBC for this?
Thanks in advance,
Suresh
[email protected]jschell wrote:
nichele wrote:
jwenting wrote:
If NULL really is different in your context from an empty string you're going to have to define some sequence of characters as indicating an empty string.yes, this is what i need to implement.Sounds like a flawed design then.
I'm wondering what's the best approach in order to avoid to change all my application isolating this behavior somewhere (wrapping the jdbc driver for instance).That doesn't make much sense to me. You should already have a database layer. You change the database layer. If you don't have a database layer then that means you have another design flaw. And in that case I would really not be the one that needs to maintain that code base.I thought a bit about the value of your answer...but i didn't find it ....sorry but i don't like who replies on forum just to say bad design/bad choice etc...if you have any kind of suggestion you are welcome, otherwise you can spend your time in doing something else instead of reply to this thread. -
Distinguish between 'Edit Page' and 'Customize'
I have a portlet/provider that needs to be able to distinguish between 'Edit Page' and 'Customize (Page)' (top level). In both cases you can add portlets, but I want to implement different logic for both instances.
Thanks,
Jan
nullOkay, so here goes!
Oracle Portal stores the way a portlet instance is shown/put on a page in the db-column 'wwpob_portlet_instance$.include'.
In the portlet 'register' call you can find out what the originating action was for this portlet to be placed on the specific page. At this stage only two possible values are interesting:
3: WWPOB_API_PAGE.PORTLET_CUSTOM; The originating action was [Customize Page - Add Portlet]
1: WWPOB_API_PAGE.PORTLET_BASE_SHOWN; The originating action was [Edit Page - Add Portlet]
For now this gives me a hook to process the two originating actions differently.
Please let me know if you know of any other (less hacked) way to do this.
Thx,
Jan. -
Distinguish between pure AS3 and Flex project
Hey,
how can I distinguish if I am compiling currently an AS3 or a Flex project (mxml vs. pure as)?
I acutally want to look something up in the "evaluate" method of a GenerativeFirstPassEvaluator before doing the processing. So I need to know it there.
Any help is much appreciated.
Best,
JoaMXML is converted to AS3 code as part of the compilation process, then the AS3 is compiled normally like the rest of the project. I don’t think that GFPE is run over anything but an AS3 tree. There
may be a way to figure out where the original source came from, e.g. .mxml or .as file, but you’d have to interactively debug and scan the data structures — I don’t know off hand.
- Jono
From: Joa Ebert <[email protected]>
Reply-To: <[email protected]>
Date: Mon, 31 Mar 2008 05:40:13 -0700
To: <[email protected]>
Subject: Distinguish between pure AS3 and Flex project
A new discussion was started by Joa Ebert in
Developers --
Distinguish between pure AS3 and Flex project
Hey,
how can I distinguish if I am compiling currently an AS3 or a Flex project (mxml vs. pure as)?
I acutally want to look something up in the "evaluate" method of a GenerativeFirstPassEvaluator before doing the processing. So I need to know it there.
Any help is much appreciated.
Best,
Joa
View/reply at Distinguish between pure AS3 and Flex project
<http://www.adobeforums.com/webx?13@@.59b4da24>
Replies by email are OK.
Use the unsubscribe
<http://www.adobeforums.com/webx?280@@.59b4da24!folder=.3c060fa3> form to cancel your email subscription. -
Distinguishing between bookmark page and ordinary jsp
If I bookmark a page in my project and close the browser , and again on restarting the browser
viewing the same bookmark page without logging in,
All the links should work.
It is working , but problem arises here
how to
distinguish between bookmark page and ordinary jsp
which is viewed with loginThe problem is not the bookmark.
Review your JSP, you may find it does not check the session id.
In this case, everyone can access the page without login. -
How can I distinguish between the first and the rest in Smartforms??
I have made an Invoice in Smartform. I have to take three copies of that. In the first copy it will be printed "ORGINAL INVOICE" and in the next copies it will print "Duplicate copy". How can I distinguish between the first and the rest in Smartforms??
Regards,
Subhasish>
Subhasish Ganguly wrote:
> I have made an Invoice in Smartform. I have to take three copies of that. In the first copy it will be printed "ORGINAL INVOICE" and in the next copies it will print "Duplicate copy". How can I distinguish between the first and the rest in Smartforms??
Hello Vamshi,
As per the OP's requirement he has to print 3 copies of the invoice. Which according to my understanding should be printed at the same time ? May be i am wrong in interpreting this.
You must be knowing you can control the print params of the SmartForms in CONTROL_PARAMETERS where you set the NO_DIALOG & in the OUTPUT_OPTIONS pass the number of copies.
I think the solution you have proposed the "Original Copy" will be printed only once. (Correct me if i am wrong)
Every time the user prints the invoice again he will be getting a "Duplicate Copy". If this is what the OP wants the logic is perfect
Cheers,
SUhas -
Error 13641 - The Subnet prefix must be between the starting and ending values
Hi All,
I can honestly say hand on heart that this is the first time I have ever asked for help in a forum in over 15 years but this is doing my head in..
I have a Sys Center 2012 R2 deployment.. VMM R2 up to RU3, Edge Cluster (2 hosts), Management Cluster (2 hosts), 2 x Production Compute Clusters (total of 20 hosts). I have a HA Network Virt Gateway deployed on the edge cluster.
All Hosts have the new DHCP install done and the RU3 SQL patch is completed as outlined in deployment manual.
Everything had been running fine for some time after RU3 update... I am experiencing an issue whereby I get the following error anytime I try and attach a NVGRE VM network to a VM, or when I try and migrate a VM with a NVGRE network attached to another
host.
Error (13641)
The specified subnet prefix must be between the starting and ending values for the range.
Starting value: 4
Ending value: 30
Recommended Action
Specify a suitable subnet prefix.
All subnets in the entire network are /24's so prefix isn't an issue.
I can successfully attach a standard vm network but get the above error when working with NVRGE networks..
Further to this, if I restart VMM the DHCP function to VM's with NVGRE networks doesn't get picked up until I trigger a change in config on the VM, then it will get IP and function as expected.
I have checked all logs, there aren't any errors that I can see.
get-netvirtualizationlookuprecord throws out VM's and PA's as expected, but again not until I manually interfere with the VM in question.
Have any of you come across this before?? I want to check before I go rebuilding the PA network entirely and having to cleanup all existing VM networks to do it..
Any help or guidance would be appreciated..
Cheers
NathanI have seen this message before, "specify a suitable subnet prefix".
In my case, the NVGRE policies were out of sync due to HW issues on several hosts.
Here's some steps in order to troubleshoot/fix:
run the following cmdlet: Get-SCVMHost | Read-SCVMhost -RunAsynchronously
Check for any errors in the job log that refers to "Network Virtualization".
If this doesn't help, a recycle of the VMM Management server should do a "hard refresh" of the NVGRE policies, and it might include a reboot of the nvgre hosts too.
This solved the case in my situation.
-kn
Kristian (Virtualization and some coffee: http://kristiannese.blogspot.com ) -
Difference between hierarchy node and single value
Hi experts,
Can anyone explain me the difference between hierarchy node and single value?
This is my problem:
I have a query that uses a characteristic (0ORGUNIT) with a hierarchy and I execute it without any problem but when I try to set a fliter on this characteristic and I try to find a single value, for example 101, it doesn't appear in the single value list, instead it appears in the hierarchy nodes list in the selection window.
I think I'm confused about both terms because I thought a hierarchy node was always the one who has one or more values as its lower levels like this:
A. 10
A1. 100
A2. 101
A3. 102
A3.1. 1021
B. 11
I this case I thought , for example, 101 was a single value but not a hierarchy node so I must find it in the single values list in the selection window, however, 102 can be both and must appear in both lists, is it true?
Thanks in advancedIn BW, hierarchy node with more information compare to the single value. for example, it always carries its father node information, which it belongs to. and some time information if it is time-dependent.
So, when you using hierarchy node, it means at least 2 information: value and "position" (who is its father node)
That's the reason why you see the hierarchy tree when choosing the node.
If you want to expand the hierarchy to the certain level, you can setting in the property. Another choice is restrict in the query designer. -
JDBC Receiver does not convert empty string to NULL
Hello experts,
I am facing a problem with an INSERT statement to ORACLE DB where some of the fields are empty, for example:
- <STATEMENT_VLP_CONT_DETAILS>
- <TABLE_VLP_CONT_DETAILS ACTION="INSERT">
<TABLE>VLP_CONT_DETAILS</TABLE>
- <ACCESS>
<VLP_HDR_ID>43</VLP_HDR_ID>
<VLP_CONT_LINE_ID>1</VLP_CONT_LINE_ID>
<QUANTITY>1</QUANTITY>
<OWNER>CBHU</OWNER>
<SERIAL_NO>3372739</SERIAL_NO>
<CONT_ISO_CODE>2300</CONT_ISO_CODE>
<WEIGHT>6.44</WEIGHT>
<POL>ILASH</POL>
<POD>FRFOS</POD>
<FD>FRFOS</FD>
<OPER_CODE>COS</OPER_CODE>
<CUR_STOW_LOC>150102</CUR_STOW_LOC>
<PRV_STOW_LOC />
<HAZARDOUS>N</HAZARDOUS>
In the JDBC Receiver comm channel I selected: Interpretation of Empty String Values = NULL Value.
It seems the empty strings are not converted to NULL values as can be seen in the reflected SQL statement in RWB:
INSERT INTO VLP_CONT_DETAILS (VLP_HDR_ID, VLP_CONT_LINE_ID, QUANTITY, OWNER, SERIAL_NO, CONT_ISO_CODE, WEIGHT, POL, POD, FD, OPER_CODE, CUR_STOW_LOC, PRV_STOW_LOC, HAZARDOUS, EMPTY, REFER, OOG, HAZARD_IMDG, TEMP_SET, TEMP_MIN, TEMP_MAX, FRONT_OVL, REAR_OVL, RIGHT_OVW, LEFT_OVW, OVERHEIGHT, COMMODITY, BOOKING_REF, ALLOTMENT, YARD_LOC, LD_SEQ_CRANEID, LD_SEQ_NUMBER, LD_STATUS, STACKABLE, OPT_PORT_CODE1, OPT_PORT_CODE2, OPT_PORT_CODE3) VALUES (44, 1, 1, CBHU, 3372739 , 2300, 6.44, ILASH, FRFOS, FRFOS, COS, 150102, , N, N, N, N, , , , , , , , , , , , , , , 0, 64, N, , , )
So, I am getting the following error:
Could not execute statement for table/stored proc. "VLP_CONT_DETAILS" (structure "STATEMENT_VLP_CONT_DETAILS") due to java.sql.SQLException: ORA-00936: missing expression
Help would be appreciated.Hi Effi,
There is a mismatch in the field and thier value.
Here field id 37
VLP_HDR_ID, VLP_CONT_LINE_ID, QUANTITY, OWNER, SERIAL_NO, CONT_ISO_CODE, WEIGHT, POL, POD, FD, OPER_CODE, CUR_STOW_LOC, PRV_STOW_LOC, HAZARDOUS, EMPTY, REFER, OOG, HAZARD_IMDG, TEMP_SET, TEMP_MIN, TEMP_MAX, FRONT_OVL, REAR_OVL, RIGHT_OVW, LEFT_OVW, OVERHEIGHT, COMMODITY, BOOKING_REF, ALLOTMENT, YARD_LOC, LD_SEQ_CRANEID, LD_SEQ_NUMBER, LD_STATUS, STACKABLE, OPT_PORT_CODE1, OPT_PORT_CODE2, OPT_PORT_CODE3
And value is 35
44, 1, 1, CBHU, 3372739 , 2300, 6.44, ILASH, FRFOS, FRFOS, COS, 150102, , N, N, N, N, , , , , , , , , , , , , , , 0, 64, N, , ,
Give empty values for nuil fields so that they can be made NULL by jdbc adapter
Regards
Suraj -
About xml and null values in 10g
Hi, I have an UCM GetFile webservice component wich receives 4 arguments, two of them are null values (rendition and extraPops), and the xml request generated by obpm is:
<GetFileByName xmlns="http://www.stellent.com/GetFile/">
<dDocName>V_123410</dDocName>
<revisionSelectionMethod>latestReleased</revisionSelectionMethod>
<rendition/>
<extraProps/>
</GetFileByName>The problem is: On UCM web service, an empty tag like <rendition/> is treated like a "empty string" value, instead of a null value, and then the response i get isn't the expected.
What I want do to is change this behavior, and when I put null values in requests, the obpm should not write those tags. Is that possible?
Should be like that:
<GetFileByName xmlns="http://www.stellent.com/GetFile/">
<dDocName>V_123410</dDocName>
<revisionSelectionMethod>latestReleased</revisionSelectionMethod>
</GetFileByName>Thanks!Hi,
I have question regarding aggregates. It's possible to read data from BW aggregates? We have webi reports on a SAP BW multi cube and we would like to optimize retriving query.
>> Because you are using the BW Query as the source all the items that you have done so far in terms of aggregation, indexing, ... is all valid and there are no specific steps required to leverage it with Web Intelligence. Make sure the aggregates are "correct" meansing that they do reflect what you are asking for in the Web Intelligence query panel
How can we filter in webi query null (#) values. If we create condition that some variabe is diffrent from # we still get null (#) values in report.
>> You should be able to create a variable. in case you tried that already could you be more specific ?
thanks
Ingo
Maybe you are looking for
-
Is there a cure for persistent file corruptions across the suite?
i am having terrible and consistent problems with file corruptions across the suite. for example- 1: i collected for output (indesign) – corrupted over 100 small images that were linked. 2: opened an indesign job and all linked files failed to update
-
How do you pass vi references from one event to another
I have a vi which gets vi references (thereby loading the vi's into memory) for all the vi's in a given directory when a user clicks a button on the front panel. To do this I use an event structure. My question is whether it is possible to have anoth
-
How to Verify Junk Filter Learning?
Hi, With some helpful posts on this board, I setup Junk Mail filtering in 10.4 a few months ago. While it appears that everything is running fine, the system doesn't seem to learn much about what it should or shouldn't tag as spam. I'm using Spamtrai
-
I have a verizon 8330 curve and my verison is 4.5.0.175. I'm having an issue with https://sports.bodog.com/. I can log in and get all the way to where I click on "Review My Bet." I click the button and it goes nowhere. It acts like I haven't clicked
-
Hi anyone out there that knows Adobe Photoshop Elements (?
Is anyone available to answer a question for Adobe Photoshop Elements 9?