Substr issue
I have a column called vehicle desc
which will have this type of info in it:
"2007 light blue Kawasakme Eclipse"
or
"2006 cream Toyotwa Forerunner"
I need to pull this data into three separate columns called YEAR, MAKE, and MODEL.
I can pull out the year with a simple substr, but as you can see the position of the make and model varies.
Luckily there are only about 12 makes, and the model always follows the make.
Any ideas? Do I have to make a long "case" statement or "with" clause?
Here if only the last word in the string is MODEL then you can start cutting the string from end and cut it till first space from end of string.
If MODEL includes the last two words then pick up the first letters of the words after the space from the end using substr, instr.
Similar Messages
-
Hi All,
I've got XSLT issue.
Suppose in XML I have string like that :
world.country.town.Moskow.SomeOtherValue
Capitalized word/s/ is/are/ always at the end.
Using XSLT how to get substring returning capitalized words only i.e Moskow.SomeOtherValue
ThanksHi,
Here are two possible solutions :
1) If you can run XSLT 2.0, then you may use a regular expression :
Sample XML :
<test>world.country.town.Moskow.SomeOtherValue</test>
<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:analyze-string select="test" regex="\.([A-Z].*)$">
<xsl:matching-substring>
<result><xsl:value-of select="regex-group(1)"/></result>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:template>
</xsl:stylesheet>
output :
<result>Moskow.SomeOtherValue</result>2) With XSLT 1.0, you can use a recursive template to analyze the string :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<result>
<xsl:call-template name="find_cap_words">
<xsl:with-param name="in" select="test"/>
</xsl:call-template>
</result>
</xsl:template>
<xsl:template name="find_cap_words">
<xsl:param name="in"/>
<xsl:variable name="rem" select="substring-after($in,'.')"/>
<xsl:choose>
<xsl:when test="translate(substring($rem,1,1),'_ABCDEFGHIJKLMNOPQRSTUVWXYZ','_')=''">
<xsl:value-of select="$rem"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="find_cap_words">
<xsl:with-param name="in" select="$rem"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
output :
<result>Moskow.SomeOtherValue</result>Hope that helps. -
hi, i am learning java in class for school, and in my project i have one issue with the .substring method of strings.
my code is
import java.util.Scanner;
public class Valid
private String lastName;
private String email;
private boolean oneSymbol;
private boolean nonBlankLeft;
private boolean onePeriod;
private boolean nonBlankBoth;
Valid()
public void readData(Scanner input)
lastName = input.next();
email = input.next();
public void checkSymbol()
String s = email.substring(0);
int count = 0;
int x;
x = s.indexOf('@');
while (!(x == -1))
s = s.substring(0,x) = s.substring(x+1);
count++;
x = s.indexOf('@');
if (count == 1)
oneSymbol = true;
else
oneSymbol = false;
public void checkNonBlankLeft()
int x = email.indexOf(" @");
if (x == -1)
nonBlankLeft = true;
else
nonBlankLeft = false;
public void checkOnePeriod()
String s = email.substring(0);
int count = 0;
int x;
x = s.indexOf('.');
while (!(x == -1))
s = s.substring(0,x) = s.substring(x+1);
count++;
x = s.indexOf('.');
if (count >= 1)
onePeriod = true;
else
onePeriod = false;
public void checkNonBlank()
int x = email.indexOf(" . ");
if (x == -1)
nonBlankBoth = true;
else
nonBlankBoth = false;
public void writeResults(java.io.PrintWriter outputValid, java.io.PrintWriter outputInvalid)
if (oneSymbol && nonBlankLeft && onePeriod && nonBlankBoth)
outputValid.printf("%-15s%-30s", lastName, email + "\n");
else
outputInvalid.printf("%-15s%-30s", lastName, email + "\n");
if (oneSymbol == false)
outputInvalid.printf("%45s%-30s", " ", "@ symbol must occur once\n");
if (nonBlankLeft == false)
outputInvalid.printf("%45s%-30s", " ", "Must be a character before the @ symbol\n");
if (onePeriod == false)
outputInvalid.printf("%45s%-30s", " ", "Must contain one . (period)\n");
if (nonBlankBoth == false)
outputInvalid.printf("%45s%-30s", " ", "Both sides of . must be contain a character\n");
} i have issues with both .substring methods and i get these errors.
.\Valid.java:31: unexpected type
required: variable
found : value
s = s.substring(0,x) = s.substring(x+1);
^
.\Valid.java:58: unexpected type
required: variable
found : value
s = s.substring(0,x) = s.substring(x+1);
^
2 errorsgeorgemc wrote:
boulbrokdrm wrote:
thank you, you just showed me that i am a complete idiot lol
i ment to use + instead of =, just forgot to press the shift key i guess, but it should work now, thank youLol, easiest 10 dukes I ever made.If you made them why are they still just sitting there waiting to be awarded?
Hint, hint - OP, YOU NEED TO AWARD THEM -
DBMS_LOB.Substr Issues
Hello everyone,
I'm trying to use dbms_lob.substr on a clob column in one of my tables. I'm searching the table for a particular phrase, which should be the first two words in this column. Any row that has that phrase should be returned. However, when I run the script, I get only rows where the ONLY words in the entire column are the two words. Here's an example
| ID | | Name | | Information |
| 1 | | Jorge | | Terminated for negligence |
| 2 | | Stephanie | | Terminated for ... ? |
I need the script to return both of those rows.
Here's my script:
WHERE
dbms_loc.substr("EMPLOYEE"."COMMENTS", 15, 1)='Terminated for'
Thanks,
JoeNevermind, fixed it by adding a space to the end of the search string.
They really need a delete feature up here. -
I will give a great thanks for help with this. I have a table with a number field called "lotnum". Each rows "lotnum" has a value of 1000, 1001, 1002, 1003....2000, 2001, 2003, ..etc.) The parent row is always the one ending in zero (i.e.: 1000, 2000, 12000, etc....are all the parents). The children all end in 1,2,3,4...etc.. My problem is that another field (let's call it "x_dev") should have a value for not only the parent but also the child, but they do not. I need a query that will help me compare the parent's "x_dev" value with the value of all of the childrens "x_dev" values to determine if they are the same or not.
Sample Data:
Lotnum x_dev
1000 20
1001 Null
1002 Null
2000 20
2001 Null
(i.e: compare 1000 (parent) with the children (1001 & 1002) to determine if the "x_dev" value is the same and if not set it equal to the parent. I know I will have to probably use instr or substr going from right to left since the only constant is that the last three digits represent the children. The remaining digits are the parent (1, 10, 100, 1000), so the value could range from 1000 - 1000000)
Thanks alot
Edited by: kirkladb on Jul 14, 2012 12:09 PMselect t1.lotnum,
t2.lotnum parent_lotnum,
t1.dev_x,
t2.dev_x parent_dev_x
from tbl t1,
tbl t2
where mod(t1.lotnum,1000) != 0
and t2.lotnum = trunc(t1.lotnum / 1000) * 1000
and lnnvl(t2.dev_x = t1.dev_x)
LOTNUM PARENT_LOTNUM DEV_X PARENT_DEV_X
1002 1000 20
1001 1000 20
2001 2000 20
SQL> Or if this will be more readable to you:
select t1.lotnum,
t2.lotnum parent_lotnum,
t1.dev_x,
t2.dev_x parent_dev_x
from tbl t1,
tbl t2
where mod(t1.lotnum,1000) != 0
and t2.lotnum = trunc(t1.lotnum / 1000) * 1000
and (t2.dev_x != t1.dev_x or t1.dev_x is null)
LOTNUM PARENT_LOTNUM DEV_X PARENT_DEV_X
1002 1000 20
1001 1000 20
2001 2000 20
SQL> SY. -
Hi,
I have a string with the following content:
String1
String2
With other words: "\n\n\n\nString1\nString2"
How can I extract String1 & String2 from the whole string?
Thanks in advance!I am sorry I should have made it clear that I am
limited to J2ME as the String is in a MIDlet.
Please advice if there is a way of extracting the
required Strings!
Thank you!I'm in a good mood. Here's a start: public String[] mobileSplit(String text, String delimiterChars) {
String[] array = new String[text.length()];
int found = 0;
StringBuffer buffer = new StringBuffer();
for(int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if(delimiterChars.indexOf(ch) == -1) {
buffer.append(ch);
} else if(buffer.length() > 0) {
array[found++] = buffer.toString();
buffer = new StringBuffer();
if(buffer.length() > 0) {
array[found++] = buffer.toString();
String[] returnArray = new String[found];
for(int i = 0; i < found; i++) {
returnArray[i] = array;
return returnArray;
You can call it like this: String[] array = mobileSplit(
"\n\n\n \n\n\nString1\n String2 \n", // The String to split
"\n "); // Splits the newline- and whitespace character Note: untested code!
Good luck. -
'abcd def$ff>def$nsfdef$'
i have above string and need to replace 'def' with some string but only those occurance where space is not before it ..
output :-
'abcd def$ff>xyz$nsfdef$'select regexp_replace('abcd def$ff>def$nsfdef$','([^ ])(def)','\1XXX') str
from dual;
abcd def$ff>XXX$nsfXXX$And if you need to replace only the first occurance (As your sample output says) use the below
select regexp_replace('abcd def$ff>def$nsfdef$','([^ ])(def)','\1XXX',1,1) str
from dual;
abcd def$ff>XXX$nsfdef$And without using regular expressions
--Assuming "~" will not occur in your string.
select replace(replace(replace('abcd def$ff>def$nsfdef$',' def',' ~~~'),'def','XXX'),'~~~','def') str
from dual;
abcd def$ff>XXX$nsfXXX$ -
Hello,
I have a following query
Select '||' || RW."Description" || ':' || RW."Reason_Code"
from TMTABLE UL, XMLTABLE('//Row' PASSING UL.TEXT
COLUMNS
"Event" CHAR(10) PATH 'Event',
"Reason_Code" PATH 'Reason_Code',
"Description" PATH 'Description'
) AS RW
WHERE
UL.ID = '[Param.1]' and
UL.QUEUENAME = '[Param.2]' and
RW."Event" = '[Param.3]'
which returns me following result set
||A:00052
||B:00053
||C:00054
||D:00055
||E:00056
But I want all these rows to be concatenated like this : A:00052||B:00053||C:00054||D:00055||E:00056
So I had written following query:
Select substr( (Select '||' || RW."Description" || ':' || RW."Reason_Code"
from TMTABLEUL, XMLTABLE('//Row' PASSING UL.TEXT
COLUMNS
"Event" CHAR(10) PATH 'Event',
"Reason_Code" PATH 'Reason_Code',
"Description" PATH 'Description'
) AS RW
WHERE
UL.ID = '[Param.1]' and
UL.QUEUENAME = '[Param.2]' and
RW."Event" = '[Param.3]' ) , 3 , 2000 ) from Dual
But it gives this error: java.sql.SQLException: ORA-01427: single-row subquery returns more than one row
what should I do to achieve desired result?Russ,
Thanks for having a look, I think we've got a bit confused. 'Max char fetched' is the item property, you can see in Admin - Disco reserves this space for the column whilst running the query .
Yes, unfortunately we are having to substr all function calls in DB views as Disco defaults to 2000/4000 chars for these items - have a look at some of the standard BIS BAs or see Metalink Note:270273.1 for info. This we can live with and its fixed in 10g...(uuughhh I hate 4i after having done a few 10g implementations). Then we'll remove them after upgrade to help the CPU cause, but it could be many months away.
The current problem that I'm finding strange, is the tripling issue. If a DB view has and item say SUBSTR(emps.employee_longname,1,150) - no function calls involved, this then appears in the folder with the item property 'Max char fetched' as 450 - I would have thought that this should be 150.
In all the years of working with Disco, I never noticed this behaviour before - though I have never looked at it before. I thought I'd give the forum a try b4 raising a SR to see if somebody has encountered this.
thanks,
matt -
Substring instr issue in obiee
Hi,
I want to use the INSTR function in OBIEE
POSITION function found in the forum
INSTR function takes four values:
INSTR (string1, string2, number, number)
Eg IP address
111.222.333.444
The desired result
SUBSTR (IP_ADD, 1, INSTR (IP_ADD, '.', 1,3) -1)
111.222.333
POSITION function, how should I use?
Thanks,
Mino1st example '0.0.0.0' will def be a problem here. Unfortunately, I don't think any other OBIEE string function could support this.
I was assuming for min 2 numbers like 00.00.00.00. Do you have any case like the first one in your table ?
=========
As I said, you can't use POSITION function here..Just do help for String Function in RPD)
Position
Returns the numerical position of the character_expression1 in a character expression. If the character_expression1 is not found, the function returns 0.
Syntax:
POSITION(character_expression1 IN character_expression2)
where:
character_expression1
Any expression that evaluates to a character string. Used to search in the second string.
character_expression2
Any expression that evaluates to a character string.
So, these are the 2 expression, In your case its '.' & IP_ADDR.
=========
Hope its helpful -
@SUBSTRING function issue
Hi,
I try to put a formula on a member in Hyperion Planning :
*@MEMBER(@SUBSTRING(@NAME(@CURRMBR(Measures)),0,5)) -> @MEMBER(@SUBSTRING(@NAME(@CURRMBR(Measures)),7));*
For example, on the member "205000_DIM", this formula has to return the data on "205000"->"DIM".
But I've got an error message in Essbase : +Error executing formula for [205000_DIM] (line 1): attempt to cross a null member in function [@X]+
When I put "205000"->@MEMBER(@SUBSTRING(@NAME(@CURRMBR(Measures)),7)); => it works !!!!
I do not understand...
Please help !
Thanks a lot.
Virgile.Oups !
I'm dreaming... I thought I tried that...
In Oracle Techical Reference documentation, they say 0 is the first character... So, for me, the sixth character corresponds to 5 in the formula...
But I guess I'm wrong.
Thank you !!
Virgile. -
Instr and substr function in oracle issues
hi all
I have an issue to split my filename
Filename is as below:
ABCD01_123456789_samplename_13062012_10062012-12-12-12-1.PDF
my output as below
Col1 Col2 col3 col4 col5 col6
ABCD01 123456789 samplename 13062012 10062012 10062012-12-12-12-1.PDFcan you please help me to split this using any simple method
thanks ain advance
Edited by: A on Jun 12, 2012 8:25 PM
Edited by: A on Jun 12, 2012 8:25 PM>
can you please help me to split this using any simple method
>
You can split the string into rows using the same technique used in this example
http://nuijten.blogspot.com/2009/07/splitting-comma-delimited-string-regexp.html
Just replace the ',' with an underscore.
Then you can convert the rows to columns using LISTAGG like this example
http://www.oracle-base.com/articles/misc/string-aggregation-techniques.php
Search the forum for 'rows to columns' and you will find plenty of other alternatives. -
Issue for using replace or substring function in OBIEE for Essbase.
Hello,
We are Getting data from essbase cubes. I am trying to take out a part of characters from a data in a column. When i was trying to you replace function directly in a report, if i use the logic for only that column its work well. But when i was trying to add metric column to that report then i am getting this error.
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred.
[nQSError: 42043] An external aggregate is found in an outer query block. (HY000)
SQL Issued: SELECT REPLACE("CLIN OIC"."Gen2,CLIN OIC", '_CLIN_OIC', ' ') saw_0, Revenue."Job Profit" saw_1 FROM RADAR ORDER BY saw_0
Kindly help me to fix this issue and share you suggestions.Hello,
We are Getting data from essbase cubes. I am trying to take out a part of characters from a data in a column. When i was trying to you replace function directly in a report, if i use the logic for only that column its work well. But when i was trying to add metric column to that report then i am getting this error.
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred.
[nQSError: 42043] An external aggregate is found in an outer query block. (HY000)
SQL Issued: SELECT REPLACE("CLIN OIC"."Gen2,CLIN OIC", '_CLIN_OIC', ' ') saw_0, Revenue."Job Profit" saw_1 FROM RADAR ORDER BY saw_0
Kindly help me to fix this issue and share you suggestions. -
Issue in Conversion of String to XML (xsd) elements.
Hi All,
Please help in resolving the below issue.Please help me ASAP
I am getting a strng value from Db adapter String= Mike,3453,USA
I need to convert the data into xml by using below xsd.
<?xml version="1.0" encoding='UTF-8' ?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.uss.com/htr/IHCM204/MainRec"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
xmlns:tns="http://www.uss.com/htr/IHCM204/MainRec"
attributeFormDefault="unqualified" nxsd:version="NXSD"
nxsd:stream="chars" nxsd:encoding="US-ASCII">
<element name="MainOutput">
<complexType>
<sequence>
<element name="Target" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="name" type="string" nxsd:style="terminated" nxsd:terminatedBy="," />
<element name="sal" type="string" nxsd:style="terminated" nxsd:terminatedBy="," />
<element name="add" type="string" nxsd:style="terminated" nxsd:terminatedBy="," />
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
Regards,
AnaSay, for Example
If you are getting response from db adapter as abc,def,ghi then use an transform activity to split the string.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
<xsl:template match="/">
<ns:StringParsing>
<ns:Name>
<xsl:value-of select='substring(/ns:simpleelement/ns:dbString,1.0, oraext:last-index-within-string(/ns:simpleelement/ns:dbString,",") + 0.0)'/>
</ns:Name>
<ns:Address>
<xsl:value-of select='substring(/ns:simpleelement/ns:dbString,oraext:last-index-within-string(/ns:simpleelement/ns:dbString,",") + 2.0)'/>
</ns:Address>
</ns:StringParsing>
</xsl:template>
</xsl:stylesheet>
Let me know if it helps you.
Edited by: BK574 on May 14, 2013 11:31 AM
Edited by: BK574 on May 14, 2013 11:55 AM
Edited by: BK574 on May 14, 2013 12:48 PM -
Hi Gurus,
I am dier need of one of the xml issue which I am facing right now.
I am reading one of the xml file which is like this
<?xml version="1.0" encoding="UTF-8" ?>
- <GEBIZ_ORDER xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <HEADER>
<MINISTRY_CODE>RPO</MINISTRY_CODE>
<DEPARTMENT_CODE>000</DEPARTMENT_CODE>
<ORDER_CODE>RPO000EPO11000953</ORDER_CODE>
<EXTERNAL_SYSTEM_CODE>E</EXTERNAL_SYSTEM_CODE>
<AMENDMENT_NUMBER>0</AMENDMENT_NUMBER>
<VARIATION_NUMBER>0</VARIATION_NUMBER>
<DESCRIPTION>Purchase Order for Air tickets for SOT to Korea (from 17th - 26th Sep 2011) off PC(RPO000ECN11000100)for SAS</DESCRIPTION>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<PAYMENT_TERMS xsi:nil="true" />
<BILL_TO>One-Stop Centre, 9 Woodlands Avenue 9, S(738964)</BILL_TO>
<JUSTIFICATION>Please refer to attached approval email.</JUSTIFICATION>
<CREATE_TIMESTAMP>2011-07-08T16:57:39</CREATE_TIMESTAMP>
<TERMINATE_REASON xsi:nil="true" />
<TERMINATE_TIMESTAMP xsi:nil="true" />
<ORDER_TYPE>1</ORDER_TYPE>
- <FINANCIAL_SYSTEM>
<SUB_BUSINESS_UNIT>RPS01</SUB_BUSINESS_UNIT>
</FINANCIAL_SYSTEM>
- <SUPPLIER>
<CODE>200003048E</CODE>
<NAME>Safe2Travel Pte Ltd</NAME>
<GST_NUMBER>20-0003048-E</GST_NUMBER>
<CONTACT_NAME>ONG PEI LENG</CONTACT_NAME>
<CONTACT_PHONE>68233103</CONTACT_PHONE>
<CONTACT_EMAIL>[email protected]</CONTACT_EMAIL>
<CONTACT_FAX>68221636</CONTACT_FAX>
- <SITES>
- <SITE>
<ID>1</ID>
<NAME>ravel Pte Ltd</NAME>
<PHONE>68233013</PHONE>
<PHONE_EXTENSION xsi:nil="true" />
<FAX>68221636</FAX>
<EMAIL>[email protected]</EMAIL>
<ADDRESS_LINE1>10 Eunos Road 8</ADDRESS_LINE1>
<ADDRESS_LINE2>#08-03 (North Lobby)</ADDRESS_LINE2>
<ADDRESS_LINE3>Singapore Post Centre</ADDRESS_LINE3>
<COUNTRY_CODE>SG</COUNTRY_CODE>
<PROVINCE xsi:nil="true" />
<STATE xsi:nil="true" />
<CITY xsi:nil="true" />
<AREA_CODE xsi:nil="true" />
<ZIP>408600</ZIP>
<REGION_CODE xsi:nil="true" />
</SITE>
- <SITE>
<ID>2</ID>
<NAME>ravel Pte Ltd</NAME>
<PHONE>62208866</PHONE>
<PHONE_EXTENSION xsi:nil="true" />
<FAX>62265578</FAX>
<EMAIL>[email protected]</EMAIL>
<ADDRESS_LINE1>3 Lim Teck Kim Road</ADDRESS_LINE1>
<ADDRESS_LINE2>#02-02</ADDRESS_LINE2>
<ADDRESS_LINE3>Singapore Technologies Building</ADDRESS_LINE3>
<COUNTRY_CODE>SG</COUNTRY_CODE>
<PROVINCE xsi:nil="true" />
<STATE xsi:nil="true" />
<CITY xsi:nil="true" />
<AREA_CODE xsi:nil="true" />
<ZIP>088934</ZIP>
<REGION_CODE xsi:nil="true" />
</SITE>
- <SITE>
<ID>3</ID>
<NAME>Safe2Travel Pte Ltd</NAME>
<PHONE>62208866</PHONE>
<PHONE_EXTENSION xsi:nil="true" />
<FAX>62265578</FAX>
<EMAIL>[email protected]</EMAIL>
<ADDRESS_LINE1>3 Lim Teck Kim Road</ADDRESS_LINE1>
<ADDRESS_LINE2>#02-02</ADDRESS_LINE2>
<ADDRESS_LINE3>Singapore Technologies Building</ADDRESS_LINE3>
<COUNTRY_CODE>SG</COUNTRY_CODE>
<PROVINCE xsi:nil="true" />
<STATE xsi:nil="true" />
<CITY xsi:nil="true" />
<AREA_CODE xsi:nil="true" />
<ZIP>088934</ZIP>
<REGION_CODE xsi:nil="true" />
</SITE>
</SITES>
</SUPPLIER>
- <USER>
<CODE>JOYCE SOON</CODE>
<NAME>JOYCE SOON</NAME>
<ORGANISATION_NAME>Republic Polytechnic</ORGANISATION_NAME>
</USER>
- <FUND_COMMIT_AMOUNT>
<CURRENCY_CODE>SGD</CURRENCY_CODE>
<CURRENCY_RATE>1</CURRENCY_RATE>
<CURRENCY_RATE_DATE>1900-01-01T00:00:00</CURRENCY_RATE_DATE>
<CURRENCY_RATE_TYPE>BOOK</CURRENCY_RATE_TYPE>
<CURRENCY_AMOUNT>21551.4</CURRENCY_AMOUNT>
</FUND_COMMIT_AMOUNT>
- <PERIOD_CONTRACT>
<CODE>RPO000ECN11000100</CODE>
<AGENCY_CODE>RPO000</AGENCY_CODE>
<ADMIN_FEE_SGD_AMOUNT>0</ADMIN_FEE_SGD_AMOUNT>
</PERIOD_CONTRACT>
- <BUYER>
<ORGANISATION_CODE>1</ORGANISATION_CODE>
<ORGANISATION_NAME>Republic Polytechnic</ORGANISATION_NAME>
<NAME>Sally Ang</NAME>
<PHONE>31001711</PHONE>
<FAX>64151310</FAX>
<EMAIL>[email protected]</EMAIL>
</BUYER>
<APPROVING_OFFICERS />
</HEADER>
- <ITEMS>
- <ITEM>
<LINE_NUMBER>1</LINE_NUMBER>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<DESCRIPTION>Return Air Ticket including Airport Taxes and Fuel Surcharges (2 staff and 24 students)</DESCRIPTION>
<UNIT_OF_MEASURE>PAX</UNIT_OF_MEASURE>
<QUANTITY>26</QUANTITY>
<LINE_TYPE>SERVICES</LINE_TYPE>
<UNIT_PRICE>828.9</UNIT_PRICE>
<PRICE_UNIT>1</PRICE_UNIT>
<TOTAL_AMOUNT>21551.4</TOTAL_AMOUNT>
<MATERIAL_MASTER_CODE xsi:nil="true" />
<MATERIAL_GROUP_CODE xsi:nil="true" />
<PLANT_CODE xsi:nil="true" />
<ITEM_CATEGORY_CODE xsi:nil="true" />
<ADMIN_FEE_SGD_AMOUNT>0</ADMIN_FEE_SGD_AMOUNT>
<INSTRUCTION_TO_SUPPLIER>Purchase of goods/services is subject to the Terms & Conditions found in www.rp.sg/purchase and/or in the ITQ/ITT Specifications. Please liaise with the Contact Person for delivery details. Invoice MUST be addressed to the Contact Person. PO number MUST be included in the Description field under e-Invoice Details section at Vendor@Gov.</INSTRUCTION_TO_SUPPLIER>
<PERIOD_CONTRACT_LINE_NUMBER>1</PERIOD_CONTRACT_LINE_NUMBER>
<GOODS_INSPECT_FLAG>N</GOODS_INSPECT_FLAG>
- <PURCHASE_REQUEST>
<CODE>RPO000EPR11000465</CODE>
<LINE_NUMBER>1</LINE_NUMBER>
</PURCHASE_REQUEST>
- <PART_NUMBER_INFORMATION>
<NATO_STOCK_NUMBER xsi:nil="true" />
<MANUFACTURER_PART_NUMBER xsi:nil="true" />
<PART_NUMBER xsi:nil="true" />
<CAGE_CODE xsi:nil="true" />
<CAGE_NAME xsi:nil="true" />
<ITEM_CONDITION xsi:nil="true" />
<MINIMUM_SHELF_LIFE xsi:nil="true" />
<SHELF_LIFE_REMAINING xsi:nil="true" />
<CERTIFICATE_OF_CONFORMANCE xsi:nil="true" />
<EXPORT_LICENSE xsi:nil="true" />
</PART_NUMBER_INFORMATION>
- <LOCATIONS>
- <LOCATION>
<LINE_NUMBER>1</LINE_NUMBER>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<QUANTITY>26</QUANTITY>
<DELIVERY_DESTINATION>Republic Polytechnic, One-Stop Centre, 9 Woodlands Avenue 9, S(738964)</DELIVERY_DESTINATION>
<DELIVERY_DATE>2011-07-11T00:00:00</DELIVERY_DATE>
<DELIVERY_TERMS>LOC</DELIVERY_TERMS>
<PORT_OF_ORIGIN>-</PORT_OF_ORIGIN>
- <RECIPIENT>
<CODE>OSC</CODE>
<NAME>One Stop Centre</NAME>
<PHONE>65103000</PHONE>
<EMAIL>[email protected]</EMAIL>
</RECIPIENT>
- <DISTRIBUTIONS>
- <DISTRIBUTION>
<LINE_NUMBER>1</LINE_NUMBER>
<STATUS>NEW</STATUS>
<STATUS_DATE>2011-07-08T16:57:39</STATUS_DATE>
<QUANTITY>26</QUANTITY>
<CHART_OF_ACCOUNT>1/G01/3SAS/020/220908/0000/0000/0000</CHART_OF_ACCOUNT>
<PROJECT_DISTRIBUTION xsi:nil="true" />
</DISTRIBUTION>
</DISTRIBUTIONS>
</LOCATION>
</LOCATIONS>
</ITEM>
</ITEMS>
</GEBIZ_ORDER>I was able to read this kind of file structure but due to some constraints now they added supplier sites and increment that one which will be like variable kind of thing now.
And below mentioned is the script which I am using right now for reading that xml file
PROCEDURE XGBZPROD.XGBZ_PUR_ORD_XMLTAG_PROC(P_XML_FILE IN VARCHAR2, P_FOLDER_NAME IN VARCHAR2)
IS
lv_supp_file XMLTYPE;
lv_hdr_error VARCHAR2(240);
lv_line_error VARCHAR2(240);
lv_line_loc_err VARCHAR2(240);
lv_dist_err VARCHAR2(240);
l_file_name VARCHAR2(300);
l_folder_name VARCHAR2(300);
lv_sysdate DATE := sysdate;
BEGIN
l_file_name := p_xml_file;
l_folder_name := p_folder_name;
-- this clause to check whether is xml file or NODATA FILE.
IF upper(substr(l_file_name,instr(l_file_name,'.',1)+1,3)) ='XML' THEN
lv_supp_file := xmltype( bfilename('XMLDIR',P_XML_FILE), nls_charset_id('AL32UTF8'));
dbms_output.put_line('P_XML_FILE '||P_XML_FILE);
-- Initially insert data into 11g table
-- This is to read xml datafile
INSERT INTO XGBZ_PO_XML_DETAILS
(ministry_code ,
department_code ,
order_code ,
external_system_code ,
amendment_number ,
variation_number ,
description ,
status ,
status_date ,
payment_terms ,
bill_to ,
justification ,
create_timestamp ,
terminate_reason ,
terminate_timestamp ,
order_type ,
sub_business_unit ,
cost_center_group ,
buyer_code ,
financial_system_order_code ,
user_nric ,
supplier_code ,
supplier_name ,
gst_number ,
contact_name ,
contact_phone ,
contact_email ,
contact_fax ,
supp_site_id ,
supp_site_name ,
supp_site_phone ,
supp_sit_phone_ext ,
supp_site_fax ,
supp_site_email ,
supp_site_add_line1 ,
supp_site_add_line2 ,
supp_site_add_line3 ,
supp_site_country_code ,
supp_site_province ,
supp_site_state ,
supp_site_city ,
supp_site_area_code ,
supp_site_zip ,
supp_site_region_code ,
user_code ,
user_name ,
user_org_name ,
currency_code ,
currency_rate ,
currency_rate_date ,
currency_rate_type ,
currency_amount ,
tx_field_2 ,
agency_code ,
admin_fee_sgd ,
buyer_orgn_code ,
buyer_orgn_name ,
buyer_name ,
buyer_phone ,
buyer_fax ,
buyer_email ,
ao_code ,
ao_name ,
line_no ,
line_status ,
line_status_date ,
line_description ,
unit_of_measure ,
line_qty ,
line_type ,
unit_price ,
line_total_amount ,
material_master_code ,
material_group_code ,
item_category_code ,
line_admin_fee_sgd_amt ,
instruction_supplier ,
period_contract_line_no ,
goods_inspect_flag ,
pr_code ,
pr_line_number ,
nato_stock_number ,
manufacturer_part_no ,
part_number ,
cage_code ,
cage_name ,
item_condition ,
minimum_shelf_life ,
shelf_life_remaining ,
cert_of_conformance ,
export_license ,
line_location_no ,
line_loc_status ,
line_loc_status_date ,
line_loc_qty ,
delivery_destination ,
delivery_date ,
delivery_terms ,
port_of_origin ,
recipient_code ,
recipient_name ,
recipient_phone ,
recipient_email ,
dist_line_no ,
dist_line_status ,
dist_line_status_date ,
dist_line_qty ,
chart_of_account ,
project_distribution
SELECT --Header Data
ministry_code ,
department_code ,
order_code ,
external_system_code ,
amendment_number ,
variation_number ,
description ,
status ,
status_date ,
payment_terms ,
bill_to ,
justification ,
create_timestamp ,
terminate_reason ,
terminate_timestamp ,
order_type ,
sub_business_unit ,
cost_center_group ,
buyer_code ,
financial_system_order_code ,
user_nric ,
supplier_code ,
supplier_name ,
gst_number ,
contact_name ,
contact_phone ,
contact_email ,
contact_fax ,
supp_site_id ,
supp_site_name ,
supp_site_phone ,
supp_sit_phone_ext ,
supp_site_fax ,
supp_site_email ,
supp_site_add_line1 ,
supp_site_add_line2 ,
supp_site_add_line3 ,
supp_site_country_code ,
supp_site_province ,
supp_site_state ,
supp_site_city ,
supp_site_area_code ,
supp_site_zip ,
supp_site_region_code ,
user_code ,
user_name ,
user_org_name ,
currency_code ,
currency_rate ,
currency_rate_date ,
currency_rate_type ,
currency_amount ,
tx_field_2 ,
agency_code ,
admin_fee_sgd ,
buyer_orgn_code ,
buyer_orgn_name ,
buyer_name ,
buyer_phone ,
buyer_fax ,
buyer_email ,
ao_code ,
ao_name ,
line_no ,
line_status ,
line_status_date ,
line_description ,
unit_of_measure ,
line_qty ,
line_type ,
unit_price ,
line_total_amount ,
material_master_code ,
material_group_code ,
item_category_code ,
line_admin_fee_sgd_amt ,
instruction_supplier ,
period_contract_line_no ,
goods_inspect_flag ,
pr_code ,
pr_line_number ,
nato_stock_number ,
manufacturer_part_no ,
part_number ,
cage_code ,
cage_name ,
item_condition ,
minimum_shelf_life ,
shelf_life_remaining ,
cert_of_conformance ,
export_license ,
line_location_no ,
line_loc_status ,
line_loc_status_date ,
line_loc_qty ,
delivery_destination ,
delivery_date ,
delivery_terms ,
port_of_origin ,
recipient_code ,
recipient_name ,
recipient_phone ,
recipient_email ,
dist_line_no ,
dist_line_status ,
dist_line_status_date ,
dist_line_qty ,
chart_of_account ,
project_distribution
FROM XMLTable('/GEBIZ_ORDER'
passing lv_supp_file
columns
ministry_code VARCHAR2(3) path 'HEADER/MINISTRY_CODE',
department_code VARCHAR2(3) path 'HEADER/DEPARTMENT_CODE',
order_code VARCHAR2(17 ) path 'HEADER/ORDER_CODE',
external_system_code VARCHAR2(1) path 'HEADER/EXTERNAL_SYSTEM_CODE',
amendment_number VARCHAR2(5) path 'HEADER/AMENDMENT_NUMBER' ,
variation_number VARCHAR2(5) path 'HEADER/VARIATION_NUMBER',
description VARCHAR2(500) path 'HEADER/DESCRIPTION',
status VARCHAR2(500) path 'HEADER/STATUS',
status_date VARCHAR2(24) path 'HEADER/STATUS_DATE',
payment_terms VARCHAR2(400) path 'HEADER/PAYMENT_TERMS',
bill_to VARCHAR2(200) path 'HEADER/BILL_TO',
justification VARCHAR2(400) path 'HEADER/JUSTIFICATION',
create_timestamp VARCHAR2(24) path 'HEADER/CREATE_TIMESTAMP',
terminate_reason VARCHAR2(400) path 'HEADER/TERMINATE_REASON',
terminate_timestamp VARCHAR2(24) path 'HEADER/TERMINATE_TIMESTAMP',
order_type VARCHAR2(2 ) path 'HEADER/ORDER_TYPE',
sub_business_unit VARCHAR2(5 ) path 'HEADER/FINANCIAL_SYSTEM/SUB_BUSINESS_UNIT',
cost_center_group VARCHAR2(20 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/COST_CENTER_GROUP',
buyer_code VARCHAR2(30 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/BUYER_CODE',
financial_system_order_code VARCHAR2(20 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/FINANCIAL_SYSTEM_ORDER_CODE',
user_nric VARCHAR2(9 ) path 'HEADER/FINANCIAL_SYSTEM/NFS/USER_NRIC',
supplier_code VARCHAR2(10) path 'HEADER/SUPPLIER/CODE',
supplier_name VARCHAR2(140) path 'HEADER/SUPPLIER/NAME' ,
gst_number VARCHAR2(30 ) path 'HEADER/SUPPLIER/GST_NUMBER',
contact_name VARCHAR2(140 ) path 'HEADER/SUPPLIER/CONTACT_NAME',
contact_phone VARCHAR2(23 ) path 'HEADER/SUPPLIER/CONTACT_PHONE',
contact_email VARCHAR2(100) path 'HEADER/SUPPLIER/CONTACT_EMAIL',
contact_fax VARCHAR2(23 ) path 'HEADER/SUPPLIER/CONTACT_FAX',
supp_site_id NUMBER path 'HEADER/SUPPLIER/SITES/SITE/ID',
supp_site_name VARCHAR2(140) path 'HEADER/SUPPLIER/SITES/SITE/NAME',
supp_site_phone VARCHAR2(23) path 'HEADER/SUPPLIER/SITES/SITE/PHONE',
supp_sit_phone_ext VARCHAR2(4 ) path 'HEADER/SUPPLIER/SITES/SITE/PHONE_EXTENSION',
supp_site_fax VARCHAR2(23 ) path 'HEADER/SUPPLIER/SITES/SITE/FAX',
supp_site_email VARCHAR2(100 ) path 'HEADER/SUPPLIER/SITES/SITE/EMAIL',
supp_site_add_line1 VARCHAR2(254 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE1',
supp_site_add_line2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE2',
supp_site_add_line3 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE3',
supp_site_country_code VARCHAR2(2 ) path 'HEADER/SUPPLIER/SITES/SITE/COUNTRY_CODE',
supp_site_province VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/PROVINCE',
supp_site_state VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/STATE',
supp_site_city VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/CITY',
supp_site_area_code VARCHAR2(10 ) path 'HEADER/SUPPLIER/SITES/SITE/AREA_CODE',
supp_site_zip VARCHAR2(20 ) path 'HEADER/SUPPLIER/SITES/SITE/ZIP',
supp_site_region_code VARCHAR2(3 ) path 'HEADER/SUPPLIER/SITES/SITE/REGION_CODE',
user_code VARCHAR2(16 ) path 'HEADER/USER/CODE',
user_name VARCHAR2(25 ) path 'HEADER/USER/NAME',
user_org_name VARCHAR2(95 ) path 'HEADER/USER/ORGANISATION_NAME',
currency_code VARCHAR2(3 ) path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_CODE',
currency_rate NUMBER path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_RATE',
currency_rate_date VARCHAR2(24) path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_RATE_DATE',
currency_rate_type VARCHAR2(5 ) path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_RATE_TYPE',
currency_amount NUMBER path 'HEADER/FUND_COMMIT_AMOUNT/CURRENCY_AMOUNT',
tx_field_2 VARCHAR2(17 ) path 'HEADER/PERIOD_CONTRACT/CODE',
agency_code VARCHAR2(6 ) path 'HEADER/PERIOD_CONTRACT/AGENCY_CODE',
admin_fee_sgd NUMBER path 'HEADER/PERIOD_CONTRACT/ADMIN_FEE_SGD_AMOUNT' ,
buyer_orgn_code VARCHAR2(5 ) path 'HEADER/BUYER/ORGANISATION_CODE',
buyer_orgn_name VARCHAR2(95 ) path 'HEADER/BUYER/ORGANISATION_NAME',
buyer_name VARCHAR2(80 ) path 'HEADER/BUYER/NAME',
buyer_phone VARCHAR2(23 ) path 'HEADER/BUYER/PHONE',
buyer_fax VARCHAR2(23 ) path 'HEADER/BUYER/FAX',
buyer_email VARCHAR2(100 ) path 'HEADER/BUYER/EMAIL',
ao_code VARCHAR2(16 ) path 'HEADER/APPROVING_OFFICERS/APPROVING_OFFICER/CODE',
ao_name VARCHAR2(40 ) path 'HEADER/APPROVING_OFFICERS/APPROVING_OFFICER/NAME',
items XMLTYPE path 'ITEMS'
) x1,
XMLTABLE('/ITEMS/ITEM'
passing x1.items
columns
line_no VARCHAR2(5) path 'LINE_NUMBER',
line_status VARCHAR2(15) path 'STATUS',
line_status_date VARCHAR2(24) path 'STATUS_DATE',
line_description VARCHAR2(500) path 'DESCRIPTION',
unit_of_measure VARCHAR2(3) path 'UNIT_OF_MEASURE',
line_qty NUMBER path 'QUANTITY',
line_type VARCHAR2(20) path 'LINE_TYPE',
unit_price NUMBER path 'UNIT_PRICE',
line_total_amount NUMBER path 'TOTAL_AMOUNT',
material_master_code VARCHAR2(20) path 'MATERIAL_MASTER_CODE',
material_group_code VARCHAR2(10) path 'MATERIAL_GROUP_CODE',
item_category_code VARCHAR2(18) path 'ITEM_CATEGORY_CODE',
line_admin_fee_sgd_amt NUMBER path 'ADMIN_FEE_SGD_AMOUNT',
instruction_supplier VARCHAR2(400) path 'INSTRUCTION_TO_SUPPLIER',
period_contract_line_no NUMBER path 'PERIOD_CONTRACT_LINE_NUMBER',
goods_inspect_flag VARCHAR2(1) path 'GOODS_INSPECT_FLAG',
pr_code VARCHAR2(17) path 'PURCHASE_REQUEST/CODE',
pr_line_number VARCHAR2(5) path 'PURCHASE_REQUEST/LINE_NUMBER',
nato_stock_number VARCHAR2(14) path 'PART_NUMBER_INFORMATION/NATO_STOCK_NUMBER',
manufacturer_part_no VARCHAR2(32) path 'PART_NUMBER_INFORMATION/MANUFACTURE_PART_NUMBER',
part_number VARCHAR2(200) path 'PART_NUMBER_INFORMATION/PART_NUMBER',
cage_code VARCHAR2(10) path 'PART_NUMBER_INFORMATION/CAGE_CODE',
cage_name VARCHAR2(140) path 'PART_NUMBER_INFORMATION/CAGE_NAME',
item_condition VARCHAR2(1) path 'PART_NUMBER_INFORMATION/ITEM_CONDITION' ,
minimum_shelf_life NUMBER path 'PART_NUMBER_INFORMATION/MINIMUM_SHELF_LIFE',
shelf_life_remaining VARCHAR2(3) path 'PART_NUMBER_INFORMATION/SHELF_LIFE_REMAINING',
cert_of_conformance VARCHAR2(1000) path 'PART_NUMBER_INFORMATION/CERTIFICATE_OF_CONFORMANCE',
export_license VARCHAR2(3) path 'PART_NUMBER_INFORMATION/EXPORT_LICENSE',
locations XMLTYPE path 'LOCATIONS'
)x2,
XMLTABLE('/LOCATIONS/LOCATION'
passing x2.locations
columns
line_location_no NUMBER path 'LINE_NUMBER',
line_loc_status VARCHAR2(15) path 'STATUS',
line_loc_status_date VARCHAR2(24) path 'STATUS_DATE',
line_loc_qty NUMBER path 'QUANTITY',
delivery_destination VARCHAR2(1000) path 'DELIVERY_DESTINATION',
delivery_date VARCHAR2(24) path 'DELIVERY_DATE',
delivery_terms VARCHAR2(3) path 'DELIVERY_TERMS',
port_of_origin VARCHAR2(150) path 'PORT_OF_ORIGIN',
recipient_code VARCHAR2(16 ) path 'RECIPIENT/CODE',
recipient_name VARCHAR2(40 ) path 'RECIPIENT/NAME',
recipient_phone VARCHAR2(23 ) path 'RECIPIENT/PHONE',
recipient_email VARCHAR2(100 ) path 'RECIPIENT/EMAIL',
distributions XMLTYPE path 'DISTRIBUTIONS'
)x3,
XMLTABLE('/DISTRIBUTIONS/DISTRIBUTION'
passing x3.distributions
columns
dist_line_no NUMBER path 'LINE_NUMBER',
dist_line_status VARCHAR2(15) path 'STATUS',
dist_line_status_date VARCHAR2(24) path 'STATUS_DATE',
dist_line_qty NUMBER path 'QUANTITY',
chart_of_account VARCHAR2(420) path 'CHART_OF_ACCOUNT',
project_distribution VARCHAR2(4000) path 'PROJECT_DISTRIBUTION'
)x4;
end;As there is change in requirement now I need to read the multiple supplier sites at the header level. Current this is my structure please give an idea how to read the mulitple sites as one record, probably i can increase the supplier site columns at table level so as to capture second site level information.
But if in case if i receive that time it should not fail please provide some good solution for this issue.
Thanks in advance for your help.
Regards
NagendraHi odie,
Thanks for your response. But here my supplier site will always be maxiumum 2 times and minimum 1 time. My thinking is to fit this one in the existing code by repeating the supplier site only like this
supp_site_id NUMBER path 'HEADER/SUPPLIER/SITES/SITE/ID',
supp_site_name VARCHAR2(140) path 'HEADER/SUPPLIER/SITES/SITE/NAME',
supp_site_phone VARCHAR2(23) path 'HEADER/SUPPLIER/SITES/SITE/PHONE',
supp_sit_phone_ext VARCHAR2(4 ) path 'HEADER/SUPPLIER/SITES/SITE/PHONE_EXTENSION',
supp_site_fax VARCHAR2(23 ) path 'HEADER/SUPPLIER/SITES/SITE/FAX',
supp_site_email VARCHAR2(100 ) path 'HEADER/SUPPLIER/SITES/SITE/EMAIL',
supp_site_add_line1 VARCHAR2(254 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE1',
supp_site_add_line2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE2',
supp_site_add_line3 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE3',
supp_site_country_code VARCHAR2(2 ) path 'HEADER/SUPPLIER/SITES/SITE/COUNTRY_CODE',
supp_site_province VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/PROVINCE',
supp_site_state VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/STATE',
supp_site_city VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/CITY',
supp_site_area_code VARCHAR2(10 ) path 'HEADER/SUPPLIER/SITES/SITE/AREA_CODE',
supp_site_zip VARCHAR2(20 ) path 'HEADER/SUPPLIER/SITES/SITE/ZIP',
supp_site_region_code VARCHAR2(3 ) path 'HEADER/SUPPLIER/SITES/SITE/REGION_CODE',
supp_site_id2 NUMBER path 'HEADER/SUPPLIER/SITES/SITE/ID',
supp_site_name2 VARCHAR2(140) path 'HEADER/SUPPLIER/SITES/SITE/NAME',
supp_site_phone2 VARCHAR2(23) path 'HEADER/SUPPLIER/SITES/SITE/PHONE',
supp_sit_phone_ext2 VARCHAR2(4 ) path 'HEADER/SUPPLIER/SITES/SITE/PHONE_EXTENSION',
supp_site_fax2 VARCHAR2(23 ) path 'HEADER/SUPPLIER/SITES/SITE/FAX',
supp_site_email2 VARCHAR2(100 ) path 'HEADER/SUPPLIER/SITES/SITE/EMAIL',
supp_site_add_line1_2 VARCHAR2(254 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE1',
supp_site_add_line2_2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE2',
supp_site_add_line3_2 VARCHAR2(35 ) path 'HEADER/SUPPLIER/SITES/SITE/ADDRESS_LINE3',
supp_site_country_code_2 VARCHAR2(2 ) path 'HEADER/SUPPLIER/SITES/SITE/COUNTRY_CODE',
supp_site_province_2 VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/PROVINCE',
supp_site_state_2 VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/STATE',
supp_site_city_2 VARCHAR2(25 ) path 'HEADER/SUPPLIER/SITES/SITE/CITY',
supp_site_area_code_2 VARCHAR2(10 ) path 'HEADER/SUPPLIER/SITES/SITE/AREA_CODE',
supp_site_zip_2 VARCHAR2(20 ) path 'HEADER/SUPPLIER/SITES/SITE/ZIP',
supp_site_region_code_2 VARCHAR2(3 ) path 'HEADER/SUPPLIER/SITES/SITE/REGION_CODE',As this table I am being used in many areas, it will be problem for me if try to go for different levels of tables. Or else can it be possible to read only once
I mean only the first in the xml tags and leave the second xml. As there is not much significant for the second one.
I appreciate your ideas on this, as the structure we are following is to rigid so I don't have much options to explore, please provide me your inputs in this context.
Thanks for your help.
Regards
Nagendra
Edited by: 838961 on Jul 13, 2011 1:43 AM -
Item Conversion Template Issue for Oracle Migration - Copy functionality
Hi,
I am working on Migration project which is from Radius ERP to Oracle 11.5.10.2.
Currently working on Item Conversion. This Item conversion having the fileds like (ORGANIZATION_ID,SEGMENT1,DESCRIPTION,ITEM_TYPE,COST_OF_SALES_ACCOUNT,SALES_ACCOUNT,ATTRIBUTE_CATEGORY,ATTRIBUTE1,ATTRIBUTE2,ATTRIBUTE3,ATTRIBUTE4,ATTRIBUTE5,ATTRIBUTE6,ATTRIBUTE7,ATTRIBUTE8,ATTRIBUTE9,ATTRIBUTE10,ATTRIBUTE11,ATTRIBUTE12,ATTRIBUTE13,ATTRIBUTE14,ATTRIBUTE15,GLOBAL_ATTRIBUTE10,REF_INVENTORY_ITEM_ID,REF_ORGANIZATION_ID).
I have validated those fields and loaded into interfacing to Oracle Successfully in the master Org and Validated through Frontend.
when I close the form, I will be receiving the below warning message and telling that Template id needs to be assign to the item before assigning item to the Org. The message is showing like
"*You have not applied a template to this item, please apply a template before assigning this item to an ORG.*"
Please find the below package which I wrote for this conversion requirement.
The customer is saying like need to achieve the copy functionality based on the "REF_INVENTORY_ITEM_ID and REF_ORGANIZATION_ID".
The Issue is am not able to handle the copy functionality and getting above message. kindly refer the package and suggest me where i am doing the mistake. Its high priority issue for me.
Thanks in advance.
CREATE OR REPLACE PACKAGE APPS.xxxx_inv_items_conv_pkg
AS
PROCEDURE xxx_item_conversion_proc (
errbuf OUT VARCHAR2,
retcode OUT VARCHAR2,
p_org_id IN NUMBER,
-- p_commit_point IN NUMBER,
p_load_code IN VARCHAR2
IS
<<Local Variables Declaration>> <<For space limit deleted these variables>>
CURSOR cur_item_master (pc_org_code VARCHAR2)
IS
SELECT itemstg.*
FROM xxx_inv_system_items_stg itemstg
WHERE itemstg.organization_id = pc_org_code
AND itemstg.status_flag IS NULL;
CURSOR cur_item_master_dup (pc_org_code VARCHAR2)
IS
SELECT itemstg.segment1, itemstg.organization_id
FROM xxx_inv_system_items_stg itemstg
WHERE itemstg.ROWID <
(SELECT MAX (b.ROWID)
FROM xxx_inv_system_items_stg b
WHERE b.segment1 = itemstg.segment1
AND b.organization_id = itemstg.organization_id
AND b.organization_id = pc_org_code
AND itemstg.status_flag IS NULL
AND b.status_flag IS NULL);
BEGIN
IF p_load_code = 'Insert'
THEN
l_transaction_type := 'CREATE'; -- Default Value in I/F Table
ELSIF p_load_code = 'Update'
THEN
l_transaction_type := 'UPDATE'; -- Default Value in I/F Table
END IF;
DBMS_OUTPUT.put_line ( 'Validation Starts At :'
|| TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
--Checking for Duplicate Records items
BEGIN
UPDATE xxx_inv_system_items_stg a
SET a.status_flag = 'E',
a.error_message = 'Duplicate Record'
WHERE a.ROWID >
ANY (SELECT b.ROWID
FROM xxx_inv_system_items_stg b
WHERE a.segment1 = b.segment1
AND a.organization_id = b.organization_id)
AND a.organization_id = p_org_id
AND a.status_flag IS NULL;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Exception in updating duplicates'
|| SQLERRM
END;
DBMS_OUTPUT.put_line ('CheckPoint: Duplicate Record');
BEGIN
SELECT organization_id
INTO l_organization_id
FROM org_organization_definitions
WHERE organization_id = p_org_id;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.PUT_LINE(p_org_id||' Org Does Not Exist');
-- p_retcode := '2';
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE('Exception in Getting Org Id'||'Cannot Proceed');
-- p_retcode := '2';
END ;
DBMS_OUTPUT.put_line ('CheckPoint: Orgcode' || l_organization_id);
/* IF p_retcode = '2'
THEN
RETURN;
END IF;*/
--Block : Setting Master and Validation Orgs Flags
BEGIN
SELECT DECODE (master_organization_id, l_organization_id, 'Y', 'N'),
master_organization_id
INTO l_master_org,
l_master_org_id
FROM mtl_parameters
WHERE organization_id = l_organization_id;
EXCEPTION
WHEN OTHERS
THEN
l_master_org := 'N';
l_master_org_id := NULL;
DBMS_OUTPUT.PUT_LINE(p_org_id||' Org Does Not Exist');
END ;
DBMS_OUTPUT.put_line ('master_organization_id');
SELECT fnd_profile.VALUE ('USER_ID')
INTO l_user_id
FROM DUAL;
-- Block : Set the SET_PROCESS_ID
l_set_process_id := l_organization_id;
l_insert_count := 0;
LOOP
BEGIN
SELECT COUNT (segment1)
INTO l_insert_count
FROM mtl_system_items_interface
WHERE set_process_id = l_set_process_id
AND transaction_type = l_transaction_type
AND process_flag = 1;
EXCEPTION
WHEN OTHERS
THEN
l_insert_count := 0;
END;
EXIT WHEN l_insert_count = 0;
l_set_process_id := l_set_process_id + 10;
END LOOP;
DBMS_OUTPUT.put_line ('SET PROCESS ID -l_insert_count ' || l_insert_count);
IF p_load_code = 'Insert'
THEN
BEGIN
FOR recitem_data IN cur_item_master_dup (p_org_id)
LOOP
UPDATE xxx_inv_system_items_stg
SET status_flag = l_processed_flag,
error_message = l_error_message
WHERE segment1 = recitem_data.segment1
AND organization_id = recitem_data.organization_id
AND status_flag IS NULL;
COMMIT;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ( 'Update of Duplicates Failed : '
|| SQLCODE
|| '--'
|| SQLERRM
END ;
END IF;
FOR recitem_data IN cur_item_master (p_org_id)
LOOP
<<Local Variables Declaration>> <<For space limit deleted these variables>>
IF p_load_code = 'Update'
THEN
l_error_message := 'Update Mode' || l_error_delimiter;
END IF;
--l_count := -1;
BEGIN
DBMS_OUTPUT.put_line ('CheckPoint: ItemValidationStart');
SELECT DISTINCT inventory_item_id,
restrict_subinventories_code,
restrict_locators_code
INTO l_inventory_item_id,
l_restrict_subinventories_code,
l_restrict_locators_code
FROM apps.mtl_system_items_b msi
WHERE msi.organization_id = l_organization_id
AND msi.segment1 = UPPER (recitem_data.segment1);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_count := 0;
-- l_processed_flag := 'F';
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP' || l_inventory_item_id||'-'||l_processed_flag);
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP' || l_inventory_item_id||'-'||recitem_data.ref_inventory_item_id);
WHEN OTHERS
THEN
l_count := -1;
-- l_processed_flag := 'F';
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP' || l_inventory_item_id||'-'||l_processed_flag);
END ;
DBMS_OUTPUT.put_line ('inventory_item_id - AFTER MAIN LOOP'||recitem_data.ref_inventory_item_id);
IF l_count = -1
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Exception - Checking Item already Present'
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('Exception - Checking Item already Present'||l_processed_flag);
ELSIF (l_count > 0 AND p_load_code = 'Insert')
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Item Already Exists In '
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('Exception - Checking Item already Present1'||l_processed_flag);
ELSIF (l_count = 0 AND p_load_code = 'Update')
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Item Not Present In '
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('Exception - Checking Item already Present2'||l_processed_flag);
END IF;
BEGIN
SELECT count(*)
INTO l_seg_count
FROM apps.mtl_system_items_b msi
WHERE msi.organization_id = l_organization_id
AND msi.segment1 = UPPER (recitem_data.segment1);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_seg_count := 0;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Item Not Present In Oracle'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('inventory_item_id - l_seg_count ' ||l_seg_count||'-'||l_processed_flag );
WHEN OTHERS
THEN
l_seg_count := -1;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Item Not Present In Oracle'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
END ;
IF p_load_code = 'Insert'
THEN
IF l_organization_id != l_master_org_id
THEN
BEGIN
SELECT COUNT (1)
INTO l_org_item_count
FROM apps.mtl_system_items_b msi
WHERE msi.organization_id = l_master_org_id
AND msi.segment1 = UPPER (recitem_data.segment1);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_org_item_count := 0;
DBMS_OUTPUT.put_line ('l_org_item_count ' ||l_org_item_count||'-'||l_processed_flag );
WHEN OTHERS
THEN
l_org_item_count := -1;
END ;
IF l_org_item_count = -1
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Exception - Checking Item in Master '
|| l_error_delimiter;
ELSIF l_org_item_count = 0
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Item Does Not Exist in Master '
|| l_error_delimiter;
END IF;
END IF;
END IF;
DBMS_OUTPUT.put_line ( 'CheckPoint: Iteminmasterorg'
|| l_org_item_count
IF (recitem_data.description IS NULL AND p_load_code = 'Insert')
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message || 'Description is NULL' || l_error_delimiter;
END IF;
IF (recitem_data.sales_account IS NOT NULL)
THEN
BEGIN
SELECT code_combination_id
INTO l_sales_account
FROM gl_code_combinations_kfv
WHERE code_combination_id= recitem_data.sales_account;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
-- l_processed_flag := 'F'; --QUESTION
l_error_message :=
l_error_message
|| 'Sales Account Not Setup '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'CheckPoint: Salesacct_Validation'
|| l_sales_account||'-'||l_processed_flag
WHEN OTHERS
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Sales Account Exception '
|| SQLERRM
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'CheckPoint: Salesacct_Validation'
|| l_sales_account||'-'||l_processed_flag
END ;
END IF;
IF (recitem_data.cost_of_sales_account IS NOT NULL)
THEN
BEGIN
SELECT code_combination_id
INTO l_cost_of_sales_account
FROM gl_code_combinations_kfv
WHERE code_combination_id =
recitem_data.cost_of_sales_account;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'COGS Account Not Setup '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'l_cost_of_sales_account'
|| l_cost_of_sales_account||'-'||l_processed_flag
WHEN OTHERS
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'COGS Account Exception '
|| SQLERRM
|| l_error_delimiter;
DBMS_OUTPUT.put_line ( 'l_cost_of_sales_account'
|| l_cost_of_sales_account||'-'||l_processed_flag
END check_cogs_account;
END IF;
BEGIN
select distinct organization_code
into l_ref_org_code
from org_organization_definitions
where organization_id = recitem_data.ref_organization_id ;
EXCEPTION
WHEN OTHERS THEN
l_ref_org_code:= NULL;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Reference Org Not Present'
|| p_org_id
|| ' Organization '
|| l_error_delimiter ;
DBMS_OUTPUT.put_line ('l_ref_org_code'|| l_ref_org_code||'-'||l_processed_flag);
END;
BEGIN
select concatenated_segments
into l_ref_inventory_item_code
from mtl_system_items_kfv
where inventory_item_id = recitem_data.ref_inventory_item_id
and organization_id = recitem_data.ref_organization_id ;
EXCEPTION
WHEN OTHERS THEN
l_ref_inventory_item_code :=NULL;
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Reference Item Not Present'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
DBMS_OUTPUT.put_line ('l_ref_inventory_item_code'|| l_ref_inventory_item_code||'-'||l_processed_flag);
END;
IF (l_master_org = 'N' AND p_load_code = 'Insert')
THEN
BEGIN
SELECT count(*)
INTO l_description_count
FROM mtl_system_items_tl
WHERE organization_id = l_master_org_id
AND inventory_item_id =
(SELECT inventory_item_id
FROM mtl_system_items_b
WHERE organization_id = l_master_org_id
AND segment1 = recitem_data.segment1);
END ;
IF l_description_count > 0 THEN
l_processed_flag:='F';
l_error_message :=
l_error_message
|| 'Item Description Not Present'
|| p_org_id
|| ' Organization '
|| l_error_delimiter;
END IF;
END IF;
IF l_processed_flag = 'S'
THEN
BEGIN
INSERT INTO mtl_system_items_interface
(organization_id,
segment1,
description,
ITEM_TYPE,
COST_OF_SALES_ACCOUNT,
SALES_ACCOUNT,
attribute_category,
set_process_id,
transaction_type,
process_flag,
copy_organization_code,
copy_item_number,
creation_date,
created_by,
last_updated_by,
last_update_date
--attribute_category
, attribute1
, attribute2
,attribute3
,attribute4
,attribute5
,attribute6
,attribute7
,attribute8
,attribute9
,attribute10
,attribute11
,attribute12
,attribute13
,attribute14
,attribute15
,global_attribute10
VALUES (l_organization_id,
recitem_data.segment1,
recitem_data.description,
recitem_data.ITEM_TYPE,
recitem_data.COST_OF_SALES_ACCOUNT,
recitem_data.SALES_ACCOUNT,
recitem_data.ATTRIBUTE_CATEGORY,
l_set_process_id,
l_transaction_type, --,l_transaction_type
l_process_flag,
l_ref_org_code,
l_ref_inventory_item_code,
SYSDATE, l_user_id,
l_user_id, SYSDATE
-- l_attribute_category
,recitem_data.attribute1
,recitem_data.attribute2
,recitem_data.attribute3
,recitem_data.attribute4
,recitem_data.attribute5
,recitem_data.attribute6
,recitem_data.attribute7
, recitem_data.attribute8
,recitem_data.attribute9
, recitem_data.attribute10
,recitem_data.attribute11
,recitem_data.attribute12
,recitem_data.attribute13
,recitem_data.attribute14
,recitem_data.attribute15
, substr(recitem_data.global_attribute10,1,length(recitem_data.global_attribute10)-1) --recitem_data.global_attribute10
l_insert_count := l_insert_count + 1;
/* IF (l_insert_count = NVL (p_commit_point, 10000))
THEN
-- l_set_process_id := l_set_process_id + 10; -- REVERT BACK CHANGE
l_insert_count := 0;
END IF;
EXCEPTION
WHEN OTHERS
THEN
l_processed_flag := 'F';
l_error_message :=
l_error_message
|| 'Error in Inserting Item '
|| SQLERRM
|| l_error_delimiter;
END ;
COMMIT;
DBMS_OUTPUT.put_line ('CheckPoint: Insertion Completed in Intfacetable');
END IF;
BEGIN
UPDATE xxx_inv_system_items_stg
SET status_flag = l_processed_flag,
error_message = l_error_message
WHERE segment1 = recitem_data.segment1
AND organization_id = recitem_data.organization_id
AND status_flag IS NULL;
COMMIT;
DBMS_OUTPUT.put_line ('Error Message'||l_error_message);
EXCEPTION
WHEN OTHERS
THEN
fnd_file.put_line (fnd_file.LOG,
'Error:Updating Item:'
|| SQLCODE
|| '-'
|| SQLERRM
END;
END LOOP; --FOR recitem_data IN cur_item_master
DBMS_OUTPUT.put_line ( 'Validation Ends At :'
|| TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
DBMS_OUTPUT.put_line ('Number of records inserted into Table Successfully -->'|| l_insert_count);
END;
END xxxx_inv_items_conv_pkg;
Edited by: 896170 on Apr 12, 2013 11:58 PMIssue got solved... changed the PO line amount as:
<?xdoxslt:set_variable($_XDOCTX,'line_amt',xdoxslt:to_number(LINE_AMOUNT))?>
Reference :Syntax for 'to_number'
Regards
Manikanta Panigrahi
Maybe you are looking for
-
(Self-)signing a MIDlet for use on ~10 phones without spending money
Hello everyone, I just spend like 4 hours researching how to sign MIDlet and I am totally confused. Instead of asking for general instructions I am going to explain what I want to do. Hopefully that will enable people to tell me whether or not this i
-
Customer down payment problems
Hello All, My client is facing the following problem can any one give me a clear idea about reason for this When an invoice is created from a billing plan, the amount displayed as the amount available from the downpayment is different from the amount
-
Changing the Owner of all Objects in Instance ?
How to Change the Owner of all Objects in Instance, like for example the Procedure: sp_changedbowner in an MS-SQL-Database, who changed the Owner of the actual Database ! I'am looking for another possibility to do it by export the Datbase and import
-
BEA Soap Faults and differentiating them from Normal Soap Faults
Hi, I've written a webservice client that interfaces with an external soap service. The external soap service generates custom soap exceptions that I am already handling by catching remote exception and then getting the cause from this remote excepti
-
Move large tables and indexes into own tablespace
I currently manage a 100Gb 10.2.0.4 SE database on Windows. There is one data tablespace and one indexes. I have one table xxxHistory that is periodically cleared out, however, six months of data must be retained. The table is currently 17Gb and has