Decimals in data value in SQL
Hi,
I have data column defined as Balance NUMBER(20,6) in my table. The data that I'm loading is 2500.44634. But, when I see in table, I see data coming as 2500.4. No matter how many decimals I give in datatype, table is displaying only one deimal value. Do I have to change settings anywhere to display complete decimals as I have in my original data
Thanks in advance
It is client who decides how to display, not database:
SQL> with t as (
2 select 2500.44634 balance from dual
3 )
4 select *
5 from t
6 /
BALANCE
2500.44634
SQL> column balance format 9999.9
SQL> with t as (
2 select 2500.44634 balance from dual
3 )
4 select *
5 from t
6 /
BALANCE
2500.4
SQL> column balance format 9999.99
SQL> with t as (
2 select 2500.44634 balance from dual
3 )
4 select *
5 from t
6 /
BALANCE
2500.45
SQL>
SY.
Similar Messages
-
How to add days to a date value in SQL plus
I would like to perform what ADD_MONTHS does, but for days.
I have tried ADD_DAYS with no result. It sais it doesnt recognise the column.Subtracting two dates gives the number of days beteen them. So, adding or subtracting a number and a date will increment or decrementthe date by that number of days.
If you really want a function, then:
CREATE FUNCTION add_days (p_date IN DATE,
p_days IN NUMBER) RETURN DATE AS
l_ret_dt DATE;
BEGIN
RETURN (p_date + p_days);
END;and you would cal it like:
SQL> SELECT sysdate, add_days(sysdate, 5) FROM dual;
SYSDATE ADD_DAYS(SY
29-NOV-2005 04-DEC-2005However, a function is certainly overkill for something that can be done simply as:
SQL> SELECT sysdate, sysdate + 5 FROM dual;
SYSDATE SYSDATE+5
29-NOV-2005 04-DEC-2005TTFN
John -
Adding day/hour/minute/second to a date value
How does one add a day/hour/minute/second to a date value?
SQL> select to_char(sysdate, 'DD/MM/YYYY HH24:MI:SS') to_day,
2 to_char(sysdate+1, 'DD/MM/YYYY HH24:MI:SS') add_day,
3 to_char(sysdate + 1/24, 'DD/MM/YYYY HH24:MI:SS') add_hour,
4 to_char(sysdate + 1/(24*60), 'DD/MM/YYYY HH24:MI:SS') add_minute,
5 to_char(sysdate + 1/(24*60*60), 'DD/MM/YYYY HH24:MI:SS') add_second
6 from dual
7 /
TO_DAY ADD_DAY ADD_HOUR ADD_MINUTE ADD_SECOND
10/10/2006 11:54:23 11/10/2006 11:54:23 10/10/2006 12:54:23 10/10/2006 11:55:23 10/10/2006 11:54:24
SQL>Cheers
Sarma. -
How to Get Default Value of a Data Type in SQL Query.
Hi all,
I am creating a procedure which will take input the table name and Column Name.
In the Output i would like to have the data type and default value of that data type which will be used by a another procedure to blank the selected column in the database.
I tried with SET NULL on the column but as the database is of navision the table have property set to NOT NULL.
Here is what i have done till now.
Create Procedure Get_Column_type
@parm_table_name nvarchar(200),
@parm_column_name nvarchar(20),
@parm_result nvarchar(20)OUTPUT
AS
BEGIN
select @parm_result =
DATA_TYPE from INFORMATION_SCHEMA.COLUMNS IC
where TABLE_NAME = '[' + @parm_table_name +']' and COLUMN_NAME = '[' + @parm_column_name + ']'
END
GO
Now instead on write a case statement for so many data types in SQL, i was thinking is it possible someway that above procedure also returns the default value which i can set in another procedure.
Let me know if its possible or not? Thanks in advance.Do you looking for something like this?
create table t10 ( c int default 1)
SELECT so.name AS table_name,
sc.name AS column_name,
sm.text AS default_value
FROM sys.sysobjects so
JOIN sys.syscolumns sc ON sc.id = so.id
LEFT JOIN sys.syscomments SM ON sm.id = sc.cdefault
WHERE so.xtype = 'U'
AND SO.name = 't10'
ORDER BY so.[name], sc.colid
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
SQL Loader-How to insert -ve & date values from flat text file into coloumn
Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide.Question: How to insert -ve & date values from flat text file into coloumns in a table.
Explanation: In the text file, the negative values are like -10201.30 or 15317.10- and the date values are as DDMMYYYY (like 10052001 for 10th May, 2002).
How to load such values in columns of database using SQL Loader?
Please guide. Try something like
someDate DATE 'DDMMYYYY'
someNumber1 "TO_NUMBER ('s99999999.00')"
someNumber2 "TO_NUMBER ('99999999.00s')"Good luck,
Eric Kamradt -
Hi all,
How to change a date value from "java.util.Date" to "java.sql.Date"?
I m still confusing what's the difference between them.....
thanks
Regards,
KinThanks
but my sql statement can only accept the format (yyyy-MM-dd)
such as "select * from xx where somedate = '2004-12-31'
but when i show it to screen, i want to show it as dd-MM-yyyy
I m using the following to change the jave.util.Date to str and vice versa. But it cannot shows the dd-MM-yyyy. I tried to change the format from yyyy-MM-dd to dd-MM-yyyy, it shows the wrong date in my application.
public String date2str(java.util.Date thisdate) {
if (thisdate != null) {
java.sql.Date thissDate = new java.sql.Date(thisdate.getTime());
return date2str(thissDate);
} else {
return "";
public String date2str(java.sql.Date thisdate) {
if (thisdate != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(thisdate);
} else {
return "";
public java.util.Date str2date(String thisdate) {
String dateFormat = "yyyy-MM-dd"; // = 1998-12-31
java.util.Date returndate = null;
if (thisdate != null) {
SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
try {
returndate = dateFormatter.parse(thisdate);
} catch (ParseException pe) {
System.out.println (pe.getMessage());
return returndate;
} -
Setting Default value with SQL Query as Data Model
Hi All,
I am developing report based on SQL query.date set as 'SQL Query'. I have created two params start-date and end-date. I am fetching records from database between these two dates.
I want to populate sysdate as a default values. I do not want to use datatemplate approach i mean using beforeReport trigger.
Thansk,
VaraHi Vara,
To set the default value for one of your parameters to SYSDATE you need to enter:
{$SYSDATE()$}
in the Default Value text box
Is this what you require?
Cheers
Andy -
Use evdre to query data from a SQL View
Hi all
I believe that it is possible to use evdre to query data from a SQL View. If this is possible then how does one go about setting it up in the evdre options (assuming that the view has already been created)?
Regards,
ByronByron, perhaps this is no longer supported, it might be worth opening up a case at service.sap.com on this. However, I did find the following on Page 11 of the "Usages and Considerations of EVDRE" pdf file. This doc is imbedded in the helpfile for BPC 7 SP5 (which was released in August of 2009, well after note 1315011 was last updated.
It looks like you are limited to one custom view per application, since you have to name the view in a parameter at the APPLICATION level. Go into BPC Administration, login to the application related to the custom view, choose "Set Application Parameters" and enter the name of the view to the Application Parameter called "EVDRE_QUERYVIEWNAME" If it is not listed, go ahead and create it at the bottom of the Application parameter screen.
Also: I interpreted the following info from Page 10 of the same doc:
In your EVDRE, set the following options:
QueryEngine: MANUAL
QueryType: enter either NEXJ OR TUPLE see below:
NEXJ - Use two-dimensional queries using the nonemptycrossjoin function
TUPLE - Use two-dimensional queries using tuples"
And I'm assuming you'd enter a Y for the following two parameters:
QueryViewName
"..to enforce the query engine to use a used-defined SQL view of the fact tables, when trying to read the values using SQL queries. This option is typically used in conjunction with the SQLOnly option (see below). "
Option SQLOnly
"..to enforce the query engine to only execute SQL queries, when reading data. This can be achieved using this option." -
Error while saving date value in Java dictionary
Hello Everybody,
I got following error while saving date value in one of the fields of the Java table.
Internal error occured in submit request: Error in method updateRequestContact : The object of type java.sql.Date with the value '2005-12-04 08:00:00.0' assigned to host variable 9 is not normalized. It must not contain time components in the time zone running the virtual machine.
I can't find why it is taking time value in the date object.
This value is coming from the RFC as a date value, and I am saving this value in Java dictionary table.
Same code for this was working fine earlier. But, now suddenly it gives error like this.
Even if I provide date on the screen from webdynpro application, this date value can't save in the Java dictionary and gives same error.
What should be the problem behind this?
Regards,
BhavikHi Satyajit,
I am getting date value from the screen of the webdynpro application from date picker control and passing this value in Java dictionary.
More Information:
I have dat value in the Date object: <b>target_date</b>
But Now I have made new Date object as following:
Date target_Date1 = new Date(target_date.getYear(),target_date.getMonth(),target_date.getDate());
Then I am passing this object to Java dictionary. Still it gives same error.
Then I have changed code as following:
int l_year;
int l_month;
int l_days;
l_year = target_Date.getYear();
l_month = target_Date.getMonth();
l_days = target_Date.getDate();
Date target_Date1 = new Date(l_year,l_month,l_days);
Now it works for me.
But I guess this is not the perment solution. It looks very strange. I have used so many date objects at various palces. So, this solution is not the final for me.
I want to findout the main cause of it.
One more thing: This code was working for a mornth or two. But, now suddenly it is giving this error.
Please help me if anybody knows.
Regards,
Bhavik -
A few years back I was architecting an occasionally connected .Net desktop application.
VS 2010 was offering full support for Microsoft Sync Framework and SQL CE with Entity Framework.
This seemed like the perfect marriage, so I ran with it, and the resulting software solution is still successfully running in production, years later.
Jump forward to today, and I am architecting a new occasionally connected .Net desktop application.
I was really looking forward to taking advantage of the advances made by Microsoft in using the tools built into VS 2013.
However, what I discovered has dumbfounded me. VS 2013 has no designer support for Sync Framework, and worse, built in support for SQL CE has been completely removed, including the ability to generate Entity Framework models from a
CE database using the designer.
My question to the community is, what tools should I be using to solve the problem of offline storage in my brand new .Net application?
I am aware of ErikEJ’s SQL Server Compact Toolbox, which brings back some support for these features in VS 2013, but it is not as fully featured as the VS 2010 native support was, plus it does not have the institutional “Microsoft” stamp on it.
I am building a multimillion dollar corporate solution that I will have to support for many years.
I would like to have some comfort that the technologies I select, today, will still be supported 5 years from now, unlike the way Microsoft has discontinued supporting Sync Framework and CE in the most recent VS.
I can accept open source technologies, because there is a community behind them, or off the shelf corporate solutions, since they will be driven by financial gain, but I have trouble committing to a solution that is solely supported by an individual,
even if that person is a very talented Microsoft MVP.
Some of the features of SQL CE that I would like to keep are
Built in encryption of the file on disk
Easy querying with an ORM, like Entity Framework
Tools to easily sync up the offline data store with values from SQL Server (even better if this can be done remotely, such as over WCF)
Does not require installation of additional software on the client machine, as SQL Express would
Please, provide your feedback to let me know how you have achieved this, without resorting to simply using an older version of VS or Management Studio.
Thank you.Hello,
Based on your description, you can try to use SQL Server 2012 Express LocalDB.
LocalDB is created specifically for developers. It is very easy to install and requires no management, but it offers the same T-SQL language, programming surface and client-side providers as the regular SQL Server Express.
SQL Server LocalDB can work with Entity Framework and ADO.NET Syc Framework. However, there is no built-in encryption feature in LocalDB which
can let you encrypt database. You should decrypt/encrypt data on your own, for example, using
Cryptographic Functions
Reference:SQL Express v LocalDB v SQL Compact Edition
Regards,
Fanny Liu
If you have any feedback on our support, please click here.
Fanny Liu
TechNet Community Support -
How to fetch the data from pl/sql table dynamically
Hi All, I have the requirement of comparing two db views data in pl/sql. So, I have bulk collect the view into pl/sql table. But, the issue is, It is expecting to provide the column name for comparison. But, in my case, column name is dynamic. So, i cannot provide the column name directly for comparison.
For eg: In my view t1_VW, i have 4 columns. stid, c1,c2,c3,c4 and similar structure for t2_vw
my code
TYPE v1_type IS TABLE OF t1_vw%ROWTYPE;
l_data v1_type;
TYPE v1_type1 IS TABLE OF t2_vw%ROWTYPE;
l_data1 v1_type1;
test varchar2(1000);
test1 varchar2(1000);
temp1 number;
begin
SELECT * Bulk collect into l_data
FROM T1_VW;
SELECT * Bulk collect into l_data1
FROM T2_VW;
select l_data(1).stid into temp1 from dual; -- It is working fine and gives me the value properly
-- But, in my case, we are reading the column names from array, i am constructing the query dynamically and execute it.
test :='select l_data(1).stid into temp1 from dual';
execute immediate test into temp1;
-- I am getting error as follows:
Error report:
ORA-00904: "L_DATA": invalid identifier
ORA-06512: at "SYSTEM.BULKCOMPARISON", line 93
ORA-06512: at line 2
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action
end;
- Please help me to get rid of this issue. Is it possible to construct the query dynamically and fetch the data?. If not, is there any other better approach to compare the data between two views?.Output should display what are all columns changed and its old value and new value.
For eg., output should be
COLUMNNAME OLD_VALUE NEW_VALUE STID
C1 20 10 1
C2 50 40 2
C3 60 70 2
C2 80 90 3Why no do this only via a simple sql ?
create table a (STID number, C1 number, C2 number, C3 number);
insert into a values (1, 20, 30, 40)
insert into a values (2, 40, 50, 60);
insert into a values (3, 90, 80, 100);
create table b as select *
from a where 1 = 0;
insert into b values (1, 10, 30, 40)
insert into b values (2, 40, 40, 70);
insert into b values (3, 90, 90, 100);
commit;And now you can issue such a kind of select
SELECT stid , c1, c2, c3
FROM
( SELECT a.*,
1 src1,
to_number(null) src2
FROM a
UNION ALL
SELECT b.*,
to_number(null) src1,
2 src2
FROM b
GROUP BY stid , c1, c2, c3
HAVING count(src1) <> count(src2)
order by stid;I would then create a new table a_b_difference having the same structure as a or b and insert into it like this
create table a_b_diff as select * from a where 1 = 0;
insert into a_b_diff
SELECT stid , c1, c2, c3
FROM
( SELECT a.*,
1 src1,
to_number(null) src2
FROM a
UNION ALL
SELECT b.*,
to_number(null) src1,
2 src2
FROM b
GROUP BY stid , c1, c2, c3
HAVING count(src1) <> count(src2)
order by stid
;Then each time there is a difference between a column in a and its equivalente one in b (per unique stid ) a record will be inserted in this table.
You can do more by adding the name of the table in front of each record in this table to see exactly where the data comes from
Best Regards
Mohamed Houri -
Reading Data from a SQL table to a Logical file on R/3 appl. Server
Hi All,
We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
I am new to ABAP , please let me know the steps to be done to acheive this .
Regards
- AjayHi,
You can find lot of information about Datasets in SCN just SEARCH once.
You can check the code snippet for understanding
DATA:
BEGIN OF fs,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
END OF fs.
DATA:
itab LIKE
TABLE OF fs,
w_file TYPE char255 VALUE 'FILE',
w_file2 TYPE char255 VALUE 'FILE2'.
SELECT carrid connid FROM spfli INTO TABLE itab.
OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" Server to write data
LOOP AT itab INTO fs.
TRANSFER fs TO w_file. "" Writing the data into the Application server file
ENDLOOP.
CLOSE DATASET w_file.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" server to read data
FREE itab.
DO.
READ DATASET w_file INTO fs.
IF sy-subrc EQ 0.
APPEND fs TO itab.
OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
" application server
TRANSFER fs TO w_file2.
CLOSE DATASET w_file2.
ELSE.
EXIT.
ENDIF.
ENDDO.
Regards
Sarves -
How to convert a date value into week value?
How to display the date value like '20010203'
into the week number of the year 2001?
When i type in the following sql
select week(chg_time) from site;
I got this error message
ORA-00904: invalid column nameuse the to_char function, to format the date into a week number (then you might need to convert that to a number using to_number)
select to_char( sysdate, 'WW') from dual`
a description of datetime formats: http://download-west.oracle.com/otndoc/oracle9i/901_doc/server.901/a90125/sql_elements4.htm#48515 -
Reg: Assigning a Date value in context
Hi,
Below is the code, where i am initializing a context with the date value. But the date value is not getting assigned to the context. What could be the problem? Kindly help me out.
String s = "12/31/9999";
try {
SimpleDateFormat sd = new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date date1 = (java.sql.Date)sd.parse(s);
Calendar c = Calendar.getInstance();
c.set(2006, 8, 22); //month is zero based
java.sql.Date date2 = (java.sql.Date)c.getTime();
wdContext.currentContextElement().setValidto(date1);
Thanks & Regards.Dhana,
Try this:
String s = "12/31/9999";
try {
//NOT USED ???
SimpleDateFormat sd = new SimpleDateFormat("MM/dd/yyyy");
java.sql.Date date1 = new java.sql.Date( ((java.util.Date)sd.parse(s)).getTime());
Calendar c = Calendar.getInstance();
c.set(2006, 8, 22); //month is zero based
java.sql.Date date2 = new java.sql.Date(c.getTimeInMillis());
wdContext.currentContextElement().setValidto(date2);
WD in fact requires java.sql.Date, but many Java API returns java.util.Date and you may not upcast java.util.Date to java.sql.Date
Valery Silaev
SaM Solutions
http://www.sam-solutions.net -
Data values on Bar Chart in a BI Publisher report (11g)
I have a bar chart that I created via the layout editor in BI Publisher 11g, and I'm displaying the data values on the chart. That part works great. However, we're noticing that the chart adds zeros to the end of the data values depending on the length of the number being passed to the chart. My data item is a number that is 5 bytes in total, with 2 decimals. If the data value is *10.10*, the data displayed on the bar chart shows *10.10*. But when my data value is *1.10*, the data displayed on the bar chart is *1.100*. And if my data value is *.10*, the bar chart displays *0.1000*. The bar chart adds zeros to the end as the number of characters to the left of the decimal decreases.
I don't see a way to make it not do that. Has anyone else run into this, and been able to change it?Basically what are you trying to do :
Attaching Mutiple Data Definition to a XML Program and deciding which one to call ased on parameter.Sorry you can not do that one Data DEfinition per Report.
ut there is one way of doing that.
Create multiple data defintion( mutiple programs) and then a master program something like
IF Master Program Param1 = 'X'
call BI Program 1
ELSIF Master Program Param1 = 'Y'
call I Program 2....
End IF;
Maybe you are looking for
-
We had a Linksys modem-router configuration previously and it worked just fine for all three printers in our home. 2 Canon's and 1 Kodak. In addition, my HP laptop cannot use the network at all and Im forced to use my mifi card at home for my work
-
Move Email folders to a Hotmail account
Does any one no how to move my folders to anther email account like hotmail I like verizon but my account has been hi jacked...
-
Merge 3 Unlinked Reports into a single Report
I have 3 Crystal Reports with different structures and groupings, I want to view it in single report .Right now I'm using Embedded Crystal Report hence I'm unable to merge it through the code .I require a solution to this. Thanks a lot in advance.
-
I try following code but selFahrtbu and selTouren is undefined. This should be the entity of the called Screens. Why are this undefined ? myapp.BrowseDisposaetze.QueryDispoSaetzeByDatAndFahrer_ItemTap_execute = function (screen) { var satztkz = scree
-
New music location not updating.
the other day my external hard drive took a turn for the worste so i had to recover all of my data onto another external hard drive. the data included all of my itunes music. now that its on a different drive, it cant find any of the music files when