Getting NaN as output in my display only item oracle - oracle11g

I am getting NaN as output in Display only field..
Below is my query which is in page (function and global variable)
In this i am getting NaN for the item when the value having comma like 1,500.0 :P2510_OUTSTANDING_AMOUNT

how to remove commas from unalloc_value in my Javascript
The same way you already do with match-value -
match_value = match_value.replace(/,/g, '');
match_value = Number(match_value, 10);
unalloc_value = Number(unalloc_value, 10); // BQ4-5024
Just add another replace:
match_value = match_value.replace(/,/g, '');
match_value = Number(match_value, 10);
unalloc_value = unalloc_value.replace(/,/g, '');
unalloc_value = Number(unalloc_value, 10); // BQ4-5024

Related

Oracle Stored Procedure unable to call from ASP.NET

I have written a code in ASP.NET to fetch data from Oracle stored procedure. But I get an error when trying to fetch the data:
ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'USER_FEEDBACK' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
Procedure code is this:
create or replace PROCEDURE user_feedback(cv_results out sys_refcursor,start_date IN VARCHAR2)
IS
BEGIN
open cv_results for
select pi.first_name || ' ' || pi.last_name initiator
......
from request_workflow w inner join request_workflow_attribute waRating
on waRating.request_workflow_id = w.row_id
and waRating.attr_name = 'UserRating'
.............
where w.date_stamp_utc between start_date and '31-dec-2015'
order by waRating.attr_value desc, eform_name;
END ;
This is my ASP.NET code:
Oracle.DataAccess.Client.OracleCommand objCmd = new Oracle.DataAccess.Client.OracleCommand();
objCmd.Connection = objConn;
objCmd.CommandText = "user_feedback";
objCmd.CommandType = CommandType.StoredProcedure;
Oracle.DataAccess.Client.OracleParameter oraP = new Oracle.DataAccess.Client.OracleParameter();
// System.Data.OracleClient.OracleParameter op = null;
oraP.OracleDbType = OracleDbType.RefCursor;
oraP.ParameterName = "cv_results";
oraP.Direction = System.Data.ParameterDirection.Output;
oraP.ParameterName = "start_date";
oraP.OracleDbType = OracleDbType.Varchar2;
oraP.Value = "01-Dec-2015";
oraP.Direction = System.Data.ParameterDirection.Input;
objCmd.Parameters.Add(oraP);
objConn.Open();
objCmd.ExecuteReader();
objCmd.ExecuteNonQuery();
Please suggest how to make it work.
You're only creating/adding a single parameter but assigning it twice with different values resulting in just one parameter to the call.
Instead, create and add two separate parameters, something like;
var oraP1 = new Oracle.DataAccess.Client.OracleParameter();
oraP1.OracleDbType = OracleDbType.RefCursor;
oraP1.ParameterName = "cv_results";
oraP1.Direction = System.Data.ParameterDirection.Output;
objCmd.Parameters.Add(oraP1);
var oraP2 = new Oracle.DataAccess.Client.OracleParameter();
oraP2.ParameterName = "start_date";
oraP2.OracleDbType = OracleDbType.Varchar2;
oraP2.Value = "01-Dec-2015";
oraP2.Direction = System.Data.ParameterDirection.Input;
objCmd.Parameters.Add(oraP2);
It's probably because you don't Add the first parameter. Try something like this?
...
oraP.ParameterName = "cv_results";
oraP.Direction = System.Data.ParameterDirection.Output;
objCmd.Parameters.Add(oraP);
oraP = new Oracle.DataAccess.Client.OracleParameter();
oraP.ParameterName = "start_date";
...
Though, it'd be better to declare another variable for the first param if you'll be reading from that refcursor later.

How can I set the column properties(DisplayFormatString to be precise) of a aspx(devExpress) grid from code behind?

I have an aspx(devexpress) grid. Using which I generate columns dynamically from code behind.Below is the code from my grid_databinding event.
GridViewDataTextColumn bfield = new GridViewDataTextColumn();
if (TestString.YearSelectedNames.ToString().Length > 4)
{ string colName = string.Empty;
if (iCount % 2 == 0)
{
colName = TestString.YearSelectedNames.ToString().Substring(5, 4) + "-" + dtFreezing.Columns[iCount].ColumnName.ToString();
bfield.HeaderTemplate = new DevxGridViewTemplate(ListItemType.Header, typeof(Label), colName, iCount);
}
else
{
colName = TestString.YearSelectedNames.ToString().Substring(0, 4) + "-" + dtFreezing.Columns[iCount].ColumnName.ToString().Replace('1', ' ');
bfield.HeaderTemplate = new DevxGridViewTemplate(ListItemType.Header, typeof(Label), colName, iCount);
}
}
else
{
bfield.HeaderTemplate = new DevxGridViewTemplate(ListItemType.Header, typeof(Label), dtFreezing.Columns[iCount].ColumnName.Trim(), iCount);
}
bfield.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
bfield.HeaderStyle.Wrap = DevExpress.Utils.DefaultBoolean.True;
bfield.Name = dtFreezing.Columns[iCount].ColumnName.Trim();
bfield.Width = Unit.Pixel(120);
bfield.VisibleIndex = iCount;
bfield.DataItemTemplate = new DevxGridViewTemplate(ListItemType.Item, typeof(Label), dtFreezing.Columns[iCount].ColumnName.Trim(), iCount);
bfield.CellStyle.HorizontalAlign = HorizontalAlign.Right;
bfield.PropertiesTextEdit.DisplayFormatString = "N2";
gridViewProductCrop.Columns.Add(bfield);
Here the line of code
bfield.PropertiesTextEdit.DisplayFormatString = "N2";
is where I am trying to set the property of the grids' column to display only two decimals after the decimal point.
This line of code doesn't seem to work in the first place.
I have even tried using "{0:0.00}" and "{0:N2}" but in vain
Possible reason being that I am writing this line of code in the grid's databinding event. But how else can I set the column properties from code behind
Try to change this code
bfield.PropertiesTextEdit.DisplayFormatString = "N2";
to
this.PropertiesTextEdit.DisplayFormatString = "N2";
i think this happen coz u loop the object(make a new object) and the properties would be overwrite.
CMIIW

