between the clause of sql query?
Hi allAfter sql query using a report.
------------------------------------------------
Select trunc (m.spc_doc_date) prod_date, sum (nvl(d.req_qty,0)) order_qty, sum (nvl(d.spc_item_qty,0)) prod_qty
of spc_ppc_daily_m m, spc_ppc_daily_d d
where m.spc_doc_ # in (select spc_doc_ # to spc_ppc_daily_m)
- and d.blce_qty > 0
and m.spc_locn_code =: locn_code
and m.spc_doc_date between: TO_date and: FROM_date
and m.spc_locn_code = d.spc_locn_code
and m.spc_doc_ #= d.spc_doc_ #.
and (m.obu =: obu OR: OLGA IS NULL)
and (m.customer =: customer OR: CUSTOMER IS NULL)
Trunc Group (m.spc_doc_date)
order of trunc (m.spc_doc_date)
-----------------------------------------
"When I use to_date = 22 February 2012 ' from_date = February 22, 2012"
There is no pick up. (acually documents are there on February 22, 2012)
"When I use to_date = 22 February 2012 ' from_date = February 23, 2012"
now shows data of February 22, 2012.
I have replace between it of > = & < =, same result two cases respectively.
Why?
Thank you
Yoann
date you hours minutes and seconds
then
use
trunc (m.spc_doc_date)
or to: from_date in the parameter after form convert to February 23, 2012 23:59:59 '
Tags: Oracle Development
Similar Questions
-
Hi all
In addition to the discussion of yesterday (
)For a list of the table used in the SQL query, there is another way.
If we plan to explain for the query command, table plan we will be able to get all the table names.
But in the query, if we used all the views, the tables used in the underlying views are also the list.
I don't know how to do to get the name of view only, not the names of the underlying tables.
Thank you
Manon...
Dint you pick me up I guess. If you see the plan for performance that I posted you will find oracle have not all table EMP scan. There is therefore no reference to the EMP table in the PLAN_TABLE.
SQL > delete from plan_table;
0 rows deleted.
SQL > explain the plan for
2. Select empno in emp;He explained.
SQL > select * from plan_table where object_type = "TABLE";
no selected line
-
How can I parse the XML file using the Oracle's Sql query.
Hi all
I have an XML file that must analyze and display the result according to the following example
Can you please recommend me an approach to get the result.
For example, here is my XML:
<? XML version = "1.0" encoding = "UTF-8"? >
< xmlns:pi = "urn:com.workday / picof pi: Extract_Employees" >
< IP: employee >
< Additional_Information: pi > < pi: pi function: PriorValue = "" > Intern - masteri¿½s < / pi: function >
< / pi: Additional_Information >
< / pi: employee >
< / pi: Extract_Employees >
Databases:
Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - production
SQL > SELECT * FROM NLS_DATABASE_PARAMETERS;
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_NUMERIC_CHARACTERS.,.
WE8ISO8859P1 NLS_CHARACTERSET
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE AMERICAN
NLS_SORT BINARY
NLS_TIME_FORMAT HH.MI. SSXFF AM
NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR
NLS_DUAL_CURRENCY $
BINARY NLS_COMP
NLS_LENGTH_SEMANTICS BYTES
NLS_NCHAR_CONV_EXCP FAKE
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_RDBMS_VERSION 10.2.0.3.0
The Xml file above with UTF-8 character sets which is multi bytes.
But in my character database is WE8ISO8859P1 for example ISO-8859-1 (single-byte character set)
SQL > SELECT extractValue (Value (x) ', ' / pi:Employee/pi:Additional_Information/pi:Job_Title','xmlns:pi="urn:com.workday/picof ' ')
TABLE (XMLSequence (extract (XMLType (bfilename('XMLDIR','XML_Issue_227176.xml'), nls_charset_id ('AL32UTF8')),'/ pi: Employee ',' xmlns:pi="urn:com.workday/picof"'))) x;)))
which gives the following error:
Error:
ORA-31011: XML parsing failed
ORA-19202: an error has occurred in the processing of XML
LPX-00200: could not convert from UTF-8 encoding to ISO-8859-1
Error on line 1
ORA-06512: at "SYS." XMLTYPE", line 295
ORA-06512: at line 1
Also I tried with this
SQL > SELECT convert (extractValue (Value (x), ' / pi:Employee/pi:Additional_Information/pi:Job_Title','xmlns:pi="urn:com.workday/picof"'),'WE8ISO8859P1 ', 'UTF8'))
TABLE (XMLSequence (extract (XMLType (bfilename('XMLDIR','XML_Issue_227176.xml'), nls_charset_id ('AL32UTF8')),'/ pi: Employee ',' xmlns:pi="urn:com.workday/picof"'))) x;)))
The same error is according to the above error message.
Please help in this regard.
Thank you and best regards,
SandrineYou know the code of real character behind "" or you receive the file like that?
For the record, "" is the wildcard of UTF-8 (0xEFBFBD), so that the original character of the means has already been replaced and that very probably the file was not coded properly in the first place.
With respect to the resolution of the problem, try another method to read the file:
SQL> select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET'; VALUE ---------------------------------------- WE8ISO8859P15 SQL> SELECT x.* 2 FROM XMLTable( 3 XMLNamespaces(default 'urn:com.workday/picof') 4 , '/Extract_Employees/Employee' 5 passing xmltype( 6 dbms_xslprocessor.read2clob( 7 'COP_DIR' 8 , 'XML_Issue_227176.xml' 9 , nls_charset_id('AL32UTF8') 10 ) 11 ) 12 columns job_title varchar2(30) path 'Additional_Information/Job_Title' 13 ) x 14 ; JOB_TITLE ------------------------------ Intern - Master¿s
-
The Web-based SQL Query Builder
Hello
I have a generator of SQL query that allows users to create their own application graphically.
I have something I could use to do?
Thanks a lot for your help
JkoHello
I hope this help you start your applications to Query Builder
http://HTMLDB.Oracle.com/pls/OTN/f?p=18326:7:1636417102512483:P7_ID:161BR, Jari
Edit:
And this
http://HTMLDB.Oracle.com/pls/OTN/f?p=18326:7:1636417102512483:P7_ID:1222Published by: jarola October 29, 2009 12:30 AM
-
Using a procedure in the clause FROM a query
Is it possible to use a procedure which accepts several parameters and returns several parameters in the FROM of a query section?
I have a procedure that puts a format BS7666 address in a friendly format Oracle Apps.
I would like to be able to select the data from the source to feed through this procedure and output as part of a materialized view.
PROCEDURE Format_llpg_Address
(
In_Loc IN VARCHAR2,
In_Description IN VARCHAR2,
In_County IN VARCHAR2,
In_Town IN VARCHAR2,
In_PostTown IN VARCHAR2,
In_Saon_Start_num NUMBER,
In_Saon_Start_Suffix IN VARCHAR2,
In_Saon_End_num NUMBER,
In_Saon_End_Suffix IN VARCHAR2,
In_Saon_Text IN VARCHAR2,
In_Paon_Start_num NUMBER,
In_Paon_Start_Suffix IN VARCHAR2,
In_Paon_End_num NUMBER,
In_Paon_End_Suffix IN VARCHAR2,
In_Paon_Text IN VARCHAR2,
In_PostCode IN VARCHAR2,
Out_Address1 OUT NOCOPY VARCHAR2,
Out_Address2 OUT NOCOPY VARCHAR2,
Out_Address3 OUT NOCOPY VARCHAR2,
Out_Town OUT NOCOPY VARCHAR2,
Out_County OUT NOCOPY VARCHAR2,
Out_PostCode OUT NOCOPY VARCHAR2)
Thank you very much
Jason.You should look at [pipelined functions | http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/tuning.htm#i52954]
Adrian Billington has a number of excellent articles on the pipeline functions.
Here's a [link to one of them | http://www.oracle-developer.net/display.php?id=207]Published by: dombrooks on October 12, 2009 16:45
-
I have a question where I get the data from a range of dates
Select * from test_table where test_date between date1 and date2
The query will give record set between date1 and date2.
Now say date2 is null, in this case, I need to get all the records with test_date > = date1 as there is no limit on the date2.
I don't want to use dynamic SQL to do this, now how it can be done?
AB
Hi, Ab,
Here's one way:
Select *.
from test_table
where test_date between date1
and NVL (date2
test_date
)
;
and another:
Select *.
from test_table
where test_date > = date1
and (test_date<=>=>
Date2 IS NULL OR
)
;
-
Version
My querySQL> select * 2 from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio NLSRTL Version 10.2.0.4.0 - Production
Desired output:with tmp AS ( select 1 as num, 'karthik' as txt from dual UNION select 2 as num, 'john' as txt from dual UNION select 3 as num, '' as txt from dual UNION select 4 as num, '' as txt from dual UNION select 14 as num, 'tom' as txt from dual UNION select 15 as num, '' as txt from dual UNION select 26 as num, 'sam' as txt from dual UNION select 27 as num, '' as txt from dual UNION select 28 as num, '' as txt from dual ) select * from ( select num,txt,rw,'G'||dense_rank() over(order by (num-rw)) grp_id from ( select num, txt,row_number() over(order by num) rw from tmp ) ) model partition by(grp_id) dimension by(num) measures(txt,cast(null as varchar2(4000)) as last_row_col) rules (last_row_col[(num)] = max(txt)[num < cv()]) GRP_ID NUM TXT LAST_ROW_COL ----------------------------------------- ---------- ------- -------------------------------------------------------------------------------- G1 1 karthik G1 2 john karthik G1 3 karthik G1 4 karthik G3 26 sam G3 27 sam G3 28 sam G2 14 tom G2 15 tom
i.e.within Group (GRP_ID) the LAST_ROW_COL column must have the most recent (order by num desc) not null not the value that is displayed in the last line of this group in particular.GRP_ID NUM TXT LAST_ROW_COL G1 1 karthik karthik G1 2 john G1 3 G1 4 john G3 26 sam G3 27 G3 28 sam G2 14 tom G2 15 tom
So, it should be 'john' for the rest of the null values in the group G1 (Kiss will remain as for num = 1) which should appear on the final line of this group in particular.
Thanks in advance.
Published by: RUSSO on January 2, 2012 04:18RUSSO says:
I thought that this could be done easily using the power of the sql model clause
with tmp AS ( select 1 as num, 'karthik' as txt from dual UNION ALL select 2 as num, 'john' as txt from dual UNION ALL select 3 as num, '' as txt from dual UNION ALL select 4 as num, '' as txt from dual UNION ALL select 14 as num, 'tom' as txt from dual UNION ALL select 15 as num, '' as txt from dual UNION ALL select 26 as num, 'sam' as txt from dual UNION ALL select 27 as num, '' as txt from dual UNION ALL select 28 as num, '' as txt from dual ) select grp_id, num, txt, last_row_col from tmp model dimension by(row_number() over(order by num) rw) measures(num,txt,txt last_row_col,cast(null as varchar2(5)) grp_id) rules( grp_id[any] = 'G' || dense_rank() over(order by num[cv()] - cv(rw)), last_row_col[rw > 1] order by rw = case when last_row_col[cv()] is null then last_row_col[cv() - 1] else last_row_col[cv()] end, last_row_col[rw > 1] order by rw = case last_row_col[cv() + 1] when last_row_col[cv()] then null else last_row_col[cv()] end ) / GRP_I NUM TXT LAST_RO ----- ---------- ------- ------- G1 1 karthik karthik G1 2 john G1 3 G1 4 john G2 14 tom G2 15 tom G3 26 sam G3 27 G3 28 sam 9 rows selected. SQL>
SY.
Published by: Solomon Yakobson January 2, 2012 09:35
-
reload the page when SQL query returns a value
Hello world
the title of this discussion may seem strange, but I'll try to explain why I need this:
A user has the ability to connect on my APEX application. There are several tabs in my application that are visible only if a certain SQL statement returns a value which is not the case by default. The user has also the ability to download a file that is transferred to an external system that analyzes the file and writes the data in the database. During this writing process - which may take several minutes - conditions for some of the tabs to show the will becomes real (-> the query will return a value). When the user refreshes the page manually, the tabs will be displayed. However, I want the tabs will appear automatically when the condition is met.
Is it possible to refresh the page as soon as the query returns a value? It is perhaps possible to check it on the client side and trigger a refresh of the page when the condition is met. It would be even better if only the tabset has been updated, but refreshing the full page is fine as well.
Thank you!
Here is an overview of how it can be done
This is possible thanks to a dynamic action being performed on a timer.
View default tabs and dynamic action hide them on loading the page if they are not to be considered
Create a dynamic action that will execute your query every 5 seconds or more
If the query returns data, you can use the dynamic action to show your tabs using javascript
-
The Variable value based on the results of SQL query
With the help of OBIEE 11.1
Is it possible to set the value of a variable presentation of the results of a SQL statement?
Scenario:
I have 2 topics.
SubjectArea1
Text1
Date1
SubjectArea2
Field1
Field2
UpdateDate
I have an analysis that uses only the SubjectArea2.
Using a dashboard quickly, the user must be able to select Text1 in the other topic area (SubjectArea1).
Assuming that selection will be stored in a variable of presentation (SelectedText),
The filter in the analysis should be something like
Upper UpdateDate to @{SelectedDate}
How can I set a variable (SelectedDate) using a SQL statement?
Something like this:
SELECT "Date1" TO "SubjectArea1" WHERE "Text1" = @{SelectedText}
So the command prompt text selection should give a date that is used to filter the second review?
If so:
The prompt on SA1.textCol
hidden analysis who is invited on SA1.texCol has SA1.dateCol in the criteria
Analysis SA2.dateCol is filetered on basis of the results of another analysis (any value analysis hidden SA1.dateCol)
-
Placing values retuened to a cursor at the place where the clause of a query SELECT
Hello
I'm trying to accomplish a task of writing a SELECT statement where I have to query the table based on the values returned by a cursor.
For example:
SELECT a.operator_name, a.country_name, a.state_name FROM Table_A a WHERE a.country_id IN (values returned by cursor for country ID) AND the a.operator_name in (values returned by cursor for Operator_Id) AND a.state_id in (values returned by cursor State_ID for).
Is it possible to make this request, my task is to write it in a stored procedure so that I can return a cursor reference with values as described above.
Please let me know how to go about this request.
PS: Cursors are used because it is a Wild-Card search for values where several records can be returned.
Thanks in advance.
Kind regards
PriyaBecause your
SELECT a.operator_name, a.country_name, a.state_name FROM Table_A a WHERE a.country_id IN (Values returned from cursor for Country ID's) AND a.operator_name IN (Values returned from Cursor for Operator_Id's) AND a.state_id IN (Values returned from Cursor for State_ID's)
say something like (sliders deliberately avoided (see Tom Kyte mantra - http://asktom.oracle.com/pls/apex/f?p=100:11:0:::P11_QUESTION_ID:73891904732164))
SELECT operator_name,country_name,state_name FROM Table_A WHERE country_id IN (select country_id from countries where upper(country_name) like 'U%? ) AND operator_name IN (select operator_id from operators where operator_name like 'A%' ) AND state_id IN (select state_id from states where state_name like 'C%' )
Concerning
Etbin
-
get the node of SQL query file name
Hi all
I have a concurrent request that requires the name of file as input. For example, when I connect to oracle on our test instance, I use http://moon1.oando-plc.com:8000. For this program at the same time, the node file name appears as moon1.oando - plc.com.
I need to use this argument to a PL/SQL procedure, that I write and I don't want to use any hard coding.
Is it possible to get this data into an SQL statement.
Thank youHello
You can get table ICX_PARAMETERS (HOME_URL column). Orsearch profile options values for 'http' get the login page URL (or server name) - see (Note: 201945.1 - How E-Business Suite profile Option values list for all levels using SQLPlus).
Kind regards
Hussein -
Clause type SQL how can the others cannot?
Hi all
I met a topic called the type Clause when I was reading Pro Oracle SQL by Karen Morton, Kerry Osborne, Robyn SandsRiyaj Ntanguand Jared still. I just read the chapter and did some practice on my local machine. It is obvious that it is a very powerful feature. And I also reachered on the web and found out that it is used for spreadsheets (excel etc.). Can someone please give me a simple example which, in which case one must use the clauses types SQL Analytic Functions or group Advanced functions cannot cure?
Either said by the way, I recommend strongly Pro SQL Oracle book to all who want to learn the knowledge of SQL.
Thanks in advance
Hello
In short Yes, the TYPE clause allows you to perform calculations of "spreadsheet-like". With the help of the clause TYPE is quite rare. Now with the introduction of the WITH recursive clause in 11g 2, you can almost everything in SQL, do not even talk about the pattern match feature introduced in 12 c.
You can probably do now with analytical functions / recursive clause the clause of MODEL can do. And I must say that it is a shame that the TYPE clause has never been improved since its introduction in 10g.
In my view, the clause TYPE can come in handy when you need cross reference calculations (typically dealing with periods such as dates, years, weeks). For example, I personally used a MODEL clause for an analysis of sales time, where I watch the sales of previous years to find a pattern for the current. References of cells in a MODEL clause allows to easily, something like [my_year, my_week] model = local_pattern [(y ENTRE CV()-2 ET CV) (-1, w BETWEEN (CV-2) RESUME AND () + 2)]
-
SQL query to retrieve a single record for each employee of the following table?
Hi all
Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.
CREATE TABLE xxc_contact)
empnum NUMBER,
alternatecontact VARCHAR2 (100),
relationship VARCHAR2 (10),
phtype VARCHAR2 (10),
Phone NUMBER
);
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)
insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)
insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)
expected result:
EmpNum AlternateContact Relationship PhType Phone
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Thanks in advance.
994122 wrote:
Thank you all, that I got a result
http://www.orafaq.com/Forum/m/620305/#msg_620305
By Lalit Kumar B...
Specifically, the two simple solutions provided were:
1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).
SQL > column alternatecontact format A20;
SQL >
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))
3 FROM xxc_contact one)
4. WHEN r = 1
/
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.
SQL > SELECT empnum, alternatecontact, relationship, phtype, phone
2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)
3 WHERE phone = rn
4.
EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE
---------- -------------------- ---------- ---------- ----------
123456 rick Grimes SP cell 9999999999
Daryl Dixon EN work 7777777777 123457
Home 123458 Maggie Greene CH 6666666666
Kind regards
Lalit
-
Dynamic SQL query in the DB adapter
Hello
I want to use the following custom SQL query in the DB adapter:
SELECT EMP_ID, EMP_NAME, EMP_LOCATION FROM EMP WHERE EMP_ID IN (#iNPUT_PARAMETER)
the problem I'm facing is that I don't know at the time of the development that EMP_ID how much will be passed to the process so that I can not use the input parameter specific number. I cannot use it IN the query within which statement I concatenate all the EMP_ID separated by comma and passed under INPUT_PARAMETER, but when running, he read the full concatenated string as a single string rather than identify them as a list of different: with comma separation. could someone help me in this case
Thank you
SunilUse the following query with two parameters. Build the string with delimiter when running and pass this string and delimiter to query... (in this example, the input value would be the same for both Delimiter1 and Delimiter2.)
Select * from EMP WHERE deptno IN (SELECT SUBSTR (STRING_TO_TOKENIZE, DECODE (LEVEL, 1, 1, INSTR (STRING_TO_TOKENIZE, SEPARATOR, 1, LEVEL-1) + 1), INSTR (STRING_TO_TOKENIZE, SEPARATOR, 1, LEVEL)-DECODE (LEVEL, 1, 1, INSTR (STRING_TO_TOKENIZE, SEPARATOR, 1, LEVEL-1) + 1)) FROM (SELECT #StringToTokenizer | #Delimiter1 AS STRING_TO_TOKENIZE, #Delimiter2 AS DELIMITER FROM DUAL) CONNECT BY INSTR (STRING_TO_TOKENIZE SEPARATOR) ((, 1, LEVEL) > 0)
Thank you
-Sreeny -
Execution of the SQL query through 2 different databases to Oracle
Hi all
In Microsoft SQL server, we can run on 2 different databases depending on the type of SQL query:
Select * from TEST1.dbo.GENERIC_TABLE1 union select * from TEST2.dbo.GENERIC_TABLE2;
Test1 and TEST2 here is 2 different databases.
Can we do the same in Oracle?Of course you can do it.
Create a [database join | http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5005.htm] from DB1 to DB2.Grant select on the tables of the DB2 schema with which you want to connect.
And then, you can you can query as
select * from DB1schema.emp union select * from emp@dblink_name;
Maybe you are looking for
-
Ipod160GB classic sync problem
My iPod classic 160GB will not synchronize last purchases iTunes because of the iCloud required on iPod setting. Please indicate where to find this setting?
-
E-mail blackBerry Smartphones Reconcile personal Yahoo
I'm new to BB and I'm confused. I get my emails on my BB 8530 curve yahoo personal. This is what I want. I delete messages on my personal yahoo on my cell phone account and they are not deleted on my BB. I would like to have messages deleted on my B
-
Retrieve a .muse since export
HelloI have lost my file .muse (hard drive problem), however, I have still the whole export. Is it possible to 'rebuild' UN .muse from the export folder?Good to youChris
-
HelloYou are aware that FB 4.6 is not install more OS x 10.7.5 and maybe OS X in general?Because I really need design view last FB does not offer, I just downloaded 4.6 FB for OS X from Adobe: Adobe - Adobe Flash Builder 4: for Macintosh: Flash Build
-
Recommendation for the ESX infrastructure design
Hi all.What is a best practice on network virtualization infrastructure design?I intend to make a server with linux firewall and behind it DMZ with 4 nodes ESX and vCenter.It is important to vCenter as nodes ESX GW?I'm going to connect to vCenter via