Need help in parsing a VARCHAR2(4000 BYTES) field
Hi Guys,
Let me give the DB information first:
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Solaris: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
My problem is: The frontend of the application sends a large string into the VARCHAR2 (4000 BYTES) field. The string it sends is somewhat like this -
<strong>Crit:</strong> Some text. <br><strong>Distinguished</strong> (points 3):Some comment text1. <blockquote> </blockquote><strong>Crit:</strong> Some other text.<br><strong>Distinguished</strong> (points 3):Some comment text2. <blockquote> </blockquote><strong>Crit:</strong> Some more text. <br><strong>Distinguished</strong> (points 3):Some comment text3. <blockquote> </blockquote><strong>Overall comments:</strong><br> Final text!!I want to parse the text and put into separate columns. Number of Crit: can be more than 3; its 3 up there. But the basic structure is same. What is the best possible way of parsing this in PL/SQL code? I want something like
Table 1
Crit Points Comment
Some text 3 Some comment text1.
Some other text 3 Some comment text2.
Some more text 3 Some comment text3.
Table 2
Overall comments
Final text!!Please let me know, if you need further information.
Thanks.
Edited by: 794684 on Sep 14, 2010 4:15 AM
Edited by: 794684 on Sep 14, 2010 4:38 AM
Edited by: 794684 on Sep 14, 2010 4:53 AM
Edited by: 794684 on Sep 14, 2010 6:42 AM
Welcome to the forum.
Looks like noformat tags are not working.Please use the {noformat}{noformat} tag if you want to post formatted examples/code.
For example, when you type:
{noformat}select *
from dual;
{noformat}
it will appear as:select *
from dual;
when you post it on this forum...
The FAQ will explain the other options you have: http://forums.oracle.com/forums/help.jspa
Similar Messages
-
External table varchar2(4000 byte) field storing 255 bytes only
Hi all,
wondering if someone can tell me what im missing here.
I have an external table with a column defined as varchar2(4000 byte). the file has a row in it with 255 characters (all number 2's for simplicity). when i query the table all is well. if i add 1 more 2 to the string (256 chars) it fails. im sure its something stupidly simple but what am i missing? shouldnt it query fine until 4000 chars?
thanks,
DaveI ran your testcase, thanks for that.
Make sure to read the SQL and PL/SQL FAQ as well (the first sticky thread on this forum), it explains how to post formatted code and lots of other stuff.
Anyway, .log file gave me:
LOG file opened at 07/18/11 20:05:33
Field Definitions for table DAVEP2
Record format DELIMITED, delimited by 0A
Data in file has same endianness as the platform
Rows with all null fields are accepted
Fields in Data Source:
MY_STRING CHAR (255)
Terminated by ","
Enclosed by """ and """
Trim whitespace same as SQL LoaderSo, what happens if you create the table as follows:
CREATE TABLE davep2 (
my_string VARCHAR2(4000 BYTE) NULL
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY FILE_TEST
ACCESS PARAMETERS
( RECORDS DELIMITED BY 0x'0A' BADFILE FILE_TEST:'davep2.bad'
LOGFILE FILE_TEST:'davep2.log'
FIELDS TERMINATED BY ',' optionally enclosed by '"' and '"'
missing field values are null
my_string char(4000)
LOCATION (FILE_TEST:'DaveP.csv')) REJECT LIMIT 0 NOPARALLEL -
Urgent : Need help in parsing XML from Sharepoint and save it into DB
Hi ,
I am Sharepoint guy and a newbie in Oracle . PL/SQL
I am using UTL_DBWS Package to call a Sharepoint WebService " and was sucessfull , Now the xml has to be parsed and stored into a Table. I am facing the issue as the XML has a different namesoace and normal XPATH query is not working
Below is the XML and need help in parsing it
declare
responsexml sys.XMLTYPE;
testparsexml sys.XMLTYPE;
begin
responsexml := sys.XMLTYPE('<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<rs:data ItemCount="2">
<z:row ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Test Title 1" ows_ID="1" ows_owshiddenversion="1" ows_UniqueId="1;#{9C45D54E-150E-4509-B59A-DB5A1B97E034}" ows_FSObjType="1;#0" ows_Created="2009-09-12 17:13:16" ows_FileRef="1;#Lists/Tasks/1_.000"/>
<z:row ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Testing Tasks" ows_ID="2" ows_owshiddenversion="1" ows_UniqueId="2;#{8942E211-460B-422A-B1AD-1347F062114A}" ows_FSObjType="2;#0" ows_Created="2010-02-14 16:44:40" ows_FileRef="2;#Lists/Tasks/2_.000"/>
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>');
testparsexml := responsexml.extract('/GetListItemsResponse/GetListItemsResult/listitems/rs:data/z:row/@ows_Title');
DBMS_OUTPUT.PUT_LINE(testparsexml.extract('/').getstringval());
end;
The issue is with rs:data , z:row nodes.... please suggest how to handle these kind of namespaces in Oracle
I need the parse the attribute "ows_Title" and save it into a DB
this script would generate "Error occured in XML Parsing"
Help is appriciated, thanks for lookingSQL> SELECT *
FROM XMLTABLE (
xmlnamespaces ('http://schemas.microsoft.com/sharepoint/soap/' as "soap",
'#RowsetSchema' AS "z"
'for $i in //soap:*//z:row return $i'
PASSING xmltype (
'<GetListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<GetListItemsResult>
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<rs:data ItemCount="2">
<z:row ows_MetaInfo="1;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Test Title 1" ows_ID="1" ows_owshiddenversion="1" ows_UniqueId="1;#{9C45D54E-150E-4509-B59A-DB5A1B97E034}" ows_FSObjType="1;#0" ows_Created="2009-09-12 17:13:16" ows_FileRef="1;#Lists/Tasks/1_.000"/>
<z:row ows_MetaInfo="2;#" ows__ModerationStatus="0" ows__Level="1" ows_Title="Testing Tasks" ows_ID="2" ows_owshiddenversion="1" ows_UniqueId="2;#{8942E211-460B-422A-B1AD-1347F062114A}" ows_FSObjType="2;#0" ows_Created="2010-02-14 16:44:40" ows_FileRef="2;#Lists/Tasks/2_.000"/>
</rs:data>
</listitems>
</GetListItemsResult>
</GetListItemsResponse>')
columns ows_MetaInfo varchar2(20) path '@ows_MetaInfo',
ows_Title varchar2(20) path '@ows_Title',
ows__ModerationStatus varchar2(20) path '@ows__ModerationStatus'
OWS_METAINFO OWS_TITLE OWS__MODERATIONSTATUS
1;# Test Title 1 0
2;# Testing Tasks 0
2 rows selected. -
Urgently need help for parsing IP header
Hi, could anyone tell which class I should use to parsing the IP header of a packet?
Thanks many many times!> Hi, could anyone tell which class I should use to
parsing the IP header of a packet?
DatagramPacket?
> Urgently need help for parsing IP header
Don't flag your question as urgent, even if it is for you.
* We all answer questions here voluntarily, in our leisure time. We do that because doing so is fun for us, because we enjoy helping people and having interesting discussions. Guess what, it is much less fun if it gets stressful. So the last thing you want to do to get us to answer your question is to pass your stress over to us.
* People who are stressed and want a fast answer often don't even find the time to do the necessary research or to formulate their question in an easy to comprehend way. That's even less fun to work with. So you really don't want us to feel your stress. Instead you want to take your time to write a well formulated post that is fun to answer. The less likely it is for us to know that your question is urgent, the more likely you are to get a fast answer!
* The simple notion that you want your post to be answered faster than those of the other members might feel rather unfair to some of us. Doubly so because often "urgent" questions actually are homework questions. Yours might be different, but someone who had bad experiences with this type of question might not read far enough to notice. -
Diff between VARCHAR2(4000) & VARCHAR2(4000 BYTE)
Hi
Pls do explain the diff
a. VARCHAR2(4000) & VARCHAR2(4000 BYTE)
b. NUMBER & NUMBER BYTE
Regards
YramX CHAR means that column should contain X characters regardless of how many bytes they takes. For example latvian specific character ā takes more than 1 byte in some unicode caharctersets, but latin character a only one byte. So in 1 CHAR you will be able to store both ā and a but in 1 BYTE only a.
One has to remember that 4000 byte maximum limit for varchar column is effective REGARDLESS of 4000 CHAR and you wouldn't be able to store 4000 multi byte characters there. As soon as length in bytes of your string will be greater than 4000 Oracle will throw an error. If I remember correctly, in some earlier 9i version(s) there was a bug that Oracle silently cut the tail after 4000 bytes without an error.
Gints Plivna
http://www.gplivna.eu -
Difference between varchar2(4000 byte) & varchar2(4000 char
Hi,
My existing database NLS parameters as follows
CHARACTER SET US7ASCII
NATIONAL CHARACTER SET AL16UTF16
created a test database to support globalization, I changed as follows
CHARACTER SET UTF8
NATIONAL CHARACTER SET UTF8
some of the table column datatypes are varchar2(4000)
I would like to know what is difference between VARCHAR2(4000 BYTE) and VARCHAR2(4000 CHAR).
ThanksIndeed, VARCHAR2(x BYTE) means that the column will hold as much characters as will fit into x bytes. Depending on the character set and particular characters this may be x or less characters.
For example, a VARCHAR2(20 BYTE) column in an AL32UTF8 database can hold 20 characters from the ASCII range, 10 Latin letters with umlaut, 10 Cyryllic, 10 Hebrew, or 10 Arabic letters (2 bytes per character), or 6 Chinese, Japanese, Korean, or Devanagari (Indic) characters. Or a mixture of these characters of any total length up to 20 bytes.
VARCHAR2(x CHAR) means that the column will hold x characters but not more than can fit into 4000 bytes. Internally, Oracle will set the byte length of the column (DBA_TAB_COLUMNS.DATA_LENGTH) to MIN(x * mchw, 4000), where mchw is the maximum byte width of a character in the database character set. This is 1 for US7ASCII or WE8MSWIN1252, 2 for JA16SJIS, 3 for UTF8, and 4 for AL32UTF8.
For example, a VARCHAR2(3000 CHAR) column in an AL32UTF8 database will be internally defined as having the width of 4000 bytes. It will hold up to 3000 characters from the ASCII range (the character limit), but only 1333 Chinese characters (the byte limit, 1333 * 3 bytes = 3999 bytes). A VARCHAR2(100 CHAR) column in an AL32UTF8 database will be internally defined as having the width of 400 bytes. It will hold up to any 100 Unicode characters.
The above implies that the CHAR limit works optimally if it is lower than 4000/mchw. With such restriction, the CHAR limit guarantees that the defined number of characters will fit into the column. Because the widest character in any Oracle character set has 4 bytes, if x <= 1000, VARCHAR2(x CHAR) is guaranteed to hold up to x characters in any database character set.
The declaration VARCHAR2(x):
- for objects defined in SYS schema means VARCHAR2(x BYTE),
- for objects defined in other schemas it means VARCHAR2(x BYTE) or VARCHAR2(x CHAR), depending on the value of the NLS_LENGTH_SEMANTICS parameter of the session using the declaration (see the NLS_SESSION_PARAMETERS view).
After an object is defined, its BYTE vs CHAR semantics is stored in the data dictionary and it does not depend on the NLS_LENGTH_SEMANTICS any longer. Even Export/Import will not change this.
Character length semantics rules are valid for table columns and for PL/SQL variables.
-- Sergiusz -
Cannot insert varchar2 4000 bytes correctly in asp
I tried to insert 4000 bytes into a filed of varchar2 type
in an ASP page using bind variables.
After inserting, I cannot fetch the column correctly. Result was only 2000 bytes.
In sqlplus I verified that the inserted data was 4000 bytes but a wrong character at 2001 th byte.
I use oracle 8.1.6.
This problem is not occurring in JSP.
Thanks...Have you solved your problem yet?
I think you are experiencing the auto-magical characterset conversions in Windows applications.
SQL*Plus is still using those non-Unicode Win APIs; on the contrary, your C# application is very probably using the Unicode Win APIs. That means, no matter how you input (Big5 ones, unicode ones, cut-and-paste, .... ), SQL*Plus receives the characters in Big5 form and your C# application receives them in Unicode form. Windows does all the conversions transparently.
In the SQL*Plus case, the HKSCS characters are in their Big5 UDA/VDA codes. Since both your server and client have NLS_LANG set as ZHT16MSWIN950, these HKSCS Big5 codes are stored in your database intact w/o any conversion. When these characters are displayed, no matter in SQL*Plus or your C# application, they are retrieved in Big5 form and passed to Windows for display. Hence, there is no problem.
However, when you input these HKSCS characters through your C# application, they are received in Unicode form. I believe that your application is storing these Unicode characters in DB directly and, therefore, they must be converted to "MSWIN950" form by some Oracle components who lacks the full conversion table of Windows. Naturally, HKSCS characters become "??".
I am not familiar with C# and Windows APIs so I dunno the exact way to solve the problem. Still, the rule-of-thumb is to let Windows does the character set conversions and ensure that the converted data are stored in Oracle w/o further conversions. I think your C# applications should convert the text data from Unicode to Big5 (under Windows) and then save the Big5 data to the ZHT16MSWIN950 database in Big5 context. This will probably solve your problem. -
Need help on parsing xml file...
Hi all,
I need to collect some data from an Xml file using java. I have the following code with me but I am unable to get the required result. I am unable to get the data from the tags belonging to the header and footer elements. Please find the code and the sample xml file below.
Program to parse XML:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class JobLogDetails3{
//No generics
List myJobs;
Document dom;
public JobLogDetails3(){
//create a list to hold the job objects
myJobs = new ArrayList();
public void runJobDetails() {
//parse the xml file and get the dom object
parseXmlFile();
//get each joblog element and create a job object
parseDocument();
//Iterate through the list and print the data
printData();
private void parseXmlFile(){
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation of the XML file
dom = db.parse("test.xml");
}catch(ParserConfigurationException pce) {
pce.printStackTrace();
}catch(SAXException se) {
se.printStackTrace();
}catch(IOException ioe) {
ioe.printStackTrace();
private void parseDocument(){
//get the root elememt
Element docEle = dom.getDocumentElement();
//get a nodelist of <joblog> elements
NodeList nl = dom.getElementsByTagName("*");
if(nl != null && nl.getLength() > 0) {
for(int i = 0 ; i < nl.getLength();i++) {
//get the joblog element
Element el = (Element)nl.item(i);
//get the joblog object
Job J = getJob(el);
//add it to list
myJobs.add(J);
* I take an joblog element and read the values in, create
* an joblog object and return it
* @param JobEl
* @return
private Job getJob(Element JobEl) {
//for each <joblog> element get text or int values of
//name ,id, age and name
String jobServer = getTextValue(JobEl,"server");
String jobName = getTextValue(JobEl,"name");
String jobClient = getTextValue(JobEl,"machine_name");
String jobStart = getTextValue(JobEl,"start_time");
String jobType = getTextValue(JobEl,"type");
String jobEnd = getTextValue(JobEl,"end_time");
String jobSize = getTextValue(JobEl,"new_processed_bytes");
//Create a new Job with the value read from the xml nodes
Job J = new Job(jobServer,jobName,jobClient,jobStart,jobType,jobEnd,jobSize);
return J;
* I take a xml element and the tag name, look for the tag and get
* the text content
* i.e for <employee><name>John</name></employee> xml snippet if
* the Element points to employee node and tagName is name I will return John
* @param ele
* @param tagName
* @return
private String getTextValue(Element ele, String tagName) {
String textVal = null;
NodeList nl = ele.getElementsByTagName(tagName);
if(nl != null && nl.getLength() > 0) {
Element el = (Element)nl.item(0);
textVal = el.getFirstChild().getNodeValue();
return textVal;
* Calls getTextValue and returns a int value
* @param ele
* @param tagName
* @return
private int getIntValue(Element ele, String tagName) {
//in production application you would catch the exception
return Integer.parseInt(getTextValue(ele,tagName));
* Iterate through the list and print the
* content to console
private void printData(){
System.out.println("No of Jobs '" + myJobs.size() + "'.");
Iterator it = myJobs.iterator();
while(it.hasNext()) {
System.out.println(it.next().toString());
public static void main(String[] args){
//create an instance
JobLogDetails JLD = new JobLogDetails();
//call run example
JLD.runJobDetails();
Job Class
public class Job {
private String jobServer;
private String jobName;
private String jobClient;
private String jobStart;
private String jobType;
private String jobEnd;
private String jobSize;
public Job(){
public Job(String jobServer,String jobName,String jobClient,String jobStart,String jobType,String jobEnd,String jobSize ) {
this.jobServer = jobServer;
this.jobName = jobName;
this.jobClient = jobClient;
this.jobStart = jobStart;
this.jobType = jobType;
this.jobEnd = jobEnd;
this.jobSize = jobSize;
public String getjobServer() {
return jobServer;
public void setjobServer(String jobServer) {
this.jobServer = jobServer;
public String getjobName() {
return jobName;
public void setjobname(String jobName) {
this.jobName = jobName;
public String getjobClient() {
return jobClient;
public void setjobClient(String jobClient) {
this.jobClient = jobClient;
public String getjobStart() {
return jobStart;
public void setjobStart(String jobStart) {
this.jobStart = jobStart;
public String getjobType() {
return jobType;
public void setjobType(String jobType) {
this.jobType = jobType;
public String getjobEnd() {
return jobEnd;
public void setjobEnd(String jobEnd) {
this.jobEnd = jobEnd;
public String getjobSize() {
return jobSize;
public void setjobSize(String jobSize) {
this.jobSize = jobSize;
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(getjobServer());
sb.append(",");
sb.append(getjobName());
sb.append(",");
sb.append(getjobClient());
sb.append(",");
sb.append(getjobType());
sb.append(",");
sb.append(getjobStart());
sb.append(",");
sb.append(getjobEnd());
sb.append(",");
sb.append(getjobSize());
sb.append(",");
return sb.toString();
Sample XML File:
<?xml version="1.0" encoding="UTF-16" ?>
- <joblog>
<job_log_version version="2.0" />
- <header>
<filler>======================================================================</filler>
<server>Job server: TGBBAK</server>
<name>Job name: TGBSAP4-SQL-SQL DB Servers S2T - High-Weekly Full Backup</name>
<start_time>Job started: 26 September 2011 at 01:00:04</start_time>
<type>Job type: Backup</type>
<log_name>Job Log: GFD_TGBBAK_71887.xml</log_name>
<filler>======================================================================</filler>
</header>
<media_mount_date>Drive and media mount requested: 26/09/2011 01:00:04</media_mount_date>
- <media_drive_and_media_info>
<media_mount_date>Drive and media information from media mount: 26/09/2011 01:00:39</media_mount_date>
<robotic_library_name>Robotic Library Name: HP 1</robotic_library_name>
<drive_name>Drive Name: LTO4_2</drive_name>
<slot>Slot: 43</slot>
<media_label>Media Label: 000059L</media_label>
<media_guid>Media GUID: {a6ca0062-7a6f-4b4b-8144-732ca25f2f9d}</media_guid>
<media_overwrite_date>Overwrite Protected Until: 25/10/2011 19:24:58</media_overwrite_date>
<media_append_date>Appendable Until: 02/10/2011 14:00:30</media_append_date>
<media_set_target>Targeted Media Set Name: Weekly Tape</media_set_target>
</media_drive_and_media_info>
- <backup>
<filler>======================================================================</filler>
<title>Job Operation - Backup</title>
<append_or_overwrite>Media operation - append.</append_or_overwrite>
<compression>Compression Type: Hardware [if available, otherwise none]</compression>
<verify_option>WARNING: The option 'Verify after backup completes' was not selected. Performing a verify operation to make sure that media can be read after the backup has completed is recommended.</verify_option>
<filler>======================================================================</filler>
- <machine>
<machine_name>TGBSAP4.Tetley.Grp</machine_name>
<info>Network control connection is established between 10.22.2.18:3271 <--> 10.22.2.4:10000</info>
<info>Network data connection is established between 10.22.2.18:3301 <--> 10.22.2.4:3094</info>
- <set>
<set_resource_name>TGBSAP4.Tetley.Grp</set_resource_name>
<tape_name>Family Name: "Media created 25/09/2011 13:59:55"</tape_name>
- <volume>
<display_volume>Backup of "TGBSAP4.Tetley.Grp "</display_volume>
</volume>
<description>Backup set #45 on storage media #1 Backup set description: "Weekly Full Backup"</description>
<backup_type>Backup Method: Full - Back up entire database or filegroup</backup_type>
<agent_started>Microsoft SQL Server Agent: Started</agent_started>
<start_time>Backup started on 26/09/2011 at 01:01:45.</start_time>
- <database>
<database>Database PRD</database>
</database>
- <database>
<database>Database master</database>
</database>
- <database>
<database>Database model</database>
</database>
- <database>
<database>Database msdb</database>
</database>
<end_time>Backup completed on 26/09/2011 at 02:42:25.</end_time>
- <summary>
<backed_up_database>Backed up 4 databases</backed_up_database>
<new_processed_bytes>Processed 573363576542 bytes in 1 hour, 40 minutes, and 40 seconds.</new_processed_bytes>
<vlm_hist_rateformat2>Throughput rate: 5432 MB/min</vlm_hist_rateformat2>
</summary>
<filler>----------------------------------------------------------------------</filler>
</set>
</machine>
</backup>
- <footer>
<filler>======================================================================</filler>
<end_time>Job ended: 26 September 2011 at 02:43:12</end_time>
<engine_completion_status>Job completion status: Successful</engine_completion_status>
<filler>======================================================================</filler>
<completeStatus>19</completeStatus>
</footer>
</joblog>1. your code does not compile (in your main method you try to create an instance of a class which does not exist).
2. your XML document is not well formed.
+[Fatal Error] test.xml:34:74: The content of elements must consist of well-formed character data or markup.+
org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
Maybe there are other problems but you can start by fixing these. -
Need help in Parsing XML Document in Oracle
Hello Experts,
I urgently need your help. We have xml document on the Web but not on the File System. How can I parse the xml document on the web in Oracle.
Any link, blog or sample code would be appreciated.
Your help would be appreciated.
Kind Regards,
Bhavin
London, UKThis breaks down to two issues
1) Getting the XML into Oracle
2) Parsing the XML inside Oracle
For #1, the first two options that come to my mind are httpuirtype and utl_http. Both can be used to get information from a URL that understands HTTP requests.
For #2, you can treat the XML as a DOMDocument or XMLType to parse it. You also could parse it via a SQL statement using XQuery or XMLTable as well.
Many of those examples can be found on the {forum:id=34} forum or [Marco's blog|http://www.liberidu.com/blog/]. A few parsing examples that I've done can be seen at {message:id=3610259}, make sure to also follow the link I put in there to a previous example before that. -
I'm trying to write an app to parse unified patch files. I've got a table to hold a set of patches from a single patch file and a table to hold each individual patch within the patch file (a single patch file can patch multiple source files). I'm currently holding the file contents in a blob field. I know how I would do this in python or other scripting languages, but I'm a complete pl/sql n00b, so I'm a bit clueless. Basically, I have the appropriate algorithm for parsing the file, but just not how to do it.
Does anyone know of a tutorial that explains how to do this? Or maybe post some tips as to what pl/sql modules to look into?Kindly go through the following links ->
http://www.oracle.com/technology/sample_code/tech/windows/odpnet/howto/anonyblock/index.html
http://www.oracle.com/technology/sample_code/tech/java/jsp/samples/blob/blob.html
http://www.psoug.org/reference/dbms_lob.html
Might be helpful for you.
Regards.
Satyaki De. -
Hello all, I hope this is an easy question....
I have a string similar to
<li><span class="RandomInformation">the latest news on my site</span></li>
I am currently geting a string where each new line is a new <li> from a pure http call. what I need to do is split this down into an array of strings (Yes this is my website, and no im not trying to rebrand other's work...:) ) delimeted on :
- each line needs to be a separate element within a multidimensional array
- Can't split on CrLf because further up and further down I have other entries I dont care about, so I need to use the <li></li> as indicators that they contain the information I want.
- out of each line, I need to separate them into multiple 'columns' within the array
- one for the contents of the span clas (in this case "RandomInformation"
- one element for the contents of the link (in this case my url, http://www.w2gas.com, but will be sub pages later like http://www.w2gas.com/page2.html)
- most importantly one element for the text between anchor tags (this case it is "the latest news on my site")
I tried a Regex for stripping the HTML tags out, however all I was left with was the text between anchors. I know I could do it based on character by character looping (have done that) but its terrible slow. I know there must be a way to accomplish this, however Im just too new to figure it out. (maybe?)
Thanks in advance
LeeWould something like [this |http://htmlparser.sourceforge.net/] help?
-
NEED HELP:To Parse Conditional Operator Within An Expression.
Hi there:
I'm having some difficulties to parse some conditoional operator. My requirements is:
Constants value: int a=1,b=2,c=3
Input/Given value: 2
conditional operator expression: d=a|b|c
Expected result: d=true
Summary: I like to receive a boolean from anys expressions defined, which check against Input/Given value.Note: The expression are various from time to time, based on user's setup, the method is smart enough to return boolean based on any expression.
Let me know if you have any concerns.
Thanks a million,
selenahere is a simple example.
BNF changes
EXPR ::= OPERATOR
EXPR ::= OPERATION OPERANT EXPR
This is as far as I can go, please use it as a template only
because you need to take into account the precedence using ()
the logic of the eval was simply right to left so I think it is not what you want
Cheers
public interface Expression
String OR = "|";
String AND = "&";
public boolean eval(int value) throws Exception;
public class ExpressionImpl implements Expression
public String oper1;
public String operant;
public Expression tail;
/* (non-Javadoc)
* @see parser.Expression#eval()
public boolean eval(int value) throws Exception
int val1 = getValue(oper1);
if (null == tail)
System.out.println(val1 + ":" + value);
return (val1 == value);
else
if (OR.equals(operant))
return (val1 == value || tail.eval(value));
else if (AND.equals(operant))
return (val1 == value && tail.eval(value));
else
throw new Exception("unsupported operant " + operant);
private int getValue(String operator) throws Exception
Integer temp = ((Integer)Parser.symbol_table.get(operator));
if (null == temp)
throw new Exception("symbol not found " + operator);
return temp.intValue();
public String toString()
if (null == operant) return oper1;
return oper1 + operant + tail.toString();
public class Parser
public static HashMap symbol_table = new HashMap();
* recursive parsing
public Expression parse(String s)
ExpressionImpl e = new ExpressionImpl();
e.oper1 = String.valueOf(s.charAt(0));
if (s.length() == 1)
return e;
else if (s.length() > 2)
e.operant = String.valueOf(s.charAt(1));
e.tail = parse(s.substring(2));
else
throw new IllegalArgumentException("invalid input " + s);
return e;
public static void main(String[] args) throws Exception
Parser p = new Parser();
Parser.symbol_table.put("a", new Integer(1));
Parser.symbol_table.put("b", new Integer(2));
Parser.symbol_table.put("c", new Integer(3));
Parser.symbol_table.put("d", new Integer(4));
Expression e = p.parse("a|b|c&d");
System.out.println("input " + e.toString());
System.out.println(e.eval(2));
} -
Need Help to parse JAPANESE DateFormat
Hi,
fullPattern is yyyy'年'M'月'd'日' (EEEE) H'時'mm'分'ss'秒' z. I changed the full pattern as
String fullPattern = "yyyy\'\u5e74\'M\'\u6708\'d\'\u65e5\' (EEEE) H\'\u6642\'mm\'\u5206\'ss\'\u79d2\' z";
full dateValue is 2010'年'09'月'12'日' (EEEE) 1'時'15'分'45'秒' GMT
String result = createBO("japanese full format",dateValue, fullPattern ,silkPageContext , false );
In createBO method, I call some other method where I have to pass the pattern and value.
When I pass fullPattern and dateValue as argument, It turns as
2010'?'09'?'12'?' (EEEE) 1'?'15'?'45'?' GMT. Because of this, I am not able to parse this format. It gives parse Exception. I need to send this format as it is...
Can I have some useful suggestion to do this.
Thanks in Advance
SureshBreak it into smaller pieces and try each one until you find the error.
-
Need help Loading parsed RSS text
Hi, I have created an AS3 FLA where I am parsing and
displaying RSS text. I have traced the parsed text and displayed
the text into dynamic text boxes on the stage no problem.
However the line breaks in the traced text show up on stage
as well.
How does one strip out the <p> or </r> tags from
the text to make the text one nice long line that will wrap using
the length of the text box as it's parameters?OK, I have found the answer, thanks all.
var myvar:String = myDynamicText.text;
myDynamicText.text = myvar.split("\r").join(" ");
myDynamicText.text = myDynamicText.text.split("\n").join(" -
Need help to modify a report written using Field-Groups Concept. - Part1
Hello ABAP Experts,
I need your help to modify the following report with following requirement as I have least knowledge
about the field-group concept. Thats is the reason, I am pasting the whole code. As it is part of our
production requirement. I really appreciate your help, If its sent modifying the code required.
Modification required in the report.
To allow the sales representatives to see billed shipments and open orders for the current month.
1) Selection Screen Changes:
u2022 Add selection by Sales group and Customer group
u2022 Add sort by: 3. Ship-to / Material
u2022 Add another selection box
[ ] Open Orders and Shipments with the current month
2) For the new selection box, subtotal sales quantity and delivery quantity.
If delivered, make the sales quantity zero in the subtotal
Current report displays, in Selection Screen
Sales org:
Person Name:
Material:
Plant:
Sales Office:
Ship to Name:
Ship to Number:
Sorts Report by : 1. Person Name 2. Material
Check Boxes : 1. Open Orders 2. Delayed Orders.
report zorder LINE-SIZE 170
LINE-COUNT 58
MESSAGE-ID zv
NO STANDARD PAGE HEADING.
TABLES:
cdhdr, "Change Doc Header
cdpos, "Change Doc Item
kna1, "Customer master
likp, "Delivery Header
lips, "Delivery Item
*lips, "Delivery Item
zvbpa_lfa1, "Vendor Master
makt, "Material Desc
t001w, "Plant
tvkbt, "Sales Office
tvko, "Sales Organizations
vbak, "Sales Header
vbap, "Sales Item
zvvbak, "Sales Hdr - Time calc
vbup, "Item status
vbep, "Sales Schedule Line
vbfa, "Flow documents
vbpa, "Partners
vbrk, "Billing Header
vbrp. "Billing Item
SELECT-OPTIONS:
s_vkorg FOR vbak-vkorg OBLIGATORY,
s_ernam FOR vbak-ernam,
s_matnr FOR vbap-matnr,
s_werks FOR vbap-werks,
s_vkbur FOR vbak-vkbur,
s_name1 FOR kna1-name1,
s_kunnr FOR kna1-kunnr.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(49) text-c20.
PARAMETERS: p_sort TYPE n DEFAULT '1'.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 19(40) text-022.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 19(40) text-023.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 19(40) text-024.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN COMMENT 19(40) text-070.
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF BLOCK b20 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:p_open AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(48) text-072.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS:p_delay AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(48) text-073.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b20.
DATA:
vbeln(11), "Document number
cancel_dt TYPE d, "Cancellation Date
BEGIN OF tabkey, "Tabkey
mandant LIKE sy-mandt,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
END OF tabkey,
name1_sp1 LIKE lfa1-name1, "Sales Carrier Name
name1_sp2 LIKE lfa1-name1, "Delivery Carrier Name
datum-1 TYPE d, "Current Dt Less 1
datum-14 TYPE d, "Current Dt Less 14
datum-90 TYPE d, "Current Dt Less 90
rpt_hdr1(170), "Report Header 1
rpt_hdr2(170), "Report Header 2
rpt_hdr3(170), "Report Header 3
cb_hdr1(170), "Control Break Header 1
line_pos1 TYPE i, "Line Print Position HDR1
line_pos2 TYPE i, "Line Print Position HDR2
line_pos3 TYPE i, "Line Print Position DET2
status, "Order Status
open, "Open Order
delayed VALUE 'D', "Delayed Order
v_comp(30). "Company Text Field
DATA: v_flagh2. " Flag for header 2 & 3
DATA: ls_comwa LIKE vbco6. "Structure for flow information
DATA: t_vbfa_tab TYPE STANDARD TABLE OF vbfa WITH HEADER LINE."Itab
for flow information
data: g_trans_id type vttk-tdlnr. "get transport id from flow
information
data v_sales_org_cpimex type vkorg value '3300'.
FIELD-GROUPS:
header,
order.
INSERT
status "Status
vbak-vkbur "Sales Office
vbak-ernam "Created By
kna1-kunnr "Customer
kna1-name1 "Customer Name
vbap-matnr "Material
vbap-werks "Plant
vbep-lddat "Load Dt
vbap-vbeln "Sales Document
INTO header.
INSERT
kna1-ort01 "City
kna1-regio "Region
likp-traid "Transport ID
lips-vbeln "Delivery Document
lips-ntgew "Net Wt
lips-gewei "Unit of Weight
vbap-kwmeng "Order Qty
vbap-vrkme "Sales Unit
vbak-bstnk "Customer PO
vbak-erdat "Sales Create Dt
vbak-ihrez "PO Release
vbak-vdatu "Req Delivery Dt
vbak-vzeit "Req Delivery Time
vbfa-vbeln "Goods issue doc
vbrk-vbeln "Billing Document
name1_sp1 "Sales Carrier
name1_sp2 "Delivery Carrier
INTO order.
INITIALIZATION.
AT SELECTION-SCREEN.
IF NOT p_sort BETWEEN 1 AND 2.
MESSAGE e022 WITH p_sort.
ENDIF.
* Report 1 or more of cancelled, delayed or open
IF p_open IS INITIAL AND
p_delay IS INITIAL.
MESSAGE e023.
ENDIF.
START-OF-SELECTION.
* Load Company Name
WRITE 'XYZ INC'(000) TO v_comp.
* Calculate Date Range
datum-1 = sy-datum - 1.
datum-14 = sy-datum - 14.
datum-90 = sy-datum - 90.
* Compose Parameter Header
PERFORM parm_hdr.
** Compose Report Header
v_flagh2 = 1.
PERFORM data_selection.
END-OF-SELECTION.
* Determine Sort
CASE p_sort.
WHEN 1.
SORT BY status vbak-ernam kna1-name1 kna1-kunnr
vbep-lddat vbap-vbeln.
WHEN 2.
SORT BY status vbap-matnr vbap-werks vbep-lddat
vbap-vbeln.
ENDCASE.
LOOP.
AT NEW status.
CASE status.
WHEN delayed.
WRITE 'Delayed Orders'(061) TO rpt_hdr1.
WHEN OTHERS.
WRITE 'Open Orders'(062) TO rpt_hdr1.
ENDCASE.
NEW-PAGE.
ENDAT.
AT NEW vbak-ernam.
IF p_sort = 1.
CLEAR cb_hdr1.
WRITE 'CAA:'(064) TO cb_hdr1.
WRITE vbak-ernam TO cb_hdr1+5.
NEW-PAGE.
ENDIF.
ENDAT.
AT NEW vbap-matnr.
IF p_sort = 2.
CLEAR makt.
SELECT SINGLE * FROM makt
WHERE spras = sy-langu AND
matnr = vbap-matnr.
CLEAR cb_hdr1.
WRITE 'Material:'(042) TO cb_hdr1.
WRITE vbap-matnr TO cb_hdr1+10.
WRITE makt-maktx TO cb_hdr1+21.
NEW-PAGE.
ENDIF.
ENDAT.
AT NEW vbap-werks.
AT order.
RESERVE 3 LINES.
SKIP 1.
NEW-LINE.
* Indicate new open item
WRITE vbap-vbeln TO vbeln.
* Find Transport ID
* Fill the structure LS_COMWA
ls_comwa-mandt = sy-mandt.
ls_comwa-vbeln = vbap-vbeln.
CALL FUNCTION 'RV_ORDER_FLOW_INFORMATION'
EXPORTING
comwa = ls_comwa
TABLES
vbfa_tab = t_vbfa_tab.
IF sy-subrc EQ 0.
READ TABLE t_vbfa_tab WITH KEY vbtyp_n = '8'.
IF sy-subrc EQ 0.
SELECT SINGLE tdlnr INTO g_trans_id
FROM vttk WHERE tknum = t_vbfa_tab-vbeln.
CONDENSE g_trans_id.
ENDIF.
ENDIF.
IF vbak-erdat >= datum-1.
vbeln+10 = 'N'.
ENDIF.
CASE p_sort.
WHEN 1.
WRITE 1 vbak-vkbur.
WRITE 8 kna1-name1.
WRITE 44 vbeln.
WRITE 56 vbap-matnr.
WRITE:
75 vbap-kwmeng LEFT-JUSTIFIED,
vbap-vrkme,
100 vbak-bstnk,
vbak-ihrez,
134 vbak-vdatu,
vbak-vzeit,
154 vbep-lddat.
WRITE 166 vbap-werks.
NEW-LINE.
WRITE:
5 kna1-ort01,
41 kna1-regio.
IF name1_sp2 IS INITIAL.
WRITE:
45 name1_sp1,
ELSE.
WRITE 45 name1_sp2.
IF name1_sp1 = name1_sp2.
WRITE ' '.
ELSE.
WRITE '*'.
ENDIF.
ENDIF.
IF vbak-vkorg = v_sales_org_cpimex .
WRITE 81 g_trans_id.
ELSE.
WRITE 81 likp-traid.
ENDIF.
WRITE:
102 lips-vbeln,
115 lips-ntgew NO-ZERO LEFT-JUSTIFIED,
lips-gewei,
140 vbfa-vbeln,
152 vbrk-vbeln.
WHEN 2.
WRITE 1 vbak-ernam.
WRITE 14 vbak-vkbur.
WRITE 21 kna1-name1.
WRITE 57 vbeln.
WRITE:
69 vbap-kwmeng LEFT-JUSTIFIED,
vbap-vrkme,
92 vbak-bstnk,
vbak-ihrez,
126 vbak-vdatu,
vbak-vzeit,
146 vbep-lddat.
WRITE 162 vbap-werks.
NEW-LINE.
WRITE:
5 kna1-ort01,
41 kna1-regio.
IF name1_sp2 IS INITIAL.
WRITE:
45 name1_sp1,
ELSE.
WRITE 45 name1_sp2.
IF name1_sp1 = name1_sp2.
WRITE ' '.
ELSE.
WRITE '*'.
ENDIF.
ENDIF.
IF vbak-vkorg = v_sales_org_cpimex .
WRITE 81 g_trans_id.
ELSE.
WRITE 81 likp-traid.
ENDIF.
WRITE:
102 lips-vbeln,
115 lips-ntgew NO-ZERO LEFT-JUSTIFIED,
lips-gewei,
140 vbfa-vbeln,
152 vbrk-vbeln.
ENDCASE.
ENDAT.
ENDLOOP.
* FORM PARM_HDR *
FORM parm_hdr.
WRITE 'Program selections'(101) TO rpt_hdr1.
WRITE 'Sign'(102) TO rpt_hdr1+29.
WRITE 'Option'(103) TO rpt_hdr1+34.
WRITE 'From'(104) TO rpt_hdr1+41.
WRITE 'To'(105) TO rpt_hdr1+77.
ENDFORM. "PARM_HDR
* FORM RPT_HDR *
FORM rpt_hdr.
CASE p_sort.
WHEN 1. "When sort by CAA
WRITE 1'SOff'(066).
WRITE 8'Customer'(009).
WRITE 44'Sales Doc'(010).
WRITE 56'Material'(031).
WRITE 75'Sales Qty'(011).
WRITE 100'Customer PO'(012).
WRITE 134'Req.Del.Dt & Tm'(014).
WRITE 154'Load Dt'(015).
WRITE 166'Plnt'(016).
NEW-LINE.
WRITE 5'City'(017).
WRITE 41'Reg'(069).
WRITE 45'Carrier'(018).
WRITE 81'Transport ID'(019).
WRITE 102'Dlvry Doc'(021).
WRITE 115'Dlvry Qty'(025).
WRITE 140'PGI Doc'(026).
WRITE 152'Billng Doc'(027).
WHEN 2. "When sort by Material
WRITE 1'Created By'(008).
WRITE 14'SOff'(066).
WRITE 21'Customer'(009).
WRITE 57'Sales Doc'(010).
WRITE 69'Sales Qty'(011).
WRITE 92'Customer PO'(012).
WRITE 126'Req.Del.Dt & Tm'(014).
WRITE 146'Load Dt'(015).
WRITE 162'Plnt'(016).
NEW-LINE.
WRITE 5'City'(017).
WRITE 41'Reg'(069).
WRITE 45'Carrier'(018).
WRITE 81'Transport ID'(019).
WRITE 102'Dlvry Doc'(021).
WRITE 115'Dlvry Qty'(025).
WRITE 140'PGI Doc'(026).
WRITE 152'Billng Doc'(027).
ENDCASE.
ENDFORM. "RPT_HDR
INCLUDE zrpthdri.
WRITE:
/ rpt_hdr1.
ULINE.
IF v_flagh2 <> 0.
PERFORM rpt_hdr. "Write secondary header
ULINE.
* Control Break Header
WRITE / cb_hdr1.
ENDIF.
Continued in Part-2
Thanks a ton in advance.
Mythili Sharma
Edited by: Mythili sharma on Mar 30, 2009 3:32 AM
Edited by: Rob Burbank on Mar 30, 2009 10:46 AMHello ABAP Experts,
I need your help to modify the following report with following requirement as I have least knowledge about the field-group concept. Thats is the reason, I am pasting the whole code. As it is part of our production requirement. I really appreciate your help, If its sent modifying the code required.
Modification required in the report.
To allow the sales representatives to see billed shipments and open orders for the current month.
1) Selection Screen Changes:
u2022 Add selection by Sales group and Customer group
u2022 Add sort by: 5. Ship-to / Material
u2022 Add another selection box
[ ] Open Orders and Shipments with the current month
2) For the new selection box, subtotal sales quantity and delivery quantity.
If delivered, make the sales quantity zero in the subtotal
Current report displays, in Selection Screen
Sales org:
Person Name:
Material:
Plant:
Sales Office:
Ship to Name:
Ship to Number:
Sorts Report by :
1. Person Name
2. Material
3. Plant
4. Sales Office
Check Boxes :
1. Open Orders
2. Delayed Orders
3.Cancelled Orders
PLEASE DOWNLOAD THE COMPLETE REPORT FROM THE FOLLOWING LINK
<< Link removed >>
It would be a great help, If the program is modified according to the requirement and snd it back through send space and send link, even if u send the necessary changes to be done in the report is also appreciable.
Thanks a ton in adanvce
Mythili
I wanted to close this thread as I could not put my question in a proper format. So please reply in the new thread which is posted.
Edited by: Mythili sharma on Mar 30, 2009 2:16 PM
Edited by: Rob Burbank on Mar 30, 2009 4:24 PM
Maybe you are looking for
-
how do i get my contacts back? they are backed up by i cloud but when I "MERGE" only the new ones are there and not the old ones
-
what kind of metrics do you need to monitor when it comes to capacity monitoring of exchange 2010? is it just the actual remaning disk space, or do you define thresholds for each element of exchange, i.e. mailbox database, public folder database, lo
-
Istopmotion. how can i change the frame rate in a project?
so i finally got istopmotion and i love it. its a bit tricky using the built in isight to grab shots but i am getting an external one. anywho, i was wondering if there is a way, once you have started working on a project, if you can change the framer
-
BAPI_GOODSMVT_CREATE Not working for Multiple materials
Hi, I am using BAPI_GOODSMVT_CREATE to post materials (same as t-code MB1A). I am populating Serial no for the materials having serialized profile it works fine if there is only one serialized profile material in the MRS. But if there is two material
-
How to install Adblock Plus in Gran Paradiso 3.0.4 [SOLVED]
Hi, I'm trying to install Adblock Plus in the version of Firefox I use which (for some licensing issue) identifies itself as Gran Paradiso 3.0.4. The Adblock plus version is 0.7.5.5. I've looked at the install.rdf for the xpi and it seems that Adblo