Devexpress RespositoryLookUpEdit in grid , the value disaper

I have a devexpressgridcontrol. I want to use in one column of the grid : repositoryLookUpEdit.
I fill repositoryLookUpEdit with database question.
This question return three columns : IdPerson , Name and IdCity. Colums : IdPerson and Name have data but IdCity I have to set in appication.
So
- in gridcontrol the column Idcity has fildename : IdCity, and columnEdit : repositoryLookUpEdit.
- repositoryLookUpEdit has DisplayValue : CityName, and ValueMember: IdCity.
And my question is:
When I choose in grid in one row value of city and I go to another row, the value from the first row disaper.
What am I doing wrong? Could you give me some advise?
I use Devexpress 9.2.
this.gvPerson = new DevExpress.XtraGrid.Views.Grid.GridView();
this.replueCity = new DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit();
this.replueCity.Columns.AddRange(new DevExpress.XtraEditors.Controls.LookUpColumnInfo[] { new DevExpress.XtraEditors.Controls.LookUpColumnInfo("IdCity", "IdCity", 20, DevExpress.Utils.FormatType.None, "", false, DevExpress.Utils.HorzAlignment.Default), new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CityName", "CityName")});
this.replueCity.DisplayMember = "CityName";
this.replueCity.Name = "replueCity";
this.replueCity.NullText = "[Choose city]";
this.replueCity.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;
this.replueOceny.ValueMember = "IdCity";
// CityColumn this.CityColumn.AppearanceCell.Options.UseTextOptions = true;
this.CityColumn.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
this.CityColumn.AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
this.CityColumn.Caption = "Ocena";
this.CityColumn.ColumnEdit = this.replueCity;
this.CityColumn.FieldName = "IdCity";
this.CityColumn.Name = "IdCityName";
this.CityColumn.Visible = true;
You have to set ValueMember for replueCity (which is the editor in the column). You set it only for replueOceny.
Check string IdCity in all three cases: it must be written exactly the same (mind the caps!).

Calculate Sum of Oracle Apex Tabular Form Cell

There is a column as Amount in my oracle apex tabular form. I need to calculate SUM of all fields under this column while data is being entered and display on a Display only field below the tabular form.
I think this can be done using JavaScript and call that JavaScript at onchange of Amount column.
But I don't know how to calculate SUMof Amountcolumn in my oracle apex tabular form. How could I do this?
Add the following JavaScript code into the Page HTML Header property:
<script type="text/javascript">
function tot_cal()
{
var f5=new Array();
var tol=0;
f5=document.getElementsByName("f05"); /*f05 is Apex array which holds the data*/
for(i=0;i<f5.length;i++){
tol = (tol*1) + (f5[i].value.replace(/,/g, '') * 1);
}
/* alert(tol); */
$s('P10_AMOUNT_VALUE', tol.formatMoney(2,',','.'));
}
Number.prototype.formatMoney = function(decPlaces, thouSeparator, decSeparator) {
var n = this,
decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces,
decSeparator = decSeparator == undefined ? "." : decSeparator,
thouSeparator = thouSeparator == undefined ? "," : thouSeparator,
sign = n < 0 ? "-" : "",
i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
j = (j = i.length) > 3 ? j % 3 : 0;
return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
};
</script>
Tabular Form Element/Element Attributes property of the Amount column:
onchange="tot_cal();"

Flex AS3 Arraycollection sorting based on Array of values

I have been working on sorting Arraycollection like ascending , descending the numeric list. Total length of my collection will go up to 100. Now I want to preform sort to nested data like this
Data Structure
Name : String
Categories : Array ["A","x or y or z","C"]
Categories array will have maximum 3 items , out of that three items the second item can have 3 different values either X or Y or Z. My result data looks like here
{"Mike" , ["A","x","C"]}
{"Tim" , ["A","y","C"]}
{"Bob" , ["A","x","C"]}
{"Mark" , ["A","z","C"]}
{"Peter" , ["A","z","C"]}
{"Sam" , ["A","y","C"]}
anyone please explain how to sort this type of data in a way showing all "x" first , "y" next and "z" at the last and vice a versa. Any help is really appreciated. Thanks Anandh. .
You can specify a compare function in your SortField like this:
var sortfield:SortField = new SortField("Categories");
sortfield.compareFunction = myCompare;
var sort:Sort = new Sort();
sort.fields = [sortfield];
yourCollection.sort = sort;
and your compare function:
function myCompare(a:Object, b:Object):int {
/*
return -1, if a before b
return 1, if b before a
return 0, otherwise
*/
}
or something like that.. and it's untested code :)
I have created a new property to the data structure called categoryOrder In the setter I did the following and Am using the categoryOrder for sorting - sortBy = categoryOrder;. I understand little hard coding is needed but still I believe this will reduce the number of comparisons when I use compareFunction. Anyone please valid this idea. Thanks!
public function set categories(data:ArrayCollection) :void
{
if(data != null)
{
_categories = data;
for each(var categorie:Object in data)
{
switch(categorie.categoryName)
{
case "x":{categoryOrder = 1;break;}
case "y":{categoryOrder = 2;break;}
case "z":{categoryOrder = 3;break;}
}
}
}
}
Data Structure
Name : String
Categories : Array ["A","x or y or z","C"]
categoryOrder : Number

Resources