Sorting a column as a numeric value
Hello,
I have created a SQL Report using collections and having problems with sorting one of the column as a numeric value.
I have used create_collection_from_query2 to assign my numeric value as n001 variable. But, when i use the same in my SQL Report, it is considering the column as string.
Please advise if i am doing anything incorrect which is causing this issue.
Thank you in advance,
Madan
MadanN wrote:
An update to my above question:
I have used to_number() function in the select statement. But, i get an error "Invalid Number" error. I have checked the underlying data and confirmed that the data is a numeric value with a 2 point decimal value.
Just an FYI., i was using to_number() on apex_item.display_and_save function.
A function that clearly returns a VARCHAR2 result:
APEX_ITEM.DISPLAY_AND_SAVE(
p_idx IN NUMBER,
p_value IN VARCHAR2 DEFAULT NULL,
p_item_id IN VARCHAR2 DEFAULT NULL,
p_item_label IN VARCHAR2 DEFAULT NULL)
RETURN VARCHAR2;
SQL> with t as (
2 select trunc(dbms_random.value(0, 100)) n from dual connect by level <= 5)
3 select
4 n
5 , apex_item.display_and_save(1, n) d
6 from
7 t
8 order by
9 n;
N D
0 <input type="hidden" name="f01" value="0" /><span>0</span>
6 <input type="hidden" name="f01" value="6" /><span>6</span>
27 <input type="hidden" name="f01" value="27" /><span>27</span>
68 <input type="hidden" name="f01" value="68" /><span>68</span>
74 <input type="hidden" name="f01" value="74" /><span>68</span>
Making attempts to convert such results to a number using to_number clearly doomed to failure:
SQL> with t as (
2 select trunc(dbms_random.value(0, 100)) n from dual connect by level <= 5)
3 select
4 n
5 , to_number(apex_item.display_and_save(1, n)) d
6 from
7 t
8 order by
9 n;
, to_number(apex_item.display_and_save(1, n)) d
ERROR at line 5:
ORA-01722: invalid number
To make the column properly sortable in a SQL report:
Include the original number column in the query.
Reference the apex_item.display_and_save column name in the number column's HTML Expression property using column reference syntax (#COLUMN_ALIAS#).
Make the apex_item.display_and_save column hidden.
Similar Messages
-
How to get rows where a varchar column contain pure numeric value
hi,
i have to make a query from a table that return only the rows where the occurrences of a string column contain a pure numeric value
for example my table MYTABLE have the column COL1 varchar2(100)
with values
row 1 : '100'
row 2 : '101 dalmatiens'
row 3 : '102'
row 4 : 'anything'
i want to get only the rows 1 and 3 which are pure integer so i can sort and compare them like number.
thanksSQL> with rt as
2 (select '100' str from dual union all
3 select '101 dalmatiens' from dual union all
4 select '102' from dual union all
5 select '103 #$&''() 456' from dual union all
6 select 'anything' from dual)
7 /* End of sample data (rt) */
8 select str
9 ,trim(translate(str,'1234567890'||str,'1234567890')) num
10 from rt
11 where trim(translate(str,'1234567890'||str,'1234567890')) is not null;
STR NUM
100 100
101 dalmatiens 101
102 102
103 #$&'() 456 103456
-- Oooooops, I misread and now have corrected it
SQL> with rt as
2 (select '100' str from dual union all
3 select '101 dalmatiens' from dual union all
4 select '102' from dual union all
5 select '103 #$&''() 456' from dual union all
6 select 'anything' from dual)
7 /* End of sample data (rt) */
8 select str
9 ,trim(translate(str,'1234567890'||str,'1234567890')) num
10 from rt
11 where trim(translate(str,'1234567890'||str,'1234567890')) = str;
STR NUM
100 100
102 102Message was edited by:
ushitaki -
Sorting of columns in report with values from lookup table (LOV)
Hi,
I have a report where I looku the values using a number of LOVs. I'd like to enable sorting on those columns in the report whihc works BUT the report get's sorted on the numric looku pvalue instead of the description for example COUNTRY_ID instead of COUNTRY_DESC.
I have played around with the function APEX_ITEM.ITEM_TET_FROM_LOV in my SQL query:
select ID, NAME,
APEX_ITEM.TEXT_FROM_LOV(COUNTRY_ID, 'COUNTRY_LOOKUP') COUNTRY,
from VAR
But I get the following error:
report error:
ORA-06550: line 1, column 13:
PLS-00103: Encountered the symbol "COLLECT" when expecting one of the following:
:= . ( @ % ;
ORA-06550: line 1, column 82:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( , % from
So I am thinking that I am doing something very wrong? Is there another way to accomplish this?
Andyyou need to use htmldb_item.text_from_lov in your query.
this will then deocde the key value to the description within the query itself and therefore allow you to do your sorting. -
Finding Sum of the column whose column name is numeric value
HI All -
I have column names as years like 1990, 1991, 1992 and there are certain amount like below
*1990 1991 1992*
1000 5000 6000
2000 2000 3000
SUppose I want to find the sum of the amounts for year 1990, and I use the query like Select SUM(1990), it returns the sum of 1990+1990. How to make sure that 1990 is recognized as a column instead as a number.
ThanksHi,
To reference a column name that does not follow the normal rules (and starting with a digit does not follow the normal rules), then enclose the column name in double--quotes:
... SUM ("1990"), ...You can enclose any identifier in double-quotes, even ones that do follow the normal rules, but remember that anything inside any kind of quotes is case-sensitive.
If your query is assigning column aliases, like "1990", you might want to assign them only in the main query, after all references to them (like the SUM function you mentioned) have been done.
Depending on your front-end, you might get the same results by having the front end do the aliasing. For example, the SQL*Plus COLUMN command can assign an alias (like "1990") to a more gernerically named column (like year_1). Then you could use the noramlly named column throughout the query:
COLUMN year_1 HEADING "1990"
SELECT year_1
... SUM (year_1)
... -
Popup Key LOV, NULL and "Invalid numeric value undefined for column"
Hello.
I've created an item based on database column of NUMBER type and set the following properties:
Display As = Popup Key LOV (Displays description, returns key value)
List of values definition=select 'display_value' d, 1 r from dual
Null display value=%
Null return value=
Display Null=Yes
When I select "%" in the LOV and try to apply changes to database I get error:
ORA-20001: Error in DML: p_rowid=1781, p_alt_rowid=N1, p_rowid2=, p_alt_rowid2=. ORA-20001: Invalid numeric value undefined for column N2
Error Unable to process row of table TTT.
If I set Display As = Select List, all works fine. But I need Popup Key LOV.
Could anybody help me?
I use Application Express 2.2.1.00.04Hi all,
I did my homework and solved this issue. First I would like to thank Patrick Wolf for the invaluable help he gives out on thread Re: Null value handling in LOVs The code presented here is just a minor edit to his code, but an essential one when dealing with Popup Key LOV items.
Here's what I did:
1. Create an Application Process.
Name: RemoveNulls
Sequence: 0
Point: On Submit: After Page Submission - Before Computations and Validations
Process Text:
BEGIN
FOR rItem IN
( SELECT ITEM_NAME
FROM APEX_APPLICATION_PAGE_ITEMS
WHERE APPLICATION_ID = TO_NUMBER(:APP_ID)
AND PAGE_ID IN (TO_NUMBER(:APP_PAGE_ID), 0)
AND LOV_DISPLAY_NULL = 'Yes'
AND LOV_DEFINITION IS NOT NULL
AND LOV_NULL_VALUE IS NULL
LOOP
IF (V(rItem.ITEM_NAME) = '%null' || '%' OR V(rItem.ITEM_NAME) = 'undefined')
THEN
Apex_Util.set_session_state(rItem.ITEM_NAME, NULL);
END IF;
END LOOP;
END;Error Message: #SQLERRM#Condition: None
2. You should be able to submit a Popup Key LOV with a NULL value now.
Once again, THANKS, Patrick! You rock! I'm seriously thinking of trying ApexLib now :)
Georger -
Bug in sort of numeric values in ( title and album ) string.
The Bug in the sort-function of the iPod results in mixed up track list.
An album with more then 9 tracks will be sorted in the wrong way, when only title or filename or album field is just to give a track a number. The play order is 1, 10, 11, 12, 13, 2, 3 , 4 , 5, 6.... instead of the correct order 1,2,3,4,5,6...10,11, 12...
For example: After playing the track named "The Beatles - Yellow Submarine - 1 - Yellow Submarine" the ipod will play "The Beatles - Yellow Submarine - 10 - Baby, You´re A Rich Man" instead of "The Beatles - Yellow Submarine - 2 - Hey Bulldog."
The programmer have to search the string for numbers and join all numeric values to a single number.
Example: Sample data :abc123. is "a" a number? no. is "b" a number no. is "c" a number no. is "1" a number? yes. store. is "2" a number? yes. join to "1". (now we have "12"). is "3" a number? yes. join to "12". (Now we have "123") -> EOL
Is "123" largen than "99"? yes! is "123" larger than 124. no!
Thats it. In perl you need 1 line of sourcecode, in c and c++ this can be done in 10 lines. In java (there a objects for this type of sort).
And every user will be happy and nobody has to do the 01, 02, 03 workaround or reimport their audiobooks.
Alternativly Apple should thing about storing the original filename in the ID3 tag or itunes database. This would make sorting the files without id3 tags (believe me or not, there are many people using mp3 for 10 years and have no id3 tags in there mp3-library) in itunes possible. (there is a god free tagger for mac os but no for windows.)
A company like Apple should have the ability to correct the error / bug in the iPod-firmware (have the same issue in classic and iphone) or itunes-softwar.
This is a wellknown and very common error done by newbie programmers or people who have not read the documentation of the software-libraries.I still have an H140 in the cupboard. As I recall that needs leading zeros on filenames to sort properly. Since both WMP & iTunes include leading zeros it was never really an issue. THE Rename should be able to extract the track numbers from part of the filename and is also able to generate counters, along with the usual functions of setting tag fields from part of the file and/or folder name. Unfortuanetly THE Rename is still on the complicated side - I suspect there would be no easy way to lump together the variety of options that it has while keeping it very simple.
Once you've used an external program to adjust the tags you can make iTunes re-read them just by selecting the group of files in question, using CRTL-I to "Get Info." and then clicking OK +without making any changes+. iTunes will recheck it's database against any values in the tag and update as required. Given the lack of existing tags I would imagine that you don't let iTunes reorganise your music at the moment and would suggest you keep things that way at least until you are sure that all the tags have been correctly applied and you have a suitable backup. I stick to a Artist/Album/## Track structure which I don't let iTunes manage so that I can always recover details from the filesnames if I should ever accidentally edit more tracks than I intend.
tt2 -
Add numeric value to Table Column
Hello,
my problem:
I have a VO with a numeric attribute (Sal). This VO is shows in a table in a JSF Page.
I need to add to the column value a numeric value.
I try with #{row.bindings.Sal.attributeValue*2} or #{row.Sal+2} or #{row.Sal.inputValue+2} But I get an error.
Can someone help me ?
Thank You
JDev 11.1.3Hi,
an option would be to use a transient attribute in the VO to compute the maths or to populate the column field from a managed bean. You can point the column field to a managed bean property (say sumSal). In this method getSumSal() you
1. Use ELContext, ValueExpression, and ExpressionFactory to resolve the #{row} reference (you can cast it to oracle.jbo.domain.Row
2. call row.get("attribute_name") to access the field value
3. Perform the computation and return the value to display in the table
Note that using a transient attribute may be easier to achieve and easier to reuse in other usages of the VO. However, you have to options
Frank -
Checkbox and ORA-20507: Invalid numeric value #:# for column
Hi All,
I'm facing problems Checkboxes in a form.
I created a form and report on a table. one of the fields on the form is a checkbox and when ever I want to create a new record or update with more than one value for the checkkbox I obtain the following error:
ORA-20507: Invalid numeric value #:# for column COLUMN_NAME Where by #:# is numbers
I think the error occurs at the processes of get_pk and process_row_of_......
how should I change the processes to accommodate the checkbox values.
Kind regards
MelHi Roel,
Colunm = number
LOV Definition
select product display, prod_num return from product_category_vw
where prod_num not in (select p.prod_num from product_user_tb p, user_tb u
where p.user_num = u.user_number
and u.user_name = :APP_USER)
ORDER BY 1column = number
LOV Definition
select school d, sch_id r from school_tbRegards
Mel -
PL/SQL - column value is updated as 0 instead of numeric value
Declare
v_cnt varchar2(20);
v_cnd varchar2(20);
v_total varchar2(20);
begin
select count(emp_id) into v_cnt from emp1;
select count(emp_id) into v_cnd from emp2;
v_total:=v_cnt+v_cnd;
dbms_output.put_line('before');
dbms_output.put_line(v_total);
update emp3 set total_emp=v_total where dept_no=40;
commit;
dbms_output.put_line('after');
dbms_output.put_line(v_total);
end;
In the above program, value for the column total_emp is getting updated as 0 instead of numeric value. However, when I use dbms_output statement to print the value, for both the cases, before and after , I'm getting the numeric value for the variable v_total.
v_total value is not getting updated to column value in table.
table column definition for total_emp is varchar2(20).
Also, I tried to hard code value for total_emp column in the above statement and it worked.
So, the problem is variable value when used in the update statement it's not getting updated to column.
Please help me.Post a reproducable test case for us...
SQL> create table emp1 as select * from emp;
Table created.
SQL> create table emp2 as select * from emp;
Table created.
SQL> create table emp3 as select * from emp;
Table created.
SQL> alter table emp3 add (total_emp varchar2(20));
Table altered.
SQL> ed
Wrote file afiedt.buf
1 Declare
2 v_cnt varchar2(20);
3 v_cnd varchar2(20);
4 v_total varchar2(20);
5 begin
6 select count(empno) into v_cnt from emp1;
7 select count(empno) into v_cnd from emp2;
8 v_total:=v_cnt+v_cnd;
9 dbms_output.put_line('before');
10 dbms_output.put_line(v_total);
11 update emp3 set total_emp=v_total where deptno=10;
12 commit;
13 dbms_output.put_line('after');
14 dbms_output.put_line(v_total);
15* end;
SQL> /
before
28
after
28
PL/SQL procedure successfully completed.
SQL> select * from emp3;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO TOTAL_EMP
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10 28
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10 28
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10 28
14 rows selected.Works for me.. even with the incorrect datatypes.
You demonstrate exactly what you are doing. -
Sorting a column does not result in distinct values on Dashboard prompts
Hi,
We have a period column, the records of which are 'JAN-02' , "FEB-02"...."DEC-09". We need sort this column in descending order in Dashboard Prompts. We have another column "Date", which has been used to sort the period column. To achieve this in descending order, we have converted Show Results from “All Values” to “SQL Results” in dashboard prmpts, then entered the below sql.
SELECT "CODE COMBINATIONS"."LINE AC PERIOD" FROM INVOICE_PAYMENTS
order by "CODE COMBINATIONS"."LINE AC DATE" desc
The above sql resulted in non-distinct values as below. Using distinct in the above sql throws syntax error.
Period
JAN-09
JAN-09
JAN-09
FEB-09
FEB-09
How do we get distinct values and in descending order??
Thanks and appreciate any ideas
SuryaGo to advanced tab and check "Use distinct clause" that will fire a distinct to the query.
In the rpd month logical column , there is an option called sort order in the general properties and you need to specify the date column if you need to sort it based on the date column and in the Answers you can simply enable Descending sort order on the same column. That should take care of it
Hope it helps
Thanks
Prash -
Can we apply sorting on Column values in Cross tab??
Can we apply sorting on Column values in Cross tab??
Following is the scenario with me.
I have 2 fields and one formula.
Fields are HostName and Username.
Formula is status which categorizes the Authorized and Unauthorized events.
And in the Summary Field, I am calculating the total number of events.
In cross tab, Fields are marking the Rows of the cross tab and Formula is making the Columns(Authorized and Unauthorized ) of the cross tab.
Since in cross tab data is grouped from left to right and sorted by default. I want to remove this default sorting and want to put sorting on the formula for Unauthorized events.
Is there any way to fulfill this requirement?Hi,
You can assign a number to each Unauthorised field e.g
Rank Unauthorised
1 A
2 BC
3 DF
5 TD
6 GF
Then add "Rank" to the crostab Columns before the Unauthorised field. Then you can control the sorting order on your crosstab.
Hope this helps
Regards
Dotun -
Form error Invalid numeric value 06-Jun-13 for column FECHA_CAPTURA
hi,
i have an APEX form that updates a table. The form items were created autmatically from the table fields. The 3rd field is a date field and therefore the corresponding date field on the form has a calender icon on its right side. i choose a date from this calender and when i hit the update button i receive this message:
Invalid numeric value 06-Jun-13 for column FECHA_CAPTURA
any ideas?Hi,
Could we get you to change 1010319 to a meaningful handle -- I'm Howard.
In order to give helpful answers, we usually need more information including as much relevant information as possible upfront. This should include:
Full APEX version
Full DB/version/edition/host OS
Web server architecture (EPG, OHS or APEX listener/host OS)
Browser(s) and version(s) used
Theme used
Template(s) used / modified -- (Revelant/important for some problems.)
Region/item type(s)
and more detail about what you want to do.
Are you using ARP (Automatic Row Processing)?
Do you do any validations?
Could you make a trival 1-page application on apex.oracle.com duplicating the problem there?
Howard -
Particular column numerical value unable to convert/transfer to excel
Hi experts,
Could any body help in my newly developed ALV program where the required output is coming but one particular Numerical value column unable to export to excel. Apart from all the fields are exactly working and can do all the things. I am new to ABAP,so pl help to proceed further.
Regs.
S.RHi experts,
Myself solved the probelm, and the actual problem is due to in perform catalog i mentioned the wrong internal table name.
pls close this forum.
Regs.
S.R -
Script to replace non-numeric value of column to blank
Hi
I want to replace non-numeric value of column to blank. Can any one help me out.
For example:
column1
234 kjnkj 12e
555565asd44
1232334343
Now I want to that update cloumn with blank value which contains non-numeric value in itTry the following
select translate(column1,translate(column1,' +-123456789',' '), ' ') b from dual; -
Bargraph,icon and a numeric value, together in a single column of advance datagrid
Hiii,
I am trying to embed an icon, a bargraph with two values and a numeric value in a single column of advance datagrid. can anybody help me out in giving a solution for this...I have read a blog where the code explains about the bargraph in advance datagrid, I want to embed numeric value and icon too including bargraph in the column. I am looking for a Bargraph which takes two values
In the above image, the graph and rate is shown in a separate column , I require graph to be shown along with the numeric value and a icon in a single column.
The blog which i refered and got the above output is placed below, it can be used for the reference.
http://symmetri.blogsome.com/2009/05/22/render-a-bar-graph-within-a-datagrid/RVR,
This is a great exercise to get familiar with LabVIEW's array functions. A great place to start is actually the LabVIEW help on arrays, located here:
http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/grouping_data_with/
Depending on your data format, you can probably use the Read From Spreadsheet File VI to bring your data into a 2-d array. You could then use the index array VI to pull your column out. You could do this in a For loop and use Autoindexing to build your 1,000 column resulting array. I would leave everything as a String format until I'm done.
This doesn't sound like a very difficult task. Good luck!
--Paul Mandeltort
Automotive and Industrial Communications Product Marketing
Maybe you are looking for
-
What issues we may face in installing a new Prod portal with same SID as existing one
Hello All - We found some vbs script files in the host of EP Prod system. On confirmation from SAP we deleted those files without any harm to our prod EP system. But customer is still concerned about the security of the system and wanted us build the
-
Windows 7 64 bit install error
I have Window's 7 & I run 64 bit. Well Every single time I try to install iTunes 9.2.1 it says that part of the installation failed & it won't let my iPod nano or my gen. 5 iPod run on iTunes. So far every iPod I've tried says no then it tells me to
-
If I have installed InDesign CS6 on a windows computer and I want to change to a Mac. Can I use my licence or do I have to change to CC?
-
Hibernate3 error(antlr.jar) on SJSAS 8.1 EE
I have Hibernate3 app deployed on 8.1EE. After a simple select query I am getting this error in the logs. charScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlTokenI am using antlr-2.7.2.jar file. I copied it to server_home/lib and al
-
Ipad won't turn on to home screen
I downloaded the lated 7.1 or whatever software to my I pad now it is showing only the words ITunes and an icon of the charger. My I pad was fully functional before I updated, now nothing comes up I have turned it off and on several times - no good