Fetching Null Value from table
I have a table where I am want to findout the total number of product (count of product) based on the ProdName.
I have the following table with two columns:
create table newproduct (prodid integer, prodname varchar(30));
Insert into newproduct values (100, 'TowerA')
Insert into newproduct values (160, 'TowerA')
Insert into newproduct values (170, 'TowerB')
Insert into newproduct values (120, 'TowerB')
Insert into newproduct values (140, 'TowerC')
Insert into newproduct values (180, '')
So here the query that I trying to use:
Select Distinct prodname from newproduct;
Select prodid from newproduct where prodname is null; /* Correct way */
Select prodid from newproduct where prodname in (''); /* I want result (180) by using this query */
How can I do it?
I'm not sure why you're trying to accomplish it that way, but you could try to use NVL to do that.
You just need to make sure whatever value you input in the NVL is something you won't ever obtain as a real column value.
Select prodid from newproduct where nvl(prodname, 'NULL VALUE HERE!') in ('NULL VALUE HERE!');Also, for performance reasons, since you're applying a function to the column, it won't be looking up indexes for matches, unless you create a function-based index.
Nulls are not indexed anyway, but I'm not sure what you're trying to do with this query.
Similar Messages
-
Hi,
I have created a table with 2 LOV's , LOV2 is dependent on LOV2.
Here I can not use the general Dependent LOV concept, as these values are coming from 2 different LookUps.
I am not able to fetch the user input for LOV1 (from page) .that is why not able to set the where cluse fro 2nd LOVVO.
I have used this code:
if ("ViolationCat".equals(lovInputSourceId)) {
OAMessageLovInputBean msglov =
(OAMessageLovInputBean)webBean.findChildRecursive("ViolationCat");
// String p_violation_category = "'"+(String)msglov.getValue(pageContext)+"'";
String p_violation_category =
(String)msglov.getValue(pageContext);
// System.out.println(" p_violation_category =" +
// p_violation_category);
String v_violation_category = "";
//System.out.println("vcat=" + vCat);
OAViewObject violationVO =
(OAViewObject)am.findViewObject("SNI_Violation_DtlsVO2");
Number vcatViolationIdnum =
(Number)violationVO.getCurrentRow().getAttribute("ViolationId");
String vcatViolationId = "" + vcatViolationIdnum;
pageContext.putTransactionValue("vcatViolationId",
vcatViolationId);
pageContext.putTransactionValue("p_violation_category",
p_violation_category);
String query =
" SELECT LOOKUP_CODE, \n" + " MEANING, \n" +
" LOOKUP_TYPE \n" +
" FROM apps.fnd_lookup_values \n" +
" WHERE LOOKUP_TYPE ='SNI_VIOLATION_CATEGORY' AND MEANING=?";
PreparedStatement ps = txn.createPreparedStatement(query, 1);
try {
ps.setString(1, p_violation_category);
ResultSet rs = ps.executeQuery();
//System.out.println("before while,");
// rs.next();
// v_violation_category = rs.getString("LOOKUP_CODE");
// System.out.println("v_violation_category="+v_violation_category);
while (rs.next()) {
//System.out.println("inside while");
v_violation_category = rs.getString("LOOKUP_CODE");
// System.out.println("v_violation_category=" +
// v_violation_category);
ps.close();
} //try ends
catch (Exception e) {
e.getMessage();
//System.out.println("in catch.." + e.getMessage());
OAViewObject subCatVO =
(OAViewObject)am.findViewObject("SNI_ViolationSubCategoryVO1");
//System.out.println("get VO before where clause: subCatVO::"+subCatVO.getQuery());
subCatVO.setWhereClause("LOOKUP_TYPE like '%SNI_VIOL_SUB_CAT_" +
v_violation_category + "'");
System.out.println("after set where clause VO: subCat VO::" +
subCatVO.getQuery());
subCatVO.executeQuery();
// System.out.println("query of subCat VO::" +
// subCatVO.getQuery());
//End of sub category Validation
It is working fine only for the 1st row of teh table.
I have tried to fetch the value using :
String violationCategory = (String)violationVO.getCurrentRow().getAttribute("ViolationCategory");
String violationSubcategory = (String)violationVO.getCurrentRow().getAttribute("ViolationSubcategory");
But it is fetching null value.
Please tell me how can I able to fetch the values.Hi
in your scenarion,first u have to identify the particular row of table where the changes is being made ,u have to use this code .when u select the lov ,first it will give the row refernce and then u have to catch the lov event
OAApplicationModule am =
(OAApplicationModule)pageContext.getApplicationModule(webBean);
String event = pageContext.getParameter("event");
if ("<ItemPPREventName>").equals(event))
// Get the identifier of the PPR event source row
String rowReference =
262
pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
Serializable[] parameters = { rowReference };
// Pass the rowReference to a "handler" method in the application module.
am.invokeMethod("<handleSomeEvent>", parameters);
In your application module's "handler" method, add the following code to access the source row:
OARow row = (OARow)findRowByRef(rowReference);
if (row != null)
thanx
Pratap -
How to fetch null values from a table
Hi,
This is a Attendance report
Table Name : Attn_details ( Only 3 records stored in this table )
EDate Etype
04/03/2010 A
05/03/2010 C
06/03/2010 X
user Enter From date : 01/03/2010
To date : 10/03/2010
I need the output 01/03/2010 to 10/03/2010
01/03/2010 Null
02/03/2010 Null
03/03/2010 Null
07/03/2010 Null
08/03/2010 Null
09/03/2010 Null
10/03/2010 Null
How to write a sql query, this is Urgent requirement, Help Me.EDate Etype Empcode
01/03/2010 A 001
02/03/2010 C 001
04/03/2010 X 001
02/03/2010 A 002
01/03/2010 P 003
5 records Like this stored in that table.
user Enter From date : 01/03/2010
To date : 04/03/2010
for that employee code attendance date not marking that date only should come into the report.
ECode 002 attendance not marked in the date of 01/03/2010 , 03/03/2010,04/03/2010
003 attendance not marked in the date of 02/03/2010 , 03/03/2010,04/03/2010
I need the output 01/03/2010 to 04/03/2010
03/03/2010 Null 001
01/03/2010 Null 002
03/03/2010 Null 002
04/03/2010 Null 002
02/03/2010 Null 003
03/03/2010 Null 003
04/03/2010 Null 003
i think now u clear the my requirement. how can i write the query. -
How to fetch null values from DB
I need to fetch records where a field value is Null or nothing or space.
I tried :
where <field > eq space.
But this did not fetch any records though there are records in DB.
Is there any other way?
Thanks
KiranHi kiran,
As you say, WHERE<field > EQ space should be works, try using WHERE <field > IS NULL..
Regards,
Alejandro López -
Dynamic selection screen fetching the value from table fields
hi gurus,
i have one table say ztable...and i should create a dynamic selection screen which should populate the selection screen by the table field names.
example..if i have 3 fields im my table..my selection screen should have three selection option fields..and in future if i add one more field in my table it should automatically create another slection-option in selection screen..
thanks
SudheerDo you mean like SE16 works. If so, you should notice that if you amend the selection fields, the screen program is actually re-generated.
That is what is happening. A program is being created and re-generated.
To create a dynamic selection screen in a single program is not possible ( I may be wrong ). If it is possible, then you would have problems in defining selection screen field names and using them. -
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
How to replace NULL values from main table
Dear all,
I like to remove the NULL values from a main table field. Or the question is how to replace any part of the string field in MDM repository main table field.
e.g. I have a middle name field partly the value is NULL in some hundreds of records, I like to replace NULL values with Space
any recommendation.
Regards,
NaeemHi Naeem,
You can try using Workflows for automatically replacing NULLs with any specific value.
What you can do is: Create a workflow and set trigger action as Record Import, Record Create and Record Update. So, that whenever any change will occur in the repository; that workflow will trigger.
Now create an assignment expression for replacing NULLs with any specific value and use that assignment expression in your workflow by using Assign Step in workflow.
For exiting records, you will have to replace NULLs manually using the process given by Preethi else you can export those records in an Excel spreadsheet which have NULLs and then replace all NULLs with any string value and then reimport those records in your MDM repository.
Hope this will solve your problem.
Regards,
Varun
Edited by: Varun Agarwal on Dec 2, 2008 3:12 PM -
Fetch value from Table with respect to APP_USER.
Hi,
i want to fetch value from Table with respect to APP_USER.
i am using
SELECT ID,NAME,FILE_OBJ_ID,MIME_TYPE,DOC_SIZE,BLOB_CONTENT,DESCRIPTION,UPLOAD_DATE,'Download' FROM DUMY_FILE where CREATED_BY =:APP_USER;
Show me error
failed to parse SQL query:
ORA-00911: invalid characterThanks
Edited by: 805629 on Jan 13, 2011 2:09 AMHello,
I too have the same problem.
I am using this query:
select manager from leave_mgmt where support_engg=:APP_USER
and source type is SQL Query(return single value)
but nothing is coming up in the text field. Its empty.
Please advice. Thanks in advance. -
Inserting NULL values from getParameterValues("name");
I want to get values from collection of checkboxes in JSP into servlet through getParameterValues("name");
But the problem is if the user does not tick a particular checkbox I want null to come in the array where getParameterValues("name") is storing values.
How to acheive that.I don't think that is possible, checkboxes which are not checked are simply not submitted at all.
What you can do is take the array and turn it into a Map, put the checkbox form element names as your keys. Then you can fetch the values from the Map, and the keys (form element names) that don't exist will turn up as null. -
Prevent null values from displaying in answers OBIEE 11g
Is there any possibilities in OBIEE to Prevent null values from displaying in answers
For example, If i have two records in table
TV cost=NULL(having agg rule sum in BMM layer)
RADIO cost=10(having agg rule sum in BMM layer)
in answers i get two records
TV NULL
RADIO 10
but i want to get one, only with not null costJust want to clarify your question,You want to eliminate the NULL values from the report am i right? If that is the case then put the filter COST <> NULL.
Do let me know the updates?
Thanks, -
How to find out the null values in table
hi experts,
my version is oracledb10g:
i h'd simple doubts.
for eg:
create table ex1( e varchar2(20));
insert into ex1 (null).
insert into ex1(e)
count will be: 2
i can easily found out the value 'e'.
so my question is:
how can i found out the null values in the table and i want to delete the null values from the table.ADF 7 wrote:
hi experts,
my version is oracledb10g:
i h'd simple doubts.
for eg:
create table ex1( e varchar2(20));
insert into ex1 (null).
insert into ex1(e)
count will be: 2That depends what you count. If you issue count(*) you are asking Oracle "how many rows are there". If you issue a count(<column_name>) you are asking Oracle "how many not null values of <column_name> are there".
ADF 7 wrote:
i can easily found out the value 'e'.
so my question is:
how can i found out the null values in the table and i want to delete the null values from the table.
delete from <table_name>
where <column_name> is null;Ideally you'd just place a NOT NULL constraint on the column in question, thereby prohibiting NULL values from entering into the system (assuming your business requirement is that the column MUST always have a value). -
I have to populate Description field by default in AGIS page (Advanced Global Intercompany System).
Field Description:
messageTextInput: Description
VO: FunTrxHeaderVO
VO Attribute: Description
VO is entity based.
Now if the field is null then I have to populate this value by some value from table for selected batch_id.
Example:
(SELECT DESCRIPTION FROM fun_trx_batches WHERE batch_id =
211061)
Also, this value is being populated in the Batch Information region in the same page. So the problem is also be treated as to copy a value from one messageStyledText to messageTextInput in a same page.
Can this be done through personalization, w/o coding?
Please suggest if you any idea how to resolve..
Regards,
PahariNot sure why it is not displying in the front page list??
I have to search it.
Admin team, please help.
Regards,
Pahari -
OGG-01038 Cannot fetch required data from table
hello i have the following error
OGG-01038 Cannot fetch required data from table SIEBEL.S_EVT_MAIL due to missing key columns.
here is my extract policy
EXTRACT ext3
setenv NLS_LANG=AMERICAN_AMERICA.AL32UTF8
USERID ggs_owner, PASSWORD *******
TRANLOGOPTIONS ALTARCHIVELOGDEST primary instance SBPRD1 /oraarch1/SBPRD, ALTARCHIVELOGDEST primary instance SBPRD2 /oraarch2/SBPRD
FETCHOPTIONS FETCHPKUPDATECOLS
DBOPTIONS ALLOWUNUSEDCOLUMN
RMTHOST i**********, MGRPORT 7809
RMTTRAIL /home/oracle/MIGRATE_SBPRD_ACFS/ggs/dirdat/ss
DISCARDFILE discard.txt, APPEND
DDL INCLUDE ALL
TABLE IT.*;
TABLE SIEBEL.S_EVT_MAIL,KEYCOLS(ROW_ID);
TABLE SIEBEL.*;
TABLE APDBA.*;
TABLE EXECUTOR.*;
TABLE FORTHNOVA.*;
TABLE MIGRATOR.*;
TABLE REPORTER.*;
thanks a lot
Edited by: user1165357 on Nov 24, 2011 1:06 PM
Edited by: user1165357 on Nov 24, 2011 1:07 PMno pk or unique key
SQL> desc SIEBEL.S_EVT_MAIL
Name Null? Type
ROW_ID NOT NULL VARCHAR2(15 CHAR)
CREATED NOT NULL DATE
CREATED_BY NOT NULL VARCHAR2(15 CHAR)
LAST_UPD NOT NULL DATE
LAST_UPD_BY NOT NULL VARCHAR2(15 CHAR)
MODIFICATION_NUM NOT NULL NUMBER(10)
CONFLICT_ID NOT NULL VARCHAR2(15 CHAR)
PAR_ROW_ID NOT NULL VARCHAR2(15 CHAR)
EMAIL_ATT_FLG NOT NULL CHAR(1 CHAR)
EMAIL_FORWARD_FLG NOT NULL CHAR(1 CHAR)
MSG_MANL_EDTD_FLG NOT NULL CHAR(1 CHAR)
BODY_LANG_ID VARCHAR2(5 CHAR)
CNTNT_CTG_DB_ID VARCHAR2(15 CHAR)
EMAIL_BCC_LINE VARCHAR2(2000 CHAR)
EMAIL_CC_LINE VARCHAR2(2000 CHAR)
EMAIL_RECIP_ADDR VARCHAR2(250 CHAR)
EMAIL_RECIP_NAME VARCHAR2(100 CHAR)
EMAIL_SNDR_ADDR VARCHAR2(250 CHAR)
EMAIL_SNDR_NAME VARCHAR2(250 CHAR)
EMAIL_TO_LINE VARCHAR2(2000 CHAR)
FORMAT_TYPE_CD VARCHAR2(30 CHAR)
MIME_CHAR_SET VARCHAR2(50 CHAR)
MSG_NUM VARCHAR2(200 CHAR)
EMAIL_BODY LONG -
Fetching multiple values from XML node
Hi,
I have the below XML string / Data stored in one of a table column. I am trying to extract the values of ITEM_NAME node. using the query :
select extractvalue(xml_data, '/BILL/BILL_DTL/RECORD/ITEM_NAME') from XMLTable;
If i use this query i am getting the error as : ORA-19025 EXTRACTVALUE returns value of only one node
XML String / XML data
<BILL>
.....<BILL_NO>1000</BILL_NO>
.....<SRNO>3456</SRNO>
.....<BILL_DTL>
........<RECORD>
...........<LINE_NO>1</LINE_NO>
...........<ITEM_NAME>TOYOTA COROLLA</ITEM_NAME>
........</RECORD>
........<RECORD>
..........<LINE_NO>2</LINE_NO>
..........<ITEM_NAME>NISSAN CEDRIC</ITEM_NAME>
.......</RECORD>
.....</BILL_DTL>
</BILL>
The structure of the table is given below.
SQL> DESC XMLTABLE;
Column_Name ---------------Type
DOC_ID -------------------------NUMBER
XML_DATA --------------------XMLTYPE
What will be the query to fetch the values from the ITEM_NAME node.
Thanks & RegardsA late answer but just to show that it can be done with XMLTable (the built-in Oracle function) when you expect to return multiple rows from one input.
WITH XMLTable AS
(SELECT XMLTYPE('<BILL>
<BILL_NO>1000</BILL_NO>
<SRNO>3456</SRNO>
<BILL_DTL>
<RECORD>
<LINE_NO>1</LINE_NO>
<ITEM_NAME>TOYOTA COROLLA</ITEM_NAME>
</RECORD>
<RECORD>
<LINE_NO>2</LINE_NO>
<ITEM_NAME>NISSAN CEDRIC</ITEM_NAME>
</RECORD>
</BILL_DTL>
</BILL>') xml_data
FROM dual
SELECT item_name
FROM XMLTable,
XMLTable('/BILL/BILL_DTL/RECORD'
PASSING xml_data
COLUMNS
item_name VARCHAR2(25) PATH 'ITEM_NAME'
Returns
ITEM_NAME
TOYOTA COROLLA
NISSAN CEDRIC
Maybe you are looking for
-
Satellite A300 thinks button is held down and won't start up (long)
Hey sorry this is so long but I would really love some help, Ok so I was just wondering if there is a way to fix this... I was on my Satellite A300 (just over a year old) last night playing the Left 4 Dead 2 Demo using the Stream network and all of a
-
Time Capsule as Hard Drive for older iMac
After upgrading to Snow Leopard on my MacBook, my family now has four laptops that can take advantage of time machine for wireless backups, so I want to buy time capsule to do that easily. Will I also be able to use it as a hard drive for an older no
-
ChaRM integration with third party tool
Hello, I have some talks withn customers regarding a scenario where Change Requests comes from a third party tool like HP Demand and Portfolio Management. A possible scenario is when there is a request for change which goes for a complex review and
-
I took pictures on my phone with photo editor, now I can't find them, how do I access them??
-
Premier Pro CS6-Capturing Footage, Serious Surprising Issue
I started editing using final cut pro 7 and i'm making the transition into the adobe video world. Premier is very simlar to final cut, but I think premier is much better as long as you can find your self around. I chose to capture vhs tapes through