XML DB :: Xpath Functions In Oracle
Aug 24, 2012
Is there any function like fn:local-name(.) in oracle XPATH functions. I am new to Oracle & migrating procedure from SQL server to oracle where procedure taken XML script as input.
I need to convert below SQL server select statement to Oracle.
SELECT converseUID,
'Distributed',
cast(ServiceCalls.query('fn:local-name(.)') as varchar(100)),
1,
WIP.ServiceCalls.value('(TotalTime)[1]','int'),
WIP.ServiceCalls.value('(Status)[1]','varchar(100)'),
[code].......
View 5 Replies
ADVERTISEMENT
Oct 29, 2013
The types of query I refer to in the title are of this pseudo-code ilk:
select t.column_value
from table1 o, xmltable('for $co in $data
where $co/path1=$bind1
and $co/path2=$bind2
passing o.field as "data", :b1 as "bind1", :b2 as "bind2") t
where o.field = :b3
They're querying a table with a (binary) xmltype with a path/domain index over this column.As those who have had the (mis)fortune to run into these will know, the queries are extensively rewritten under the covers to access to xml via the paths supplied.
getting a baseline to work with queries like this? I was suspicious because whilst I can hint it to pick a certain access path first (leading()), the plan hashes remain the same.
I'm not sure, however, if I'm simply "doing it wrong" or it is just not possible with the level of recursive rewriting going on.NB: I consider myself reasonably competent in applying baselines to "traditional" queries...
View 7 Replies
View Related
Apr 29, 2013
I am getting the error when trying to run this test block, this is code is to simulate the production error we are getting...
DECLARE
g_xdoc XMLTYPE;
g_trans_type CHAR (20) := NULL;
BEGIN
SELECT xmltype(c) -- column is a clob column
INTO g_xdoc
FROM test_gil
[code]....
View 12 Replies
View Related
Apr 11, 2012
Can we override the pre defined functions in oracle. I am able to do this in my schema. But if DB server contains more than one schema do I need to write the same procedure in all schemes.
we can call the same procedure with schema name from different schemes also . But is there any way to over ride the actual function provided by oracle (just like over riding the equals method of object class in java).
create or replace function to_number(var varchar2) return number
is
no number := var;
begin
return 99999;
end;
SQL> select to_number(' 234 ') oracle_function , dbo.to_number(234) user_function from dual;
ORACLE_FUNCTION USER_FUNCTION
--------------- -------------
234 99999
View 4 Replies
View Related
Jan 20, 2011
the data in the column is in below format
---------------------
2/10/2009 9:28:41 PM
mm/dd/yyyy
my requirement is
--------------------
20090210
YYYYMMDD
View 5 Replies
View Related
Apr 26, 2013
I am developing android application connected to Oracle database using PHP, and I use PL/SQL statements with semantic technologies provided in Oracle(specifically, SEM_MATCH, SEM_MODELS, SEM_RULEBASES or something like this).
However, it doesn't work properly...the connection between android and Oracle works well, though. Also, the query statement is implemented well in the sql developer.The whole php code is shown below :
*<?php*
function db_connect()
*{*
*$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 203.249.105.20)(PORT = 1521)))(CONNECT_DATA=(SID=orcl)))";*
[code]...
View 6 Replies
View Related
Jan 2, 2013
writing a manual date validation function without using inbuilt oracle functions.I am planning to write this function in PL/SQL.
View 17 Replies
View Related
Apr 10, 2011
it is a good practise to assign different profile for oracle database users according to their job functions.what could be the resons for that?
View 3 Replies
View Related
Sep 26, 2012
In one of the interviews , I have attended the guy asked me to write a user defined function which will take the column name and list all the values .
For example
Table Name:Employees
Column Name: Employee_Name
Employee_name
Scott
Ivgun
Jack
Shane
The query should be in this fromat
SELECT col_agg(Employee_name) emp_name from Employees;
The output should be
Emp_names
scott,ivgun,jack,shane
View 6 Replies
View Related
Jun 23, 2011
I have a table that looks like this...
APPOINTMENT
APPOINTMENT PATIENT DENTIST PROCEDURE AMOUNT
NUMBER NUMBER ID NUMBER DATE BILLED PAYMENT
20000001 3001 27 33100 11-Feb-2000 405.00 405.00
20000005 3988 23 11201 05-Mar-2000 80.00 0.00
[code]...
and i used this to find which dentist had the least appointment
select min(count(dentist_ID)) as "Minimum Number of Appointments" from appointment group by dentist_ID;
and this shows..
Minimum Number of Appointments
------------------------------
2
if there's a way where I can show the dentist's ID that corresponds to this "min number of appointment" i tried doing
select dentist_ID, min(count(dentist_ID)) as "Minimum Number of Appointments" from appointment group by dentist_ID;
but it gives me this error
ERROR at line 1:
ORA-00937: not a single-group group function
View 9 Replies
View Related
May 13, 2010
I would like to use character functions (LPAD, INSTR, SUBSTR, etc) to accomplish what i feel should be rather easy. I would like to take the following character strings:
'ADAM ST #3 S_109640'
'ALBANY AVE #5 & #6 S_AL5&6'
'ALBIN RD #10A S_123318'
And make them
'ADAM ST'
'ALBANY AVE'
'ALBIN RD'
As you can see, it probably boils down to using SUBSTR, INSTR, RTRIM, and LENGTH??
View 10 Replies
View Related
Jul 25, 2006
analytic functions regarding the ORDER BY part =)
SQL> ed
Wrote file afiedt.buf
1 select *
2 from (select deptno, ename, sal
3 ,dense_rank() over (partition by deptno order by sal desc) rank
4 from emp)
[code]...
why is that i just added ename on the ORDER BY part of the DENSE_RANK and then
SQL> ed
Wrote file afiedt.buf
1 select *
2 from (select deptno, ename, sal
3 ,dense_rank() over (partition by deptno order by sal desc, ename) ran
[code]...
ADAMS and WARD we're removed from the result, why is it? did it rank it as UNIQUE per sal and ename?
View 9 Replies
View Related
Dec 3, 2012
Trying to understand how Oracle DATE works and how it differs to TO_DATE in the below manner...
SELECT DATE '2012-10-25' FROM DUAL;
SELECT TO_DATE('2012-10-25','YYYY-MM-DD') FROM DUAL;
I've had a look through the Oracle Docs but can't find much on this. Basically I want to know how safe the first option is and if it does the same as the second. Also, where does DATE get the Format String from (NLS setting?). Can it be employed to compare a literal with a date that has a TIME portion set to something other than 12:00:00?
View 2 Replies
View Related
Jul 2, 2010
count the no: of emp working under each manager? and instead of manager number display the manager name
View 5 Replies
View Related
Mar 27, 2012
Again i getting confused with conversion function especially Explicit data type conversions. some cases oracle server automatically converts the data to the required type. This is called IMPLICIT CONVERSION. Explicit conversions are done by using the conversion functions.
Oracle Explicit Data Type Conversions are
1 TO_CHAR
2 TO_DATE
3 TO_NUMBER
View 1 Replies
View Related
Feb 24, 2013
I have a table:
create table employee_function
(
id_emloyee number,
id_function number
);
with clients and their functions.
I want to extract all employes who has 2 functions (ex:id_function = 1 and id_function=2)
View 3 Replies
View Related
Nov 12, 2011
How can I rewrite this without the analytic functions?
SELECT employee_ID, first_name, salary,
RANK() OVER(ORDER BY salary desc) toprank_desc,
RANK() OVER(ORDER BY salary ASC) toprank_asc
FROM employees
ORDER BY first_name
View 2 Replies
View Related
Aug 31, 2012
we need to use recursion functions in pl/sql?? How can we use them in efficient way?? Also focus on mutual recursion in real world scenario.
View 4 Replies
View Related
Dec 6, 2012
Is there any way to apply the restriction on analytical functions, just like WHERE and HAVING .AS we know that we can apply the restriction on table by using WHERE and grouping functions by using HAVING clause .
For Ex: Departments wise count including all employees record :
SQL> select count(*) over(partition by deptno) dept_Count, ce.*
2 from scott.emp ce
3 order by deptno, job;
DEPT_COUNT EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ----- ---------- --------- ----- ----------- --------- --------- ------
3 7934 MILLER CLERK 7782 1/23/1982 1300.00 10
3 7782 CLARK MANAGER 7839 6/9/1981 2450.00 10
3 7839 KING PRESIDENT 11/17/1981 5000.00 10
5 7788 SCOTT ANALYST 7566 4/19/1987 3000.00 20
[code]....
View 4 Replies
View Related
Jan 17, 2011
I have created a package with some functions in it.I want to create a view with from 2 tables but also i wanto to use the functions from some fields of the view. (e.g. if the wview has 10 fields the 5 of them will be from the 2 tables and the other from package functions).
View 2 Replies
View Related
Nov 7, 2012
I am trying to Show all Customers (custId, last name, first name) who bought cars at the Arctic AND Pacific branches and Order it by CustId.
These are the tables:
VIN CARTYP BRNAME BUYERID SALEDATE
------- ------ ---------- ---------- -----------
1JJ0001 CT9015 Arctic
1NN0001 CT9014 Arctic 10010 18-mar-2012
1PP0001 CT7013 Arctic 10007 25-sep-2012
1QQ0001 CT7012 Atlantic 10014 22-dec-2009
1RR0001 CT7011 College 10013 30-sep-2012
2JJ0001 CT9015 Pacific
2NX0001 CT9014 Pacific
2PP0001 CT7013 Arctic
2QQ0001 CT7012 Arctic
[Code]...
CUSTID LNAME FNAME BALANCE_DUE
---------- ------------ ------- -----------
10001 Disney Daisy 9000.5
10010 Dupont Caryn 40000
10006 Gordon Diane 75000.5
10005 Gordon Tracy 3000.25
10013 Gross Henry 50000
10015 Hilton Kate 40000
10011 Lea Diane 12000
10003 Lopez Athena
[Code]...
No matter how I write the query, I get the message that no rows have been selected.
View 3 Replies
View Related
Aug 19, 2010
I am having some records in the table. If the record num is
1--It should show the month as "Apr"
2--"May"
3--"Jun"
4--"July"
5--"Aug"
6--"Sept"
if it is having other than these 6 should show "0" for the remaining months.
View 10 Replies
View Related
Jul 29, 2013
i want to get SUM(salary) by combining both employee and employees table.Look my table structure below:
SQL> select * from employee;
EMPNO ENAME HIREDATE ORIG_SALARY SALARY R MGR DEPTNO
---------- --------------- --------- ----------- ---------- - ---------- ----------
1 Jason 25-JUL-96 1234 8767 E 2 10
2 John 15-JUL-97 2341 3456 W 3 20
3 Joe 25-JAN-86 4321 5654 E 3 10
4 Tom 13-SEP-06 2413 6787 W 4 20
5 Jane 17-APR-05 7654 4345 E 4 10
6 James 18-JUL-04 5679 6546 W 5 20
7 Jodd 20-JUL-03 5438 7658 E 6 10
8 Joke 01-JAN-02 8765 4543 W 20
9 Jack 29-AUG-01 7896 1232 E 10
[code]....
Above, i used separate queries to get the result of SUM(salary) by deptno.Here, I want a single query to get SUM(salary) with deptno.
deptno Sum(salary)
----------------------------
10 30056
20 27132
30 6300
40 4300
View 4 Replies
View Related
Mar 18, 2010
DATA is like this;i want to insert to same set of rows again with increasing the MAIN_SEQ with 4,5,6.
DOCUMENT_ID MAIN_SEQ
VSISLG401 1
VSISLG401 2
VSISLG401 3
DATA is like this;i want to insert to same set of rows again with increasing the MAIN_SEQ with 4,5,6.
DOCUMENT_ID MAIN_SEQ
VSISLG401 1
VSISLG401 2
VSISLG401 3
INSERT INTO TEMP_TEST
[code]...
View 1 Replies
View Related
Jun 6, 2011
I use some quantity of functions with list of account id like in example below. Some functions use the same account id list, some use another. Everything works fine except those days when changes come and lists should be updated. Then I should edit each function... I think about creating new table for reference list like
CREATE TABLE MYREFERENCELIST
AS
SELECT XXXX AS ACCOUNTID, YYYY AS LIST1 FROM DUAL
UNION ALL
SELECT ZZZZ AS ACCOUNTID, UUUU AS LIST2 FROM DUAL
FUNCTION ACCOUNTID
(arc_date date,
cid number )
RETURN NUMBER
AS
[code]..........
View 11 Replies
View Related
Nov 20, 2012
Create and invoke the GET_JOB function to return a job title.
a.Create and compile a function called GET_JOB to return a job title.
b.Create a VARCHAR2 host variable called b_title, allowing a length of 35 characters. Invoke the function with job ID SA_REP to return the value in the host variable, and then print the host variable to view the result.
This is my FUNCTION:
CREATE OR REPLACE
FUNCTION GET_JOB(
p_jobid IN jobs.job_id%TYPE)
RETURN VARCHAR2
[code]...
This is how I invoked the FUNCTION but WHILE DECLARING THE BIND VARIABLE IT IS GIVING ME AN ERROR!!!!!
VARIABLE b_title VARCHAR2(35)
set serveroutput on
DECLARE
P_JOBID VARCHAR2(10);
v_jobtitle VARCHAR2(200);
[code]...
View 5 Replies
View Related
Aug 16, 2012
I have created the following function in oracle database 10g then I used it in Oracle reports 6 . It is working fine for single row(one value). But when there is multiple rows then it show error .
Note:ot.po_code is number datatype and clr_name is varchar2 data type.
this is the script
create or replace FUNCTION get_colour_name (POC number)
RETURN VARCHAR2 IS
CLR_NAME VARCHAR2(100);
BEGIN
SELECT DISTINCT BC.COLOUR_NAME INTO CLR_NAME
[Code].....
View 4 Replies
View Related
Sep 27, 2012
I have simplified this for ease of understanding. I have a Data column and a Month_ID column like this:
Values Month_ID
--------- -------------------------------------------------------
AAA 1
BBB 2
I split this out to values per year like this
Value_2011 Value_2012 Month_ID
-------------------------------------------------------------------------
AAA 1
BBB 2
Now i am trying to get the max(Value_2011) keep (dense_rank Last order by Month_ID) but i get a NULL. I can understand its because the Month_ID accomodates all years but i only need it to look at Month_ID for 2011 and return me the last dense_rank value, how can i achieve this?
I tried a couple of different methods like Last_Value() but i have group by in my original statement and i think analytical functions dont like GROUP by if they are not part of it. How can i achieve this?
View 2 Replies
View Related
Oct 21, 2010
I have a table (events) with this structure: customer_id, event_id, ... For each customer_id there can be several rows in the table. I need to run a query of the format: select customer_id, expensive_function(customer_id),... from events.
The expensive_function to be applied to customer_id in the query is really expensive (a Java class calculating a check sum) and the events table has billions of rows.
Rows in events table have same customer_id for a few rows, then continue with a different customer_id ang again coming back to the first, etc.
I was thinking that it should be a way to trigger calculation of expensive_function only when customer_id changes, in order to reduce the number of calls. Only my knowledge about SQL is not going that far and I cannot use PL/SQL or any other procedural language, need to stick to standard SQL (or Oracle version of it).
View 7 Replies
View Related
Feb 7, 2013
this query
SELECT
shrtgpa_pidm,
shrtgpa_term_code,
sum(shrtgpa_hours_earned) over (
partition by shrtgpa_pidm
order by shrtgpa_term_code
[Code]....
retrurns this rsult
82724 201010 4.5 201010
82724 201020 9 201020
82724 201110 13.5 201110
82724 201120 17.5 201120
82724 201310 20.5 201310
I need to be able to displayu the 4.5 in 201020 9 in 201110 in another words I need to move the results one term down
how I can do this?
I am thinking in a sequence? so 201010 will be seq 1
201020 will be seq 2
201110 will be seq 3
etc..etc..the I can do an update
Can this be done with aggr sql func? If not how I can add a sequence in the query It needs to break by shrtgpa_pidm
I need to end with these results
201020 4.50
201110 9.0
201120 13.50
201210 17.50
201220 21.50
here is the code to withe a table with data
create table testgpa
(
testgpa_pidm NUMBER(8) NOT NULL,
testgpa_term_code VARCHAR2(6 CHAR) NOT NULL,
testgpa_hours_earned NUMBER(9,3) NOT NULL
)
[Code]....
View 2 Replies
View Related