Query required for xml processing.
This data is present in clob i need to extract the below mentioned field.
expected query is
select
extractvalue( xmltype(table1.column1), '/UserProfileSnapshot/UserInfo/Attribute[@name="Users.Display Name"]' )
from table1
first line is incorrect <?xml version = '1.0' encoding = 'UTF-8'?>
Can anyone please help me in making a query for this incorrect clob data.
As we cannot change this first line in data.
"<?xml version = '1.0' encoding = 'UTF-8'?>
<UserProfileSnapshot key="224" version="1.0">
<UserInfo>
<Attribute name="Users.Display Name">testfuturedate102, Mr. user</Attribute>
<Attribute name="USR_UDF_HR_ORG_ID">202</Attribute>
<Attribute name="Users.Xellerate Type">End-User</Attribute>
<Attribute name="Users.Role">Employee</Attribute>
<Attribute name="Users.First Name">user</Attribute>
<Attribute name="Users.Status">Active</Attribute>
<Attribute name="USR_UDF_LOCATION_ID">1737</Attribute>
<Attribute name="Users.Provisioned Date">2013-04-23 10:04:48 -0400</Attribute>
<Attribute name="Title">MR.</Attribute>
<Attribute name="USR_UDF_LOCATION_CODE">HR- New York</Attribute>
<Attribute name="Country">US</Attribute>
<Attribute name="State">NY</Attribute>
<Attribute name="Users.Password Reset Attempts Counter">0</Attribute>
<Attribute name="Users.Disable User">0</Attribute>
<Attribute name="Users.Change Password At Next Logon">1</Attribute>
<Attribute name="USR_CN_GENERATED">0</Attribute>
<Attribute name="USR_UDF_EFFECTIVE_START_DATE">2013-03-08 00:00:00 -0500</Attribute>
<Attribute name="Postal Code">10001</Attribute>
<Attribute name="Users.Update Date">2013-04-23 10:04:48 -0400</Attribute>
<Attribute name="Employee Number">2335</Attribute>
<Attribute name="USR_UDF_DEPARTMENT_NAME">Vision Corporation</Attribute>
<Attribute name="Users.Last Name">testfuturedate102</Attribute>
<Attribute name="Users.End Date">4712-12-31 00:00:00 -0500</Attribute>
<Attribute name="Hire Date">2013-02-28 00:00:00 -0500</Attribute>
<Attribute name="USR_UDF_PERSON_ID">31967</Attribute>
<Attribute name="USR_UDF_IS_MANAGER">N</Attribute>
<Attribute name="Users.Creation Date">2013-04-23 10:04:48 -0400</Attribute>
<Attribute name="Street">500 Madison Ave</Attribute>
<Attribute name="Users.User ID">31967</Attribute>
<Attribute name="USR_UDF_CITY">New York</Attribute>
<Attribute name="Users.Lock User">0</Attribute>
<Attribute name="Users.Updated By Login" key="4">OIMINTERNAL</Attribute>
<Attribute name="Users.Created By Login" key="4">OIMINTERNAL</Attribute>
<Attribute name="Users.Login Attempts Counter">0</Attribute>
<Attribute name="Organizations.Organization Name" key="4">Integra</Attribute>
</UserInfo>
</UserProfileSnapshot>"
As said in {thread:id=2545133}, the quotes are certainly not the issue.
This works fine for me on 11.2.0.2 :
SQL> insert into table1 (column1)
2 values (
3 '<?xml version = ''1.0'' encoding = ''UTF-8''?>
4 <UserProfileSnapshot key="224" version="1.0">
5 <UserInfo>
6 <Attribute name="Users.Display Name">testfuturedate102, Mr. user</Attribute>
7 <Attribute name="USR_UDF_HR_ORG_ID">202</Attribute>
8 <Attribute name="Users.Xellerate Type">End-User</Attribute>
9 <Attribute name="Users.Role">Employee</Attribute>
10 <Attribute name="Users.First Name">user</Attribute>
11 <Attribute name="Users.Status">Active</Attribute>
12 <Attribute name="USR_UDF_LOCATION_ID">1737</Attribute>
13 <Attribute name="Users.Provisioned Date">2013-04-23 10:04:48 -0400</Attribute>
14 <Attribute name="Title">MR.</Attribute>
15 <Attribute name="USR_UDF_LOCATION_CODE">HR- New York</Attribute>
16 <Attribute name="Country">US</Attribute>
17 <Attribute name="State">NY</Attribute>
18 <Attribute name="Users.Password Reset Attempts Counter">0</Attribute>
19 <Attribute name="Users.Disable User">0</Attribute>
20 <Attribute name="Users.Change Password At Next Logon">1</Attribute>
21 <Attribute name="USR_CN_GENERATED">0</Attribute>
22 <Attribute name="USR_UDF_EFFECTIVE_START_DATE">2013-03-08 00:00:00 -0500</Attribute>
23 <Attribute name="Postal Code">10001</Attribute>
24 <Attribute name="Users.Update Date">2013-04-23 10:04:48 -0400</Attribute>
25 <Attribute name="Employee Number">2335</Attribute>
26 <Attribute name="USR_UDF_DEPARTMENT_NAME">Vision Corporation</Attribute>
27 <Attribute name="Users.Last Name">testfuturedate102</Attribute>
28 <Attribute name="Users.End Date">4712-12-31 00:00:00 -0500</Attribute>
29 <Attribute name="Hire Date">2013-02-28 00:00:00 -0500</Attribute>
30 <Attribute name="USR_UDF_PERSON_ID">31967</Attribute>
31 <Attribute name="USR_UDF_IS_MANAGER">N</Attribute>
32 <Attribute name="Users.Creation Date">2013-04-23 10:04:48 -0400</Attribute>
33 <Attribute name="Street">500 Madison Ave</Attribute>
34 <Attribute name="Users.User ID">31967</Attribute>
35 <Attribute name="USR_UDF_CITY">New York</Attribute>
36 <Attribute name="Users.Lock User">0</Attribute>
37 <Attribute name="Users.Updated By Login" key="4">OIMINTERNAL</Attribute>
38 <Attribute name="Users.Created By Login" key="4">OIMINTERNAL</Attribute>
39 <Attribute name="Users.Login Attempts Counter">0</Attribute>
40 <Attribute name="Organizations.Organization Name" key="4">Integra</Attribute>
41 </UserInfo>
42 </UserProfileSnapshot>'
43 );
1 row inserted
SQL>
SQL> select x.*
2 from table1 t
3 , xmltable(
4 '/UserProfileSnapshot/UserInfo'
5 passing xmltype(t.column1)
6 columns userdisplay_name varchar2(30) path 'Attribute[@name="Users.Display Name"]'
7 , user_role varchar2(30) path 'Attribute[@name="Users.Role"]'
8 ) x ;
USERDISPLAY_NAME USER_ROLE
testfuturedate102, Mr. user Employee
Similar Messages
-
Dear Expert
I want the Query for to convert Value in to words,the value is the document total value.HI,
Try This It may help you
->> Create 1 UDF in Header on Requrie Documents (ex. Marketing Documents).
->> Create 3 Function in MSSQL Server Management.
->> Create 1 FMS in Query Generator and save as Query Manager then Assign to UDF for Amount in Words.
for example:
Create UDF in Header on Marketing Documents.
->> Choose Tools on Top menu.
->> User - Defined Fields. -> User Manage Fields.
->> Open the User Manage Fields Widnow.
->> Marketing Documents. -> Title.
->> Select Title and Click Add button in Bottom on User Manage Fields Window.
->> Create Amount in Words UDF(Code, Discription and Type - Character) and Add the UDF.
Create Function in MSSQL Server Management.
Check this Link, (have 3 Functions in Link).
http://techcreeze.blogspot.com/2008/11/convert-amount-into-words-according-to_15.html
1st Funciton - to Convert one Digit Number to words
2nd Funciton - to convert 2 digit number to words.
3rd Funciton - to convert amt in numbers to words.
->> Open the MSSQL Server Management Window.
->> Choose your Company database and Create NEW Query.
->> Create 3 Function Queries one by one.
->> Create 3 NEW Query Tab and 1st one put the 1st Function then Run the Function. and
2nd New Query tab put the 2nd Function then Run the Function.
3rd New Query tab put the 3rd Function then Run the Function.
Create FMS in Query Generator and Save as Query Manager.
->> Adminstration.
->> Reports. -> Query Generator.
->> Open the Query Generator and put the below FMS query.
for example : Purchase Order Doc. Toal(in wrods).
declare @Doc_total numeric (19,6)
set @Doc_total=$http://OPOR.DocTotal
select dbo.fNumToWords (@Doc_total)
->> Assign the FMS in UDF on Purchase Order.
->> Auto Refresh of Document Total.
Ex.
1. Goto the UDF and Clcik Shift+Alt+F2.
2. Select the SEARCH BY SAVED QUERY.
3. Assign the FMS Query.
4. Select the AUTO REFRESH WHEN FIELD CHENGES.
5. Select Document Total.
6. Check the Display Saved Values
I am including here, source code of functions required for converting Number into words according to Indian or Nepali Numbering style. In Indian or Nepali Numbering style, 100000 is 1 Lakh and 100 Lakhs or 10000000 is 1 Crore. This makes the numbering style different from English and International Numbering Style.
1. Function to Convert one Digit Number to words.
CREATE Function dbo.fConvertDigit(@decNumber decimal)
returns varchar(6)
as
Begin
declare
@strWords varchar(6)
Select @strWords = Case @decNumber
When '1' then 'One'
When '2' then 'Two'
When '3' then 'Three'
When '4' then 'Four'
When '5' then 'Five'
When '6' then 'Six'
When '7' then 'Seven'
When '8' then 'Eight'
When '9' then 'Nine'
Else ''
end
return @strWords
end
2. Function to convert 2 digit number to words.
CREATE Function dbo.fConvertTens(@decNumber varchar(2))
returns varchar(30)
as
Begin
declare @strWords varchar(30)
--Is value between 10 and 19?
If Left(@decNumber, 1) = 1
begin
Select @strWords = Case @decNumber
When '10' then 'Ten'
When '11' then 'Eleven'
When '12' then 'Twelve'
When '13' then 'Thirteen'
When '14' then 'Fourteen'
When '15' then 'Fifteen'
When '16' then 'Sixteen'
When '17' then 'Seventeen'
When '18' then 'Eighteen'
When '19' then 'Nineteen'
end
end
else -- otherwise it's between 20 and 99.
begin
Select @strWords = Case Left(@decNumber, 1)
When '0' then ''
When '2' then 'Twenty '
When '3' then 'Thirty '
When '4' then 'Forty '
When '5' then 'Fifty '
When '6' then 'Sixty '
When '7' then 'Seventy '
When '8' then 'Eighty '
When '9' then 'Ninety '
end
Select @strWords = @strWords + dbo.fConvertDigit(Right(@decNumber, 1))
end
--Convert ones place digit.
return @strWords
end
3. Function to convert amt in numbers to words. (Built with the help of above 2 functions)
CREATE function dbo.fNumToWords (@decNumber decimal(12, 2))
returns varchar(300)
As
Begin
Declare
@strNumber varchar(100),
@strRupees varchar(200),
@strPaise varchar(100),
@strWords varchar(300),
@intIndex integer,
@intAndFlag integer
Select @strNumber = Cast(@decNumber as varchar(100))
Select @intIndex = CharIndex('.', @strNumber)
if(@decNumber>99999999.99)
BEGIN
RETURN ''
END
If @intIndex > 0
begin
Select @strPaise = dbo.fConvertTens(Right(@strNumber, Len(@strNumber) - @intIndex))
Select @strNumber = SubString(@strNumber, 1, Len(@strNumber) - 3)
If Len(@strPaise) > 0 Select @strPaise = @strPaise + ' paise'
end
Select @strRupees = ''
Select @intIndex=len(@strNumber)
Select @intAndFlag=2
while(@intIndex>0)
begin
if(@intIndex=8)
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(left(@decNumber,1))+' Crore '
Select @strNumber=substring(@strNumber,2,len(@strNumber))
Select @intIndex=@intIndex-1
end
else if(@intIndex=7)
begin
if(substring(@strNumber,1,1)='0')
begin
if substring(@strNumber,2,1)<>'0'
begin
if (@strRupees<>NULL and substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and substring(@strNumber,7,1)='0' and @intAndFlag=2 and @strPaise=NULL)
begin
Select @strRupees=@strRupees+' and ' +dbo.fConvertDigit(substring(@strNumber,2,1))+' Lakh '
Select @intAndFlag=1
end
else
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(substring(@strNumber,2,1))+' Lakh '
end
Select @strNumber=substring(@strNumber,3,len(@strNumber))
Select @intIndex=@intIndex-2
end
else
begin
Select @strNumber=substring(@strNumber,3,len(@strNumber))
Select @intIndex=@intIndex-2
end
end
else
begin
if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and substring(@strNumber,7,1)='0' and @intAndFlag=2 and @strPaise='')
begin
Select @strRupees=@strRupees+' and ' + dbo.fConvertTens(substring(@strNumber,1,2))+' Lakhs '
Select @intAndFlag=1
end
else
begin
Select @strRupees=@strRupees+dbo.fConvertTens(substring(@strNumber,1,2))+' Lakhs '
end
Select @strNumber=substring(@strNumber,3,len(@strNumber))
Select @intIndex=@intIndex-2
end
end
else if(@intIndex=6)
begin
if(substring(@strNumber,2,1)<>'0' or substring(@strNumber,3,1)<>'0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and substring(@strNumber,6,1)='0' and @intAndFlag=2 and @strPaise='')
begin
if len(@strRupees) <= 0
begin
if convert(int,substring(@strNumber,1,1)) = 1
begin
Select @strRupees=@strRupees+'' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
Select @intAndFlag=2
end
else
begin
Select @strRupees=@strRupees+'' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
Select @intAndFlag=2
end
end
else
begin
if convert(int,substring(@strNumber,1,1)) = 1
begin
Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
Select @intAndFlag=1
end
else
begin
Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
Select @intAndFlag=1
end
end
end
else
begin
if convert(int,substring(@strNumber,1,1)) = 1
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakh '
end
else
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(substring(@strNumber,1,1))+' Lakhs '
end
end
Select @strNumber=substring(@strNumber,2,len(@strNumber))
Select @intIndex=@intIndex-1
end
else if(@intIndex=5)
begin
if(substring(@strNumber,1,1)='0')
begin
if substring(@strNumber,2,1)<>'0'
begin
if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and @intAndFlag=2 and @strPaise='')
begin
Select @strRupees=@strRupees+' and ' +dbo.fConvertDigit(substring(@strNumber,2,1))+' Thousand '
Select @intAndFlag=1
end
else
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(substring(@strNumber,2,1))+' Thousand '
end
Select @strNumber=substring(@strNumber,3,len(@strNumber))
Select @intIndex=@intIndex-2
end
else
begin
Select @strNumber=substring(@strNumber,3,len(@strNumber))
Select @intIndex=@intIndex-2
end
end
else
begin
if(substring(@strNumber,3,1)='0' and substring(@strNumber,4,1)='0' and substring(@strNumber,5,1)='0' and @intAndFlag=2 and @strPaise='')
begin
Select @strRupees=@strRupees+' and '+dbo.fConvertTens(substring(@strNumber,1,2))+' Thousand '
Select @intAndFlag=1
end
else
begin
Select @strRupees=@strRupees+dbo.fConvertTens(substring(@strNumber,1,2))+' Thousand '
end
Select @strNumber=substring(@strNumber,3,len(@strNumber))
Select @intIndex=@intIndex-2
end
end
else if(@intIndex=4)
begin
if ( (substring(@strNumber,3,1)<>'0' or substring(@strNumber,4,1)<>'0') and substring(@strNumber,2,1)='0' and @intAndFlag=2 and @strPaise='')
begin
Select @strRupees=@strRupees+' and' + dbo.fConvertDigit(substring(@strNumber,1,1))+' Thousand '
Select @intAndFlag=1
end
else
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(substring(@strNumber,1,1))+' Thousand '
end
Select @strNumber=substring(@strNumber,2,len(@strNumber))
Select @intIndex=@intIndex-1
end
else if(@intIndex=3)
begin
if substring(@strNumber,1,1)<>'0'
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(substring(@strNumber,1,1))+' Hundred '
Select @strNumber=substring(@strNumber,2,len(@strNumber))
if( (substring(@strNumber,1,1)<>'0' or substring(@strNumber,2,1)<>'0') and @intAndFlag=2 )
begin
Select @strRupees=@strRupees+' and '
Select @intAndFlag=1
end
Select @intIndex=@intIndex-1
end
else
begin
Select @strNumber=substring(@strNumber,2,len(@strNumber))
Select @intIndex=@intIndex-1
end
end
else if(@intIndex=2)
begin
if substring(@strNumber,1,1)<>'0'
begin
Select @strRupees=@strRupees+dbo.fConvertTens(substring(@strNumber,1,2))
Select @intIndex=@intIndex-2
end
else
begin
Select @intIndex=@intIndex-1
end
end
else if(@intIndex=1)
begin
if(@strNumber<>'0')
begin
Select @strRupees=@strRupees+dbo.fConvertDigit(@strNumber)
end
Select @intIndex=@intIndex-1
end
continue
end
if len(@strRupees)>0 Select @strRupees=@strRupees+ ' rupees '
IF(len(@strPaise)<>0)
BEGIN
if len(@strRupees)>0 Select @strRupees=@strRupees + ' and '
END
Select @strWords = IsNull(@strRupees, '') + IsNull(@strPaise, '')
select @strWords = @strWords + ' only'
Return @strWords
End
Regards
Balaji Sampath -
Query language for XML documents
Which is a better (efficiency in terms of memory management) query language for interacting with XML documents.The query language shouls support 'insert', 'delete', 'update' and 'select' commands. How fast is database as compared to XML ( database being replaced by XML) when only 'insert' n 'select' commands are issued?
Hi,
I suggest you use the Sunopsis JDBC for XML driver that will let you perform all kind of SQL statements on your XML files. It is a type 4 driver so it's very use to use. You may have more information and download it here:
http://www.sunopsis.com/corporate/us/products/jdbcforxml/
Hope that will help
Simo Fernandez -
Query language for XML that is going to remove use of database
Friends,
I want to know whether my idea is feasible or not.
I want to make a query language similar to SQL for XML which is going to remove the need for database for a large extent.
Their will be queries for making table,extracting data,making foreign key all through XML and no database.
I just want to know that is their any market value for such a project and will it be sellable,so that i can start working on it.There is no way to judge any future market for such a thing.
As it is, XML is widely abused, having mutated from its original purpose, a markup language readable by both machine and human, to a general data interchange language. It winds up being extremely slow and convoluted, in some cases overwhelming the hardware when a simple and common error occurs, then having to catch up. A big part of this is the silly and redundant method of defining metadata, again and again and again and again.
So what you want to do is create a database which will be highly formatted with redundant information, dynamically. This is silly, why does data need to be stored in a human readable format? It doesn't always even need to be presented in a human readable format! Why the heck would you need to read the bits of an mp4? Steganography?
What you are proposing is the exact opposite of what is needed. What is needed is a way to describe metadata for many different kinds of data, in a manner that can be interpreted by both man and machine at appropriate times, extensible for various paradigms.
What can be sold, on the other hand, is another question entirely, and not technical at all.
First definition of database that pops up during a search: an organized body of related information
Why would you want to get rid of that? -
I have found a script that contains the following:
stuff(
select
', ' +
fielda
from
tablea
for
xml path (''),
type).value
'nvarchar(max)')
,1,2,
anotherfield
This will concatenate field a and the stuff will remove the leading comma.
I have amended the script to the following and it still works:
Stuff(
select
', ' +
fielda
from
tablea
for
xml path (''))
,1,2,
Afield,
Please could somebody tell me why the following has been inserted after the
for xml path ('')
section
type).value
('.', 'nvarchar(max)')Erland - I just did a quick test. The differences weren't as bad as the subtree estimates would have indicated but they weren't exactly close either. The typed version (on average) took just over twice as long to execute.
Test conditions were as follows:
AdventureWorks2012 database
On average, the non-typed version executed in ~190 ms and the typed version executes in ~405 ms.
Test bed was the following:
@@VERSION =
Microsoft SQL Server 2012 - 11.0.2218.0 (X64)
Jun 12 2012 13:05:25
Copyright (c) Microsoft Corporation
Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )
Hardware =
Processor: Core i7-4770K @ 3.50GHz (4 physical cores / 8 logical cores)
Ram: 16.0 GB @ 2400 MHz
HD: SSD
Here are the two test scripts that I used... (each run in it own SSMS tab)
-- Typed version --
DECLARE @BegDT DATETIME2(7) = SYSDATETIME()
SELECT
sod1.SalesOrderID,
STUFF((
SELECT ', ' + CAST(sod2.ProductID AS VARCHAR(8))
FROM Sales.SalesOrderDetail sod2
WHERE sod1.SalesOrderID = sod2.SalesOrderID
FOR XML PATH(''), TYPE).value('.', 'varchar(max)'), 1, 2, '') AS csv
FROM
Sales.SalesOrderDetail sod1
GROUP BY
sod1.SalesOrderID
SELECT DATEDIFF(ms, @BegDT, SYSDATETIME()) AS ExecTimeMS
-- Non-typed version --
DECLARE @BegDT DATETIME2(7) = SYSDATETIME()
SELECT
sod1.SalesOrderID,
STUFF((
SELECT ', ' + CAST(sod2.ProductID AS VARCHAR(8))
FROM Sales.SalesOrderDetail sod2
WHERE sod1.SalesOrderID = sod2.SalesOrderID
FOR XML PATH('')), 1, 2, '') AS csv
FROM
Sales.SalesOrderDetail sod1
GROUP BY
sod1.SalesOrderID
SELECT DATEDIFF(ms, @BegDT, SYSDATETIME()) AS ExecTimeMS
If you see holes in my test approach, please let me know.
Thanks,
Jason
Jason Long -
Query required for JE posted with the customer
Dear Experts,
Following is the scenario - Accountant passes Journal Entries once in a while with regard to customers also, i would require a alert for the scenario.
Whenever the user posts a JE with regard to a customer alert has to generate to the manager else a query report is required would do.
SaravananHi,
You can use the below as an alert for Manual Journal Entries that has been created the last 2 days with posting to Business Partner account.
SELECT t0.transid, t0.shortname
FROM JDT1 T0 INNER JOIN OJDT T1 ON T0.TransId = T1.TransId
WHERE shortname <> account and T1.createdate > getdate()-2 and t0.transtype = 30
If you want to have a different date range just change the '-2' to the amount of days you want, if you only want entries created today, just remore it. If you prefer it to be by posting date rather than by creaation (system) date, just change createdate to refdate.
Hope it helps,
Jesper -
Query required for below situation.
Hi All,
I have two table
T1 --> deal_site_id, subsection_id
T2 --> deal_site_id, subsection_id, catalog_id
requirement is first I need to check all the subsection_id in table T1 depending upon one deal_site_id.
Then what ever subsection_id I get from table T1 I need to check if those are available in table T2. If they are available then do nothing but if they are not available in table T2 then delete the row from table T1.
I've tried to write the query like below but stuck with exception.
DELETE FROM (SELECT * FROM T1 lid inner join T2 ld
ON LID.DEAL_SITE_ID = LD.DEAL_SITE_ID
WHERE lid.deal_site_id = 3070
AND LD.SUBSECTION_ID NOT IN (SELECT DISTINCT liod.subsection_id from T1 liod where liod.deal_site_id = 3070 )
this is giving me an exception like ORA-01752: cannot delete from view without exactly one key-preserved table
Please help me to write this query. Thanks in advance.
Regards,
Subhadeep
Edited by: sumajumd on Feb 2, 2012 3:08 AMHi, Subhadeep,
That sounds like:
DELETE FROM t1
WHERE deal_site_id = 3070 -- or whatever
AND subsection_id NOT IN (
SELECT subsection_id
FROM t2
WHERE deal_site_id = t1.deal_site_id
AND subsection_id IS NOT NULL -- If necessary
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as DELETE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using. -
Below is the condition for which a query is to be written.
as of now this the query i have written. am getting the orderids which satisfy this rule but the output should include all those orderids which already satisfy the rule.(i.e the current o/p contains those orderids which share a common circuitid and have same start and end dates. the output required should include this as well as those orderids tat do not share circuitids.
or
the o/p should contain those orderids which do not fall into any of these categories)
The Rule:
For the Entity Circuit Orders if the Circuit Id is same for two different order IDs then the Order Start Date for the Order Id having Order Status as Installed should be same as the Order End Date for the Order Id having Order Status as Retired.
Tthe query:
select order_id from managed_element1 where order_status = 'I' and order_start_date in
(select order_end_date from managed_element1 where circuit_id in
(SELECT circuit_id FROM managed_element1 where order_status='R' GROUP BY circuit_id))The data is as below
Order_id circuit_id start_date end_date order_status
ORDER_67 BORDER_2 03/05/06 05/09/06 R
ORDER_7 BORDER_6 10/26/06 I
ORDER_11 BORDER_7 12/05/06 12/06/07 I
ORDER_1 BORDER_2 05/09/06 05/19/06 R
ORDER_2 BORDER_2 05/19/06 I
ORDER_3 BORDER_3 04/03/06 05/20/06 R
ORDER_4 BORDER_3 05/20/06 I
ORDER_5 BORDER_4 02/05/06 05/06/06 R
ORDER_6 BORDER_4 05/05/06 I
ORDER_7 BORDER_5 10/22/02 02/23/03 R
ORDER_8 BORDER_5 02/23/03 I
ORDER_9 BORDER_6 03/12/06 09/26/06 R
ORDER_10 BORDER_6 09/26/0610/26/06 R -
Query Requirement for Stock on hand.
Hi All,
Actually I am have written a query for showing a running total for an Item with all Sales Order and Purchase Order order by ship date (due date).
SELECT T0.[ItemCode], T0.[ShipDate],t2.[CardCode],t4.[OnHand],-T0.[OpenQty]*t4.[NumInSale] as StockMovt FROM RDR1 T0 INNER JOIN ORDR T2 ON T0.DocEntry = T2.DocEntry INNER JOIN OITM T4 ON T0.[ItemCode]=t4.[ItemCode] WHERE T0.[ItemCode] =[%0] and T2.[DocStatus] ='o'
UNION
SELECT T1.[ItemCode], T1.[ShipDate],t3.[CardCode], t5.[OnHand], T1.[OpenQty] as StockMovt FROM POR1 T1 INNER JOIN OPOR T3 ON T1.DocEntry = T3.DocEntry INNER JOIN oitm t5 ON T1.[ItemCode]=t5.[ItemCode] WHERE T1.[ItemCode]=[%0] and T3.[DocStatus] = 'o' ORDER BY [ShipDate]
What i require is the additional field which shows the cumulative or running total for each record. Can anyone please help in how it can be achived.
Thanks & Regards
ShivaHi Prasanna,
I made some modification to ur query and its perfectly working. I still have the other query...can you please help me.
The out put that you have asked for is as follows
# ItemCode ShipDate CardCode OnHand StockMovt
1 BAS3B 04.06.09 AUCHRA 14,320.00 -108
2 BAS3B 04.06.09 BLUMER 14,320.00 0
3 BAS3B 04.06.09 GREENTsup 14,320.00 0
4 BAS3B 05.06.09 bizzy 14,320.00 -12
5 BAS3B 05.06.09 BROWNT 14,320.00 -120
6 BAS3B 18.06.09 GOODVI 14,320.00 0
7 BAS3B 26.06.09 COLMAN 14,320.00 -15,000.00
8 BAS3B 30.06.09 GREENTsup 14,320.00 3,000.00
9 BAS3B 21.07.09 GREENTsup 14,320.00 5,000.00
10 BAS3B 03.08.09 BEALES 14,320.00 -12
11 BAS3B 05.08.09 ACORN 14,320.00 -6
12 BAS3B 16.08.09 JLEWBS 14,320.00 -120
13 BAS3B 22.08.09 GREENTsup 14,320.00 1,000.00
14 BAS3B 22.08.09 GREENTsup 14,320.00 2,000.00
15 BAS3B 25.08.09 BEALES 14,320.00 -6
16 BAS3B 25.08.09 GREENTsup 14,320.00 2,000.00
17 BAS3B 27.08.09 BEALES 14,320.00 -6
18 BAS3B 27.08.09 ELIZAS 14,320.00 -24
19 BAS3B 01.10.09 GATES 14,320.00 -120
20 BAS3B 15.01.10 GREENTsup 14,320.00 2,000.00
Further to this I need a running total for the stock movement. Basically it nothing but the difference between the last two columns.
Regards
Shiva -
Guidance required for excel processing
Hai
I am new to Excel documents processing in java.I have tried jxl .
Now i hear about jakarta POI.Can you tell which is the best method ?
I will be grateful if you provide me some links to get started.
Thanks in advanceHai
I am new to Excel documents processing in java.I
.I have tried jxl .
Now i hear about jakarta POI.Can you tell which is
s the best method ?
I will be grateful if you provide me some links to
get started.
Thanks in advanceI prefer POI because I have been using it for quite some time and the Quick Start guide is very easy to understand. :) -
A unique requirment for business process
I have recd. a unique requiment for GRs. My clients wants to block selected GRs for parking the invoice. No one should be able to park the invoice against such GRs without permission from authority.
Can we map this procdure???
If Yes then HOW??
Atul KulkarniTry using this BADI : INVOICE_UPDATE ,
You can use the business add-in (INVOICE_UPDATE) to further process the following functions or, if necessary, forbid them:
Creating invoices (invoices, credit memos, subsequent debits, subsequent credits) in Logistics Invoice Verification
Parking documents in Logistics Invoice Verification, and making changes to these documents, for example, deleting them
Regards
Raviraj -
Suggestion required for Rental process
Hello Gurus,
Please suggest a suitable solution for the following scenario:
Client has property like office space and shops.
client gives it on rent, the current process is as follows:
1. Adv in News Papers
2. Selling of tender forms.
3. Accept tenders with refundable deposits.
4. Agreement with highest Quoted.
5. Collect 3 months rent in Advance
6. collect the rent every month.
7. At the end of the period refund the deposit.
Kindly suggest the document types, copy control and periodic billing steps and pricing to be used in SAP SD.
Thanks & RegardsHello lrsapsd
You first need to decide the business processes that you would (can) cover within SAP and which will be out of SAP. Check out SAP for Real Estate Industry Solution, If you can not go that way, here is my proposal:
1. Adv in News Papers: Outside SAP
2. Selling of tender forms: Outside SAP
3. Accept tenders with refundable deposits: Enter them as quotes, You may use AV-Quotation f.Contract or AG-Quotation. Bidders (Renters) will be sold-tos or Prospects and quote will be priced manually with the amount they bid to pay for rent. Deposits may be collected via a Debit Memo and posted to a Temporary Holding Account.
4. Agreement with highest Quoted: Reject all the Bids except the one with highest quote, Convert that quote into Rental Contract (MV) with Periodic Billing Plan. Billing Plan Type- 02; Date Determination Rule- 50.
5. Collect 3 months rent in Advance: Can be managed with Billing Plan and/or down payment.
6. collect the rent every month- Monthly billing of rent using Periodic Billing Plan
7. At the end of the period refund the deposit- Credit Memo Req and Credit Memo, can be automated using contract end date and triggered by workflow with Status control of contract if needed.
Hope this helps. -
Query required for the below result format:
Table(DATA):
Bank_id Device_type Status date Station_status
1011 N Y 3/23/2012 DOWN
1011 N Y 3/23/2012 up
1011 N y 3/23/2012 up
1011 E Y 3/23/2012 down
1011 E I 3/23/2012 down
1011 W Y 3/23/2012 up
1012 N Y 3/23/2012 DOWN
1012 N Y 3/23/2012 up
1012 N y 3/23/2012 up
1012 E Y 3/23/2012 down
1012 E I 3/23/2012 down
1012 W Y 3/23/2012 up
1013 N Y 3/23/2012 DOWN
1013 N Y 3/23/2012 up
1013 N y 3/23/2012 up
1013 E Y 3/23/2012 down
1013 E I 3/23/2012 down
1013 W Y 3/23/2012 up
(SELECT QUERY RESULT SHOULD BE LIKE THIS):Report result:
Bank_id----Date-----TOTAL---UP_STATUS--DOWN_STATUS-----DEVICE
1011 3/23/2012 6 3 3 N<2>N<1>,E<0>E<2>,W<1>W<0>
1012 3/23/2012 6 3 3 N<2>N<1>,E<0>E<2>,W<1>W<0>
1013 3/23/2012 6 3 3 N<2>N<1>,E<0>E<2>,W<1>W<0>
N<2>N<1>,E<0>E<2>,W<1>W<0> this mean(INDICATES)
In N 2 UP 1 DOWN
IN E 0 up 2 down
In W 1 up 0 down
SCRIPTS:
CREATE TABLE FIMS_TEST
BANK_ID VARCHAR2(10 BYTE),
DEVICE_TYPE VARCHAR2(10 BYTE),
STATUS VARCHAR2(1 BYTE),
DATE_TS DATE,
STATION_STATUS VARCHAR2(10 BYTE)
INSERT SCRIPT:
SET DEFINE OFF;
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1011', 'N', 'Y', TO_DATE('03/26/2012 16:30:48', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1011', 'N', 'Y', TO_DATE('03/26/2012 16:32:26', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1011', 'N', 'Y', TO_DATE('03/26/2012 16:32:55', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1011', 'E', 'Y', TO_DATE('03/26/2012 16:33:51', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1011', 'I', 'Y', TO_DATE('03/26/2012 16:34:15', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1011', 'W', 'Y', TO_DATE('03/26/2012 16:34:39', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1012', 'N', 'Y', TO_DATE('03/26/2012 16:35:13', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1012', 'N', 'Y', TO_DATE('03/26/2012 16:35:56', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1012', 'N', 'Y', TO_DATE('03/26/2012 16:36:48', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1012', 'E', 'Y', TO_DATE('03/26/2012 16:37:17', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1012', 'E', 'I', TO_DATE('03/26/2012 16:37:42', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1012', 'W', 'Y', TO_DATE('03/26/2012 16:38:10', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1013', 'N', 'Y', TO_DATE('03/26/2012 16:38:37', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN ');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1013', 'N', 'Y', TO_DATE('03/26/2012 16:39:23', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1013', 'N', 'Y', TO_DATE('03/26/2012 16:39:54', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1013', 'E', 'Y', TO_DATE('03/26/2012 16:40:19', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1013', 'E', 'I', TO_DATE('03/26/2012 16:40:53', 'MM/DD/YYYY HH24:MI:SS'), 'DOWN');
Insert into TEST.FIMS_TEST
(BANK_ID, DEVICE_TYPE, STATUS, DATE_TS, STATION_STATUS)
Values
('1013', 'W', 'Y', TO_DATE('03/26/2012 16:41:17', 'MM/DD/YYYY HH24:MI:SS'), 'UP');
COMMIT;thanks in advance
can any one help me please -
How to deploy and start PHP web services required for a process
hello everyone!
i ve implemented some php web services. One of them is ManagePatientsImpl.php class
and the corresponding ManagePatients.wsdl.
How can deploy it? What are the files required apart from them?
In addition there are some GUI-files. Should these files be deployed together?
Thank you in advance!
Edited by: user643354 on 14-Jul-2010 09:40i'm sorry, i assumed you were running weblogic server.
in case of oc4j you could try this :
http://tugdualgrall.blogspot.com/2005/03/php-on-oc4j-yes-with-jsr-223-ri.html
OC4J communication with PHP -
CREATE TABLE COUNTRIES(CID INT,CNAME VARCHAR(100))
INSERT INTO COUNTRIES VALUES(1,'AUSTRALIA')
INSERT INTO COUNTRIES VALUES(2,'INDIA')
INSERT INTO COUNTRIES VALUES(3,'FRANCE')
INSERT INTO COUNTRIES VALUES(4,'BERLIN')
SELECT * FROM COUNTRIES
o/p
CID CNAME
2 INDIA
1 AUSTRALIA
4 BERLIN
3 FRANCE
here India should be always first position remaining countries values should be in sorted orderYou can use a conditional sorting =>
SELECT *
FROM COUNTRIES
ORDER BY CASE WHEN CNAME = 'INDIA'
THEN 0
ELSE 1 END,
CNAME
Olaf Helper
[ Blog] [ Xing] [ MVP]
Maybe you are looking for
-
Hello All Can someone please help me with the following questions, J 1: I have a CA whose CA certificate has an Issuance (aka certificate) Policy. Next I created a CSR for a WEBServer certificate, I created the CSR by first creating a .inf (request f
-
Is the Samsung 850 EVO not compatible with this MacBook Pro? Has anyone installed it and found it to work fine for a few months? Has anyone faced boot-partition corruptions, problems when installing Yosemite updates with this SSD - on reboot, SSD par
-
Why is Fault Policy working only when the BPEL's transaction is requiresNew
Hi All I've defined Fault policy & fault bindings files for faults in my BPEL process. I'm using Oracle SOA Suite 11g. But the fault management framework is properly working only when the transaction property(bpel.config.transaction) of the BPEL is s
-
App Layer: Capture Cleanup
Current situation: A recored App Layer cannot be managed in any way. Any recorded data, including garbage, will be part of an App Layer. Feature request: Have the possibility to cleanup the App Layers by interacting with the actual captured data. Som
-
Difference in SWI1 in SAP 4.6C and ECC 6.0
Hi All, Could you please tell me the difference in transaction SWI1 in SAP 4.6C and ECC 6.0? Thanks & regards, Nitisha Sanan