Decimal separator in the SELECT Clause
HelloI have the following parameters of decimal number:
SQL > select value
2 from v$ nls_parameters
3 where parameter = "NLS_NUMERIC_CHARACTERS;
VALUE
----------------------------------------------------------------
,.
If I show a decimal number, I get a comma as decimal separator
SQL > select 10/100 double;
10/100
----------
1
But if I use a decimal separator in the SELECT clause, I get:
SQL > select 100 * 1.1 double;
100 * 1 1
---------- ----------
1 100
It does not work. But the use of a period as the decimal separator works:
SQL > select 1.1 * 100 double;
1.1 * 100
----------
110
Maybe it's something that I never had to deal with before, but I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.
Kind regards
Nestor Boscan
Hi, Nestor,
user594312 wrote:
... I thought that the number format applied to results of sql, as well as the numbers you have used sql clauses.
No.; it applies to the results and it can affect implicit conversions, but it does not apply to the SQL code.
The period (or dot, '.') is the decimal separator in literals always digital. There is no way to change this.
Think how confusing it would be if it applied to the SQL code. For example:
WHERE num_col IN (1,2)
We compare num_col values 1 or 2? He comes in, what happens if we wanted to do the opposite?
If you really want to use the comma as the decimal separator, you may have to use strings, not numbers, and it could be much less effective.
For example:
SELECT 100 * TO_NUMBER ('1,1') -- This assumes your NLS settings are correct
FROM dual;
Of course, the effectiveness will not be a problem when you select 1 row of double.
Tags: Database
Similar Questions
-
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
But I tried the following:
DECLARE toto NUMBER := 10; tata NUMBER := 0; BEGIN SELECT toto INTO tata FROM employees WHERE employee_id = 101; DBMS_OUTPUT.PUT_LINE(tata); END; /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
Won't the doc or did I just miss something?
Thanks for your response!
Hello
rep0ne wrote:
Hello
Doc Oracle says the following on the identifiers in the SELECT in PL/SQL clause: there is no possibility of ambiguity in the SELECT clause because any identifier in the SELECT clause must be a database column name.
If we assume that only valid column identifier are allowed in the SELECT clause.
Post a link to this Oracle doc.
But I tried the following:
- DECLARE
- Toto NUMBER: = 10;
- Auntie NUMBER: = 0;
- BEGIN
- SELECT toto IN Auntie FROM Employees WHERE employee_id = 101;
- DBMS_OUTPUT. Put_line (Auntie);
- END;
- /
And there is no error telling me that toto is not a column in the employees table and the result is the same as: toto: = aunt;
...
You're right that toto is an identifier, but this isn't a column name. (Of a subquery) column alias are not database of the names of columns either, nor are the names of the user-defined function.
Also, there is a possibility for ambiguity even if all the names are the database column names.
Won't the doc or did I just miss something?
I can't say until I see the doc you're talking about.
Oracle documentation is sometimes misleading and sometimes just plain wrong. For each mistake outright example that I saw in the docs of Oracle, there might be 20 cases where the meaning is unclear or misleading and maybe 200 where I just read it wrong.
-
How to remove the name of the column in the select clause
Hello guys,.
I want to just delete a column name in the select clause. Because I don't want to write all the names of columns. I hope I am.
In other words, I want the following.
Select * - unwanted_column from table; instead of this Select col1, col2, col3, col4, ........ col 10000 from table;
Hello
There is nothing in SQL, which means "all columns * except *...» ». As others have said, the only way to achieve these results in SQL is to list all the columns you want.
Your front end may have a feature that allows you to hide a specific column. For example, in SQL * Plus, you can use COLUMN... NOPRINT , like this:
COLUMN dname NOPRINT SELECT * FROM scott.dept ORDER BY dname ;
Output:
` DEPTNO LOC ---------- ------------- 10 NEW YORK 40 BOSTON 20 DALLAS 30 CHICAGO
There is a column called dname in the scott.dept table; the query above uses actually. But, because of the order of the COLUMN, SQL * Plus will not display this column.
Published by: Frank Kulash on February 26, 2013 10:10
Example of scott.dept has changed. -
INSERT the SEQ WITH the question of the Select clause
Hello
I have Insert statement that I want to use seq with the select clause, but does not please help in this...
Insert in aaa (rowname, rowid, rowadd)
aa_seq.nextval, empaddress, and Select empname from emp;
Please, do not help to accommodate seq in the insert statement.Insert into aaa(rid,rowname,rowadd) select aa_seq.nextval, empname,empaddress from emp;
Do not use as ROWID column name.
-
instead of update, I want to incorporate in the select clause
instead of separate update, I want to incorporate in the select clause.
I use the following version
=====================
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
=============================
create table SpendBy AS NOLOGGING
SELECT commodities.commodity_level_1 mkt_sec.
0 AS mkt_sec_id,-instead of update, I want to integrate it in the select clause
Commodities.commodity_level_2 mkt_sub_sec
TO spend,
commodities
WHERE (spend.commodity_id = commodities.node_id)
Update SpendBy set mkt_sec_id = (select node_id from products where commodity_level_2 is null and commodity_level_1 = SpendBy.mkt_sec);
commit;I'm sorry, should have better considered in your code.
A then:
create table SpendBy NOLOGGING AS SELECT c.commodity_level_1 mkt_sec, select node_id as mkt_sec_id from commodities c2 where c2.commodity_level_2 is null and c2.commodity_level_1=c.commodity_level_1, c.commodity_level_2 mkt_sub_sec FROM spend s, commodities c WHERE s.commodity_id = c.node_id;
-
The decimal separator in the model generator XML Word formatting
Hello
I am a model in the XML Editor, for a report of accounts receivable in the E-Business Suite. So I use MS Word with the Publisher Oracle XML model builder plug-in software component.
The data comes from the E-Business suite by using the comma as decimal separator. For example: 123,99
My goal is to have the period as the decimal separator. For example: 123.99
Does anyone know what code should I use to achieve this?
Thanks colinin the next time use appropriate forum - Forum: Editor of BI - BI Publisher
>
The data comes from the E-Business suite by using the comma as decimal separator. For example: 123,99
My goal is to have the period as the decimal separator. For example: 123.99
>
usewhere VAL is tag with 123,99
-
Subquery in the select clause and not "a group by expression" error.
Hi all
I hope someone out there can help me out with this one. I have a sql query that performs a subquery in the select case combined with an aggregate function and gives me a "not a group by expression.
I created a simplified example
I'm sure he expected me to add the po_number to the group by clause, but this does not work and gives the error "invalid identifier".SELECT COUNT(*) , ai.invoice_num invoice_number , ai.description invoice_description , (SELECT poh.po_header_id FROM po_headers poh , po_distributions pod WHERE pod.po_distribution_id = aid.po_distribution_id AND pod.po_header_id = poh.po_header_id ) po_number FROM ap_invoice_distributions aid , ap_invoices ai WHERE ai.invoice_id = 1476932 AND aid.project_id = 8608 AND aid.task_id = 462202 AND ai.invoice_id = aid.invoice_id GROUP BY ai.invoice_num, ai.description;
Can someone suggest a way for a new concert the query so that I can add po_number to my education by clause.
KrisYou should try either:
SELECT COUNT (*),
AI.invoice_num invoice_number,
have. Description invoice_description,
(SELECT poh.po_header_id
OF po_headers poh,.
pod po_distributions
WHERE pod.po_distribution_id = aid.po_distribution_id
AND pod.po_header_id = poh.po_header_id
) po_number
HELP ap_invoice_distributions.
ap_invoices AI
WHERE ai.invoice_id = 1476932
AND aid.project_id = 8608
AND aid.task_id = 462202
AND ai.invoice_id = aid.invoice_id
Ai.invoice_num GROUP,
have. Description, aid.po_distribution_id;or
SELECT COUNT (*),
AI.invoice_num invoice_number,
have. Description invoice_description,
MAX ((SELECT poh.po_header_id
OF po_headers poh,.
pod po_distributions
WHERE pod.po_distribution_id = aid.po_distribution_id
AND pod.po_header_id = poh.po_header_id
po_number))
HELP ap_invoice_distributions.
ap_invoices AI
WHERE ai.invoice_id = 1476932
AND aid.project_id = 8608
AND aid.task_id = 462202
AND ai.invoice_id = aid.invoice_id
Ai.invoice_num GROUP,
have. Description; -
To generate the sequence in the select clause of the inner query
Hi all
Have the table and the data as below,
I want to generate a sequence number for all the distinct combinations of emp_id and emp_name running
DROP TABLE emp1.
CREATE TABLE emp1 (emp_id NUMBER, emp_name VARCHAR2 (100));
INSERT INTO emp1 VALUES (1, 'Name1');
INSERT INTO emp1 VALUES (2, 'Name2');
INSERT INTO emp1 VALUES (1, 'Name3');
INSERT INTO emp1 VALUES (2, 'Conjoint4');
COMMIT;
Output must be same as below:
EMP_ID EMP_NAME Reference ID 1 Name1 1000 1 Name1 1000 1 Name3 1001 2 Name4 1002 2 Name2 1003 "You cannot invoke CURRVAL and NEXTVAL in the subquery to CREATE."
"MATERIALIZED VIEW, or a SELECT, UPDATE, or DELETE statement;
Steve O'Hearn, Guide to preparing Oracle 1Z0-047
------
-
Calling a function in the select clause.
I'm using Oracle 11 g.
I am trying to write a query like this
SELECT name, age, sal, avg is avg_salary (age)
of the customer
where sal > = avg;
However, I am not able to do. What the query is trying to do is to print the name, age and the remuneration of each customer, as well as the average salary for the age of the customer where the customer pay is higher than the weighted average for his age.
Help, please. Thank you.OK, so what about:
SELECT c.name, c.age, c.sal, avg_salary (c.age) AS avg_sal FROM customer c WHERE c.sal > avg_salary (c.age)
-
The locale-specific decimal separator in Fmt?
Is there a way to get the floating point numbers using the locale-specific decimal separator in the Fmt() function?
It seems that SetSystemAttribute will only change the separator of UI elements, as described in this thread. Call setlocale (LC_ALL, "") doesn't seem to work either.
Is this possible?
Thanks for the reply. I ended up just do a search / replace and permutation of every instance of Fmt() with sprintf_s(), which DOES pay attention to the setlocale() function.
-
LV 8.6f1 - different decimal point to the development &; exe
Hello
In my program I want to use the decimal point '. ' and not the local symbol of the PC.
So, I turned this option in the category "FAÇADE".
In the development system, it works very well on the screen and in the recorded data (*.lvm & *.xls) files the "." will be used.
But when I create a my program exe file it will be always used a ',' as the decimal separator (on the same computer and screen in all the saved data files).
Can someone help me?
Jan
LV 8.6f1
The option is stored in the file LabVIEW.ini. This is what is used by the development environment. When you build an exe, the exe is using application_name.ini. So copy the configuration ini (useLocalDecimalPt = False) to application_name.ini, and who understand the distribution of your application.
-
Hi all
Suppose I have table, whose structure changes frequently on a daily basis.
For example. / / desc my_table gives you after the name of the column the day 1
SQL > my_table DESC;
Output
Name
Age
Phone
Day 2, two other columns are added, viz, address and salary.
SQL > my_table DESC;
Output
Name
Age
Phone
Address
Salary
Now, I want to create a Dynnamic RTF report which made extracting data from all columns from my_table daily. For this, I have defined a simultaneous program with XML output type and include in annex a data/definition of data model that takes XML as input and gives the final result of the conc program in EXCEL layout. I am able to do that for a constant number of columns, but don't know how to do it when the number of columns to display dynamically changes.
For 1 day my XML file should be like this.
<?xml version="1.0" encoding="UTF-8"?> <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0"> <dataQuery> <sqlStatement name="Q2"> <![CDATA[ SELECT Name ,Age ,Phone FROM my_table ]]> </sqlStatement> </dataQuery> <dataStructure> <group name="G_my_table" source="Q2"> <element name="Name" value="Name" /> <element name="Age" value="Age" /> <element name="Phone" value="Phone" /> </group> </dataStructure> </dataTemplate>
And my day 1, EXCEL output RTF model should be like this.
Name age phoneSwapnill 23 12345
For 2 days my XML file should be like this. With 2 new columns selected in the SELECT clause.
<?xml version="1.0" encoding="UTF-8"?> <dataTemplate name="XYZ" description="iExpenses Report" Version="1.0"> <dataQuery> <sqlStatement name="Q2"> <![CDATA[ SELECT Name ,Age ,Phone ,Address ,Salary FROM my_table ]]> </sqlStatement> </dataQuery> <dataStructure> <group name="G_my_table" source="Q2"> <element name="Name" value="Name" /> <element name="Age" value="Age" /> <element name="Phone" value="Phone" /> <element name="Address" value="Address" /> <element name="Salary" value="Salary" /> </group> </dataStructure> </dataTemplate>
And my day 2, exit EXCEL model RTF should be like this.
Name address telephone pay23 12345 Madrid 100000 Swapnill
Now, I don't know below things.
- Make the dynamic XML as we did in the day 1 there are 3 columns in the SELECT statement and the day 2, 5 columns. I want to create a dynamic XML which must not be changed if the new columns are added into my_table. I don't know how to create this query and also create their corresponding items below.
- Make the RTF model dyanamic as day 1 there are 3 exit EXCEL columns and the day 2, 5 columns. I want to create a dynamic RTF model that would display all the columns selected in XML dynamic. I don't know how the RTF will create new XML tags and how it will know where to place them in the report. Means, I can create model RTF day 1, by loading the XML data for 3 columns and place 3 tags XML in the model. But how he will create and place the tags for the new columns the day 2?
Hope so, you got my requirement, it's difficult. Please let me know how I can implement the necessary solution using the RTF dynamically without any manual intervention.
Kind regards
Patricia K.
Post edited by: SwapnilK
Hi guys,.
I was able to solve above the requirement.
I created a procedure that would create & update (attached to the data definition) XML file dynamically for each race. This dynamic XML contains the SQL statement for the data query that is built dynamically. I am updating this XML file using XDOLoader utility to the definition of data. Then run my program customized to generate the excel output.
Exit excel retrieves correct number of columns dynamically (3 on Day1 and Day2 5), with corresponding data records.
Kind regards
Patricia K.
-
Outer join - problem with the name of the table in the select list
Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
create table (j1)
number of C1,
number of C2);
create table (j2)
number of C1,
number of C2);
insert into values j1 (1, 10);
insert into j1 values (1, 100);
insert into values j1 (1, 1000);
insert into values j2 (1, 2);
insert into values j2 (1, 4);
insert into values j2 (1, 8);
commit;
Select c1, j1.c2, j2.c2 of outer join of j1 j2 using (c1); - DOES NOT
Select c1, j1 j2 (c1) using outer join j2.c2. - WORK
Why?
Hello
Interesting question! Oracle goes very far in trying not to trigger an error.
The OUTER keyword (if used; it is always optional) must be preceded by one of the keywords, right or LEFT. Since neither LEFT, RIGHT, or FULL comes before OUTER in queries in your first message, it does not recognize as keyword OUTER and treats him like a table alias for table j1. Since j1 has an alias, the real table name cannot be used in the SELECT clause. This query is executed:
SELECT c1
outer.c2
j2.c2
External J1
Join the HELP of j2 (c1)
;
There is an INTERNAL join. Add to your sample data:
insert into values of j1 (-1, -10);
insert into values of j2 (-2, -20);
to be specified.
Moreover, USING is short for confUSING. I suggest you use IT for all the join conditions. Everyone (unless they you write or read a manual) does.
-
Lexical parameters in the WHERE clause in error
Hello
Based on the settings, I need to change the place where the clause of the sql query in the data in the report model. After report params, I added the code as
: p_where1: = 'conditions...' » ;
and in the select clause
Select table.name
where & p_where1
I added the p_where1 as the parameter to use.
But when I say OK to the query in the data model. I am getting error like
ORA-00936: lack of expression
WHERE == >
Can someone help me why I get this error...
Thank you
HCHello
Set the initial value of the parameter as 1 = 1 try.
-Clément
-
Classification of the UNION by the select statement
I have an SQL statement composed of a bunch of different statements of union and I would that they sort by the first Union first, then the second, then third, etc.
SELECT *.
OF SERVICE_ADDRESS
WHERE SERVICE_ADDR_ST_NUM LIKE ('% A %')
UNION
SELECT *.
OF SERVICE_ADDRESS
WHERE SERVICE_ADDR_ST_NUM LIKE ("%B %')
UNION
SELECT *.
OF SERVICE_ADDRESS
WHERE SERVICE_ADDR_ST_NUM LIKE ('%C %')
I tried a bunch of different ways, but I get an error of invalid expression;
Can someone please show me how to sort this, so that all the results come first, then the B and the C?
I left all my other tests cause well, none of them worked lol. It's just the bare bones starting point
Thanks in advanceHello
You can do this more effectively and more easily without UNION, like this:
SELECT * FROM service_address WHERE CASE WHEN street_num LIKE '%A% THEN 1 WHEN street_num LIKE '%B% THEN 2 WHEN street_num LIKE '%C% THEN 3 END > 0 ORDER BY CASE WHEN street_num LIKE '%A% THEN 1 WHEN street_num LIKE '%B% THEN 2 WHEN street_num LIKE '%C% THEN 3 END ;
If you do not want to make the same expression BOX twice, then you can do in a subquery, but then you'd have either display the results or list all service_address columns in the SELECT clause.
Maybe you are looking for
-
2000 - 369wm: cmos lost password on laptop HP 2000-369WM
We lost the CMOS for this laptop. Getting error code 64915549 after 3 attempt. What's next? I can try to remove the CMOS battery, if I knew exactly where is was! Thank you
-
During the game Sim City for about an hour, the program stops automatically. This has happened several times recently. Don't know if it happens again with other programs. When I restart the game it works.Working on my new HP laptop. A lot of spee
-
Yes I know I'm a dinasauer still under kind of WinXp Pro Home edition use it - my burner gone--not recognized by my computer - I checked the Device Manager, they are there, but the two identical optical dvd rw drives have a! Mark surrounded both in y
-
cannot delete emails in outlook express
Original title: outlook express cannot delete emails from the Inbox
-
How to suspend purchases for MSN games?
I recently got a new count (portable) and why it will not down-load MSN games. I bought two games within the last week, the title appears, but there is nothing there. I would like to suspend or cancel my subscription purchase. Please tell me how t