Handling null value in where condition
CREATE OR REPLACE package body GetRefCursors is
function sfGetAccountInterval
( pFirstAccount in ACCOUNTS.ACCOUNT_NO%type
,pLastAccount in ACCOUNTS.ACCOUNT_NO%type)
return csGetResultSet is
csGetAccounts csGetResultSet;
begin
open csGetAccounts for
SELECT accounts.account_no,accounts.name
FROM accounts
WHERE accounts.account_no BETWEEN pFirstAccount AND pLastAccount
ORDER BY accounts.account_no;
return csGetAccounts;
end sfGetAccountInterval;
end GetRefCursors;
how can i handle the condition if pFirstAccount parameter having null value?
do i need to use Dynamic SQL here?
no need for dynamic stuff.
You could use the NVL function, but it depends what you want... If you want NULL to be considered the lowest possible account number, then you could do something like
nvl (pFirstAccount, 0)where the zero is the lowest possible number.
Similar Messages
-
Concatenation error - when i use text column value in where condition.
Hi,
i am creating Materialized view using few columns from two tables and as per requirement i need to prepare select statement with where condition in another column.(new column)
i tried like below....
create materialized view MAIN
refresh force on demand
as
select
a.table_name,
a.column_name,
b.trial_name,
'select * from '||a.table_name||' where '||a.column_name|| ' = '|| b.trial_name||';' "QUERY"
from
exp_csv_tB a,
exp_csv_tr b;
a.table name value is : monitoring_table
a.column_name value is : study
b.trial_name = fty777
Materialized view created with extra column but it is not added '' (codes) to text value in where condition.
output which i got is :
select * from monitoring_table where study = fty777;
but
i need output like
select * from monitoring_table where study = 'fty777';
fty777 value should be in codes like 'fty777'. i read some articles but didnt get this example.
please help.Try this:
CREATE MATERIALIZED VIEW main
REFRESH FORCE ON DEMAND
AS
SELECT
a.table_name,
a.column_name,
b.trial_name,
'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||'';'' "QUERY"
FROM
exp_csv_tb a,
exp_csv_tr b;
You have to give double single codes for semi-colons ..
Regards.. -
Hi frzz,
Can any one explain me how exactly HANA handles NULL values??
Best Regards,
Krishna.Hi Krishna,
You can use IFNULL for the SQL queries/script instead of ISNULL . Since ISNULL is binary function and will be mostly used for the CE Functions based Calc views.
Try using the same queries with IFNULL instead of ISNULL, it should work
Best Regards
Rahul Jha -
Num and Value in Where condition
Hi all,
I have table:
create table T1
f1 fixed (1),
f2 boolean
then:
insert into T1 values (1,null)
and query:
select f2,Num(Value(f2,False)),Num(Value(null,False)) from
(select max(f1) x from t1)
left join t1 on x=f1
where 22 =Num(Value(f2,False))
Statement 'select f2 from (select max(f1) x from t1) left join t1 on x=f1 where 22 ...' successfully executed in 0 ms.
Result: ?;0;0
This is a bug? Known bug?
KR Lukasz.Hi Holger,
sorry it does nothing. Query still returns rows.
Thank you for help and explanation very much. I'm waiting to next MAXDB relase(s).
BTW
I have fixed this problem in that way:
select f2,Num(Value(f2,False)),Num(Value(null,False)) from
(select max(f1) x, 22 k from t1)
left join t1 on x=f1
where Num(Value(f2,False))=k
query does not return rows but... execution plan contains 䕘偒䕓卉低⁗䥔䠠.
Simple correction in where condition:
select f2,Num(Value(f2,False)),Num(Value(null,False)) from
(select max(f1) x, 22 k from t1)
left join t1 on x=f1
where Num(Value(f2,False))-k=0
And execution plan is proper too.
KR Lukasz. -
Using Convert to handle NULL values for empty Strings ""
After having had the problem with null values not being returned as nulls and reading some suggestion solution I added a converter to my application.
<converter>
<converter-id>NullStringConverter</converter-id>
<converter-for-class>java.lang.String</converter-for-class>
<converter-class>com.j2anywhere.addressbookserver.web.NullStringConverter</converter-class>
</converter>
...I then implemented it as follows:
public String getAsString(FacesContext context, UIComponent component, Object object)
System.out.println("Converting to String : "+object);
if (object == null)
System.out.println("READING null");
return "NULL";
else
if (((String)object).equals(""))
System.out.println("READING null (Second Check)");
return null;
else
return object.toString();
public Object getAsObject(FacesContext context, UIComponent component, String value)
System.out.println("Converting to Object: "+value+"-"+value.trim().length());
if (value.trim().length()==0 || value.equals("NULL"))
System.out.println("WRITING null");
return null;
else
return value.toUpperCase();
...I can see that it is converting my values, however the object to which the inputText fields are bound are still set to empty strings ""
<h:inputText size="50" value="#{addressBookController.contactDetails.information}" converter="NullStringConverter"/>Also when reading the object values any nulls are already converted to empty strings before ariving at the converter. It seems that there is a default converter handling string values.
How can I resolve this problem as set nulls when the input value is an empty string other then checking every string in my class individually. I would really hate to pollute my object model with empty string tests.
Thanks in advance
Edited by: j2anywhere.com on Oct 19, 2008 9:06 AMI changed my converter as suggested :
public Object getAsObject(FacesContext context, UIComponent component, String value)
if (value == null || value.trim().length() == 0)
if (component instanceof EditableValueHolder)
System.out.println("SUBMITTED VALUE SET TO NULL");
((EditableValueHolder) component).setSubmittedValue(null);
else
System.out.println("COMPONENT :"+component.getClass().getName());
System.out.println("Converting to Object: " + value + "< to " + null);
return null;
System.out.println("Converting to Object: " + value + "< to " + value);
return value;
}which produces the following output :
SUBMITTED VALUE SET TO NULL
Converting to Object: < to null
Info : The INFO line however comes from my controller object where I print out the set value :
package com.simple;
import java.util.ArrayList;
import java.util.List;
public class Controller
private String information;
/** Creates a new instance of Controller */
public Controller()
System.out.println("Createing Controller");
information = "Constructed";
public String process()
System.out.println("Info : "+getInformation());
return "processed";
public String reset()
setInformation("Re-Constructed");
System.out.println("Info : "+getInformation());
return "processed";
public String setNull()
setInformation(null);
System.out.println("Info : "+getInformation());
return "processed";
public String getInformation()
return information;
public void setInformation(String information)
this.information = information;
}I also changes my JSP / JSF page a little. Here is the updated version
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%--
This file is an entry point for JavaServer Faces application.
--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<f:view>
<h:form>
<h:inputText id="value" value="#{Controller.information}"/>
<hr/>
<h:commandLink action="#{Controller.process}">
<h:outputText id="clicker" value="Process"/>
</h:commandLink>
<hr/>
<h:commandLink action="#{Controller.reset}">
<h:outputText id="reset" value="Reset"/>
</h:commandLink>
<hr/>
<h:commandLink action="#{Controller.setNull}">
<h:outputText id="setNull" value="Set Null"/>
</h:commandLink>
</h:form>
</f:view>
</body>
</html>The converter is declared for the String class in the faces configuration file. From the log message is appears to be invoked, however the object is not set to null.
I tested this with JSF 1.2_04-b20-p03 as well as 1.2_09-b02-FCS.
any other suggestions what could be causing this. -
How to handle Null value in Database Adapter
I configured the DA Adapter, with operation type as "Perform an Operation on a Table - Select" and added few where clause parameters (StreetNo, StreetName city, country, state, zipcode)too.
If we won't enter any value for any of the column in the table (S_ADDR_PER) is taking as NULL, so what happening is, if i give "%" or if i leave as "blank" to those columns(input for where clause parameter). The DB adapter not fetching any records. Any help to handle this situation.
I need query like this...
select * from S_ADDR_PER where city like '%' AND state is NULL AND addr_line_2 like '%';
seems.... I can't use the pure SQL option since i don't know which column will be null. Some case the addr_line_2 column will be NULL in table, in some other case the state or city column will be null.Hi,
you can handle null with date like this , If it doesn't wortk for you then please explain your problem.
select NVL(to_char(sysdate,'DD-MON-YY'),'Not Recorded')
from dual
NVL(TO_CHAR(
08-NOV-05
select NVL(to_char(NULL,'DD-MON-YY'),'Not Recorded')
from dual
SQL> /
NVL(TO_CHAR(
Not Recorded
Regards -
Checkbox Value in where condition of query
Hi,
I have a check box which shows values based on the LOV's . If i check on the checkbox the values that are selected on the check box must be used in the where condition to update the table.
Please suggest me how to take the check box values.
Am using the below methos to update but its not happening
Declare
old_cohort_name varchar2(500);
new_cohort_name varchar2(500);
l_cohort_id apex_application_global.vc_arr2;
begin
l_cohort_id := apex_util.string_to_table(:P64_CASCADE_COHORT_NAMES);
select cohort_name into old_cohort_name from study_cohort
where cohort_id = :p64_cohort_id;
select :P64_COHORT_NAME into new_cohort_name from dual;
if old_cohort_name <> new_cohort_name then
update study_cohort
set
cohort_name = new_cohort_name
where cohort_id = :p64_cohort_id and
cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked
End if;
End;
Please suggest me how to modify the code
Tx
SudhriHi Sudhri,
where cohort_id = :p64_cohort_id and
cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked If this is the code you are actually using, then the condition would only be met if l_cohort_id = :p64_cohort_id because you are using an AND condition over the same column in the where clause, so it will only return rows when both values are the same. Then, I think that it seems not to be working for you because :p64_cohort_id and l_cohort_id have different values, and no row is getting updated then. If the values you are selecting in your checkboxes are several ids of rows to update, besides the one with id :p64_cohort_id, then maybe the condition you need is something like this:
WHERE cohort_id = :p64_cohort_id OR instr(l_cohort_id, cohort_id) != 0;Hope that helps.
Regards,
Sergio -
Handle NULL Values from Teradata Database in OBIEE
Hi All,
I have records in a Teradata that are marked with 'A' for Available and sometimes blanks. Even though in OBIEE I have put a filter that says display all records with NULL values or 'A' I am only getting values with 'A'. How can I pick up the records with blanks in that field.Looks like the column value is not NULL. I would suggest to know the exact value of the column
you may go for expression like length(col) where col!='A'
or
case when col is null then '1null'
when col='' then '2'
etc..
once you know the value then replace with 'Unspecified' or any text. -
ODI - Issue with handling null value
Hi,
I have a flat file as below. When i am trying to load the data file into Essbase through ODI, i am not able to load. If i given the Null value as 0, i'm able to load the file into Essbase. If we pass 0 in place of null value, blocks will be created in Essbase and it might cause the performance issue.
Account,Product,Customer,Version,Year,BU,Data
A1,P1,C1,V1,2010,BU1,7677
A2,P2,C2,V2,2010,BU2,0908
A3,P3,C3,V1,2010,BU3,
Can any one help if there is any way to handle the null values to load the data into Essbase?
Your help is more important to us as it is one of the critical one we are facing.
Thanks
V D ReddyHi
I am not using any query.
Data column is empty (no data) for few records in my flat file. After the data load is done to Hyperion Essbase, in the excel retrieve should show me as #Missing. But ODI is defaultly loading it as 0 into Essbase.
Is there any way to load it as #Missing?
Thanks
V D Reddy -
Oracle Discoverer: How to handle null value
In Oracle Discoverer, I pull data from a folder. When I hit Null value for a column, I want to replace it with data from another folders column. Something like the functionality of "nvl" of a SQL statement. How can I do the following query in Discoveror :
example: select nvl(table1.column1,table2.column2) from table1, table2
where table1.column7 = table2.column7.Hi,
You first need to include any column from folder table2 into your report so that Discoverer will do the join. (This assumes the join between table1 and table2 is set up in your EUL). Then you can create a calculation containing nvl(table1.column1,table2.column2) . You can then remove the column from folder table2 and the join will stay in your workbook.
Hope that helps,
Rod West -
Oracle Discoveror: How to handle null value
In Oracle Discoveror, I pull data from a folder. When I hit Null value for a column, I want to replace it with data from another folders column. Something like the functionality of "nvl" of a SQL statement. How can I do the following query in Discoveror :
example: select nvl(table1.column1,table2.column2) from table1, table2
where table1.column7 = table2.column7.Hi,
You first need to include any column from folder table2 into your report so that Discoverer will do the join. (This assumes the join between table1 and table2 is set up in your EUL). Then you can create a calculation containing nvl(table1.column1,table2.column2) . You can then remove the column from folder table2 and the join will stay in your workbook.
Hope that helps,
Rod West -
Handle null value in char infoobject -data type DATE(ora-01722 invalid num)
Hi,
We have a DSO with a info object in the Data fields. The char info object has the data type DATE and most often it has the null value. but some times it has data in it.
When ever we were trying to run a report on the DSO it throws a error as ORA- 01722 INVALID NUMBER.
we tried editing PSA data and placing 00000000 for null values - and had a message invalid date.
suggestions pls
Regards.Hello,
Please check the note given below
https://service.sap.com/sap/support/notes/1327167.
If null value is the problem, change the query setting for not to show the null values. Just add a filter in ZDAT to exclude "NULL"
Thanks
Nidhi -
Join is not working for NULL values on join condition
HI ,
I have the following problem .
SQL> select *from a;
X Y
1
2
3
4
SQL> select *from b;
B Y
1
2
SQL> select f.x,f.y,s.b from a f,b s
2 where f.x=s.b(+);
X Y B
1 1
2 2
4
3
SQL> select f.x,f.y,s.b from a f,b s
2 where f.x=s.b(+)
3 and f.y=s.y;
no rows selected
So now if i include one more join condition where in null = null situation arises , it is now working.
Simply saying its not treating ( 1 and null ) and ( 1 and null ) are same.
What is the solution.Is this a expected behaviour.
Thanks
Pramod GarreHI
I want something like this
SQL> select f.x,f.y,s.b from a f,b s
2 where f.x=s.b(+);
X Y B
1 1
2 2
4
3
SQL> select f.x,f.y,s.b from a f,b s
2 where f.x=s.b(+)
3 and f.y=s.y;
Instead of "now Rows " i have to get
X Y B
1 1
2 2
4
3
Is there is any way to do this.
Thanks
Pramod -
How to handle null values in RTF templates
Hi - I have two groups in a report for different SQL and two formulas for each group, CF_ELE_CNT and CF_ELE_CNT1. In the template I use the below code to print or not print a section.
<?if:number(CF_ELE_CNT +CF_ELE_CNT1) >0?>
The problem is when there is no data in the second group its not creating the XML tag for CF_ELE_CNT1, though CF_ELE_CNT has 13, it still does not print that partucular section. If I remove CF_ELE_CNT1 from the condition it works fine. I was wondering how to handle this.
Any help would be appreciated!!
Thanks,
RavHey Rav,
You can add a check to identify it the element/tag is present or not
<?if:(CF_ELE_CNT1)?> will give true, if the element is present otherwise falsesince you are adding the two elements, you have to add a or condition.
<?if:(CF_ELE_CNT and number(CF_ELE_CNT) >0 ) or ( CF_ELE_CNT1 and CF_ELE_CNT1 >0)?> -
I can't find any samples that show how to handle null values returned in a JDBC Select statement. My code bombs out on setLong etc if the column is null.
Any suggestions much appreciated.wasNull()
Maybe you are looking for
-
Alert while goods issue about old inventory
Hi, We have a requirement where in our client wants an alert message about old inventory aged more than 120 days at the time of issuing the same item from WBSE of lesser aging within same plant. can anybody give some idea on this? Any help on this is
-
Hello, I´m trying to use an USB OMNIKEY Smartcard 3121 on my MacPro for email encryption in a Citrix Session. If a put the smartcard into the reader, the red light is flashing 1 sec only. The content from the smart card is not delivered into the Citr
-
Dual screen issues!!
Hi, I just bought a new display, Acer x193w 19inch. I set it as my primary display, having my macbook as secondary display. my menubar and dock appear fine on my external display, but the icons are hidden by an overlay (my desktop picture), which onl
-
Got Officejet 6600 from third party vendor, had no setup cartridges​.
My company bought an HP 6600 to use as a standalone copier. It's not hooked up to any computer. Our printer did not come with setup cartridges (All original packing intact, but company removed the setup cartridges for their own use.). This was commun
-
What issues will I have if I take sql 2005 on 32bitOS TO sql 2005 on 64bit?
Last Year our SolMan was installed on 32bit OS, with SQL 2005 on Windows Ent. Edition (UNICODE). I am preparing to migrate it to 64bit OS, and want to get there as quickly as possible without jepordizing the data integrity. I was thinking that rather