set serveroutput on
declare
l_Char_Num varchar2 (40) := '&Enter_Number';
i number;
begin
i := to_number (l_Char_Num);
if ( i = trunc(i) ) then
dbms_output.put_line (i ||' is an Integer');
else
dbms_output.put_line (i ||' is not an Integer');
end if;
exception
when others then
dbms_output.put_line ('Not an Integer');
end proc;
/
Enter value for Enter_Number: 40.6
old 2: p_search varchar2 (40) := '&num';
new 2: p_search varchar2 (40) := '40.6';
40.6 is not an Integer
However, when run with -40, outcome is;
Enter value for Enter_Number: -40
old 2: p_search varchar2 (40) := '&num';
new 2: p_search varchar2 (40) := '-40';
-40 is an Integer
I use this blog as a dumping ground for various scripts as well as solutions to Maths problems.
Labels
- Alter (2)
- Analytic functions (2)
- AQ (2)
- AWR (4)
- Collections (2)
- Connect By (2)
- Constraints (7)
- Date/Time calculations (3)
- Dynamic SQL (4)
- Explain Plan (1)
- Formatting (3)
- Functions (1)
- Generating Functions (1)
- Indexes (7)
- Insert (3)
- JMS (3)
- Joins (4)
- LOB (3)
- locking (5)
- Partitions (3)
- Performance (10)
- Security (1)
- SQL Plus (3)
- Tabibitosan (1)
- Triggers (1)
- Views (1)
- XML (4)
Script categories
- Performance (10)
- Constraints (7)
- Indexes (7)
- locking (5)
- AWR (4)
- Dynamic SQL (4)
- Joins (4)
- XML (4)
- Date/Time calculations (3)
- Formatting (3)
- Insert (3)
- JMS (3)
- LOB (3)
- Partitions (3)
- SQL Plus (3)
- AQ (2)
- Analytic functions (2)
- Collections (2)
- Connect By (2)
- Explain Plan (1)
- Functions (1)
- Security (1)
- Triggers (1)
- Views (1)
Showing posts with label Formatting. Show all posts
Showing posts with label Formatting. Show all posts
Friday, 23 September 2011
Thursday, 22 September 2011
Format large number to spaces and commas
/*
to convert this number;
-13237836,2
to
-13 237 836,20.
*/
select to_char(-13237836.2
,'999g999g999d90'
,'nls_numeric_characters='', ''') Format_Number
from dual
/
to convert this number;
-13237836,2
to
-13 237 836,20.
*/
select to_char(-13237836.2
,'999g999g999d90'
,'nls_numeric_characters='', ''') Format_Number
from dual
/
Show todays date in Arabic
select to_char(sysdate, 'DD-Mon-YYYY') Today
,to_char(sysdate,'dd mon rrrr'
,'nls_calendar = ''english hijrah''') Arabic_Day
from dual
/
TODAY ARABIC_DAY
-------------------- -------------------------
22-Sep-2011 23 Shawwal 1432
,to_char(sysdate,'dd mon rrrr'
,'nls_calendar = ''english hijrah''') Arabic_Day
from dual
/
TODAY ARABIC_DAY
-------------------- -------------------------
22-Sep-2011 23 Shawwal 1432
Subscribe to:
Posts (Atom)