Sql parsing
Hello,
I have a data in a table as follows (sample)
SQL> select rownum, t from t;
ROWNUM T
1 Answer: b
Rationale: Seating should be 3-4 ft apart.
2 Answer – A
Rationale – xyz 500
The apex of the abcd.
3 Answers: A, B, D, E
4 Correct Answer: B
Rationale: XYZ p 4-5
5 Answer and rationale: C
6 Correct Answer:
B– a direction is best qualified
7 Correct Answer:
D – response asdf
8 Correct Answer: A – Is the first practice.
Rationale: xyzI am trying to write a function to parse out this string give back an out put just the answer
as the expecting output follows
SQL> select rownum,t from t1;
ROWNUM T
1 b
2 A
3 A, B, D, E
4 B
5 C
6 B
7 D
8 AI am doing all sample and putting case condition with substr and instr to get the value, but I think that there might be some efficient method to achieve this parsing.
Any help would be greatly appreciated.
Thanks,
Hi
user12236189 wrote:
Hello,
I have a data in a table as follows (sample)
SQL> select rownum, t from t;
ROWNUM T
1 Answer: b
Rationale: Seating should be 3-4 ft apart.
2 Answer – A
Rationale – xyz 500
The apex of the abcd.
3 Answers: A, B, D, E
4 Correct Answer: B
Rationale: XYZ p 4-5
5 Answer and rationale: C
6 Correct Answer:
B– a direction is best qualified
7 Correct Answer:
D – response asdf
8 Correct Answer: A – Is the first practice.
Rationale: xyz
Whenever you have a problem, post CREATE TABLE and INSERT statements for the sample data.
Always say which version of Oracle you're using.
I am trying to write a function to parse out this string give back an out put just the answer
as the expecting output follows
SQL> select rownum,t from t1;
ROWNUM T
1 b
2 A
3 A, B, D, E
4 B
5 C
6 B
7 D
8 A
How do you get those results from that data? Explain the rules that determine what the answers are, and someone will help you code them.
For example, are the answers all letters that do not appear right next to another letter in t? If so, then, in the row with ROWNUM=6, why is 'B' (which comes right before the letter â) included, but 'a' (which has spaces on either side of it) is not?
I am doing all sample and putting case condition with substr and instr to get the value, but I think that there might be some efficient method to achieve this parsing.Regular expressions might be helpful.
Similar Messages
-
Performance degradation in pl/sql parsing
We are trying to use xml pl/sql parser and noticed performance degradation as we run multiple times. We zeroed into the following clause:
doc := xmlparser.getDocument(p);
The first time the procedure is run the elapsed time at sqlplus is something like .45sec, but as we run repeatedly in the same session the elapsed time keeps on increasing by .02 seconds. If we log out and start fresh, we start again from .45sec.
We noticed similar degradation with
p := xmlparser.newParser;
but we got around by making the 'p' variable as package variable, initializing it once and using the same for all invocations.
Any suggestions?
Thank you.Can I enhance the PL/SQL code for better performance ? Probably you can enhance it.
or, is this OK to take so long to process these many rows? It should take a few minutes, not several hours.
But please provide some more details like your database version etc.
I suggest to TRACE the session that executes the PL/SQL code, with WAIT events, so you'll see where and on what time is spent, you'll identify your 'problem statements very quickly' (after you or your DBA have TKPROF'ed the trace file).
SQL> alter session set events '10046 trace name context forever, level 12';
SQL> execute your PL/SQL code here
SQL> exitWill give you a .trc file in your udump directory on the server.
http://www.oracle-base.com/articles/10g/SQLTrace10046TrcsessAndTkprof10g.php
Also this informative thread can give you more ideas:
HOW TO: Post a SQL statement tuning request - template posting
as well as doing a search on 10046 at AskTom, http://asktom.oracle.com will give you more examples.
and reading Oracle's Performance Tuning Guide: http://www.oracle.com/pls/db102/to_toc?pathname=server.102%2Fb14211%2Ftoc.htm&remark=portal+%28Getting+Started%29 -
Validating XML with PL/SQL parser
How can i validate a xml that is on a buffer with the grammar
stored in a BLOB column of o table? I'm using PL/SQL parser and
i can parse it correctly but i don't know how can i validate it
because my grammar is stored in DB.
nullAna Lucia (guest) wrote:
: How can i validate a xml that is on a buffer with the grammar
: stored in a BLOB column of o table? I'm using PL/SQL parser
and
: i can parse it correctly but i don't know how can i validate
it
: because my grammar is stored in DB.
You can't currently but this will be available in our next
release.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Logging errors in PL/SQL Parser
Using PL/SQL Parser, is it possible to obtain the parsing errors
output in other place than a file (ref: setErrorLog function)?
as varchar variables or kind?
nullM Leclair (guest) wrote:
: Using PL/SQL Parser, is it possible to obtain the parsing
errors
: output in other place than a file (ref: setErrorLog function)?
: as varchar variables or kind?
It is not possible at this time. It has been filed as an
enhancement request.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Does PL/SQL Parser Validate?
Just wondering if the PL/SQL parser can parse in validation mode?
I think I remember reading that the PL/SQL parser is a non-validating parser only but I didn't know if this changed.
Thanks for you helpI am also experiencing problems with the setDocumentType
This is my code
p := xmlparser.newParser;
xmlparser.parseBuffer(p,'<My_Data/>');
doc := xmlparser.getDocument(p);
docNode := xmldom.makeNode(doc);
xmldom.setVersion(doc, '1.0');
OuterNode := xmldom.getLastChild(docNode);
--Get DTD to parse against
xmlparser.setValidationMode(p,TRUE);
xmlparser.parseDTD(p,'c:\temp\v109.dtd','My_Data');
--Set DTD to validate against
docType := xmlparser.getDoctype(p);
xmlparser.setDoctype(p,docType);
xmlparser.freeParser(p);
The problem I am having is that the output now looks like this
<?xml version="1.0" encoding="UTF-8"?>
<My_Data>
</My_Data>
<!DOCTYPE My_Data SYSTEM "file:/c:/temp/v109.dtd">
The xmlparser.parseDTD requires as the third parameter the root element so the !DOCTYPE field comes after the root element and not before as required.
Hope this code helps a bit and if you solve the problem please let me know
Owen
null -
Hi,
I am developing a logging framework, where applications which are initiating PL/SQL transactions also log the same using our framework. The reason being, the application owner can then analyze data from these logs. I was wondering whether there is something in existence like the "General SQL Parser" for a linux based c++ component, so that we can parse the PL/SQL blocks and represent the data in a certain format.
Are there any ORACLE libraries that I can use, which would work with PYTHON or any other scripting languages and parse the PL/SQLs albeit out of the scope of the ORACLE DB itself.
Do let me know,
cheers,
jagsOur logging framework is a generic c++ framework, where applications have a 2 stage approach
1) Execute the SQL transaction to their DB host.
2) The same SQL transaction is then logged to our framework (non DB), we then generate reports on these SQL transactions.
We are already handling parsing the log data for the SQL commands but need something for the PL/SQL blocks. -
Hi,
I have to create a parser for PL/SQL 8i.
Any help on what to start with would be very helpful.
I hope to use the EBNF rules for the parsing. Am I in the right direction?
Are there any open source code for PL/SQL parser ?
Thanks & Regards
Aswin AsokanHi,
I have to create a parser for PL/SQL 8i.
Any help on what to start with would be very helpful.
I hope to use the EBNF rules for the parsing. Am I in the right direction?
Are there any open source code for PL/SQL parser ?
Thanks & Regards
Aswin Asokan The direction is right as far as I know but the task
is really difficult. PL/SQL's syntax is inherited
from ADA language which is BIG one and very complex to parse.
And there is SQL part as well. Just look at the
market - so few products are based on this kind
of parser (PL/SQL) - as I can guess.
For example:
Formatter Plus (www.quest.com),
ClearSQL (www.clearsql.com),
CAST PL/SQL Analyzer (www.castsoftware.com),
LECCO SQL Expert for Oracle (www.leccotech.com ) - as I can assume but I'm not sure.
Probably you may search the net for a little subset of this
parser - for ANSI SQL or for ADA to start with. -
PL/SQL parser for 7.3 DB?
We have an ORACLE 7.3 DB and are looking for a PL/SQL parser for XML... Some of the posts I've seen seem to suggest that a solution exists, but I'm not having any luck finding out for sure...
Thanks,
Jeffhttp://technet.oracle.com/tech/xml/info/index2.htm?Info&plsxml/xml4plsql.htm
-
Hi,
just came across a strange PL/SQL parser behavior. Why is the following PL/SQL code valid?
DECLARE
vEmpNo NUMBER;
BEGIN
FOR rEMP IN
( SELECT EMPNO
INTO vEmpNo
FROM EMP
LOOP
dbms_output.put_line('Value: '||vEmpNo);
END LOOP;
END;The "INTO vEmpno" doesn't make much sense, but it's successfully compiled and executed.
Database version is 10.2.0.3.0
Any idea?
Patrick
My APEX Blog: http://www.inside-oracle-apex.com/
The APEX Builder Plugin: http://builderplugin.oracleapex.info/
The ApexLib Framework: http://apexlib.sourceforge.net/the pl/sql manual gives the syntax of a cursor for loop as
cursor_for_loop_statement ::=
[<< label_name >>] FOR record_name IN
{cursor_name [(cursor_parameter_name
[, cursor_parameter_name]...,)]
| (select_statement)}
LOOP statement [statement]...
END LOOP [label_name];and the pl/sql manual defines a "select into" as
"The SELECT INTO statement retrieves data from one or more database tables, and assigns the selected values to variables or collections. For a full description of the SELECT SQL statement, see Oracle Database SQL Reference."
and it also says
"Selecting At Most One Row: SELECT INTO Statement
If you expect a query to only return one row, you can write a regular SQL SELECT statement with an additional INTO clause specifying the PL/SQL variable to hold the result."
so, if pl/sql feels that the INTO is just another clause to a regular select statement, and cursor-for-loops work on select statements, then there is no problem. huh?????
guess in a similar way to v8 pl/sql allowing select of booleans, it just ignores that clause. but since it isn't explicitly stated as being allowed, we can hope that oracle will eventually notice and get rid of it. -
PL/SQL parser installation error
I tried to install the XML PL/SQL parser against Oracle 8.1.6 with JServer Release 8.1.6.0.0 and I received a large number of errors about invalid column names including the following:
Error while resolving class oracle/xml/parser/v2/FromDescendantAttributes
ORA-00904: invalid column name
Error while resolving class oracle/xml/parser/v2/XSLNode
ORA-00904: invalid column name
Error while resolving class oracle/xml/parser/v2/UnaryExpr
ORA-00904: invalid column name
Any suggestions?
ThanksHi Steven:
Yep...I just checked our install and there are no java classes in user_objects. We had the init*.ora file shared_pool_size set too low (as indicated under $ORACLE_HOME/javavm/doc/readme.txt).
So I'll get our DBA to try it again.
Thanks,
Derek
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
This likely means that the database JavaVM is not properly installed in your Oracle8i database. You need to run the initjvm.sql script as detailed in the JServer documentation before any 'loadjava'
commands will work.<HR></BLOCKQUOTE>
null -
Sybase ESP java sdk, SQL parser exception for all queries
Hi,
I am new to Sybase ESP java sdk. Trying to use sdk projection subscription, but getting for all the queries including blank string:-
com.sybase.esp.sdk.exception.ProjectErrorException: SQL parsing error
at com.sybase.esp.sdk.impl.SubscriberImplV3.doSubscribe(Unknown Source)
at com.sybase.esp.sdk.impl.SubscriberImpl.subscribeSql(Unknown Source)
My Example code :-
Credentials creds = new Credentials.Builder(Credentials.Type.USER_PASSWORD).setUser("user").setPassword("pwd").create();
Project project = s_sdk.getProject(uri, creds);
project.connect(WAIT_TIME_60000_MS);
Subscriber subscriber = project.createSubscriber();
//subscriber.subscribeStream("Trades");
subscriber.connect();
subscriber.subscribeSql("select UserMaxCpu from wSBW912");
I am new to sdk and not sure what I am doing wrong here, please suggest.
Thanks,
VenkateshThe problem you're experiencing is due to your JNDI configuration not matching the JavaDB database where you created the tables.
If you look at the config for DerbyPool in the Admin Console, you'll see that DerbyPool points to:
jdbc:derby://localhost:1527/sun-appserv-samples
In the Admin Console click Resources->Connection Pools->DerbyPool, then click Additional Properties (9.1) or look at the page (9.0).
You can either modify DerbyPool's config to point to:
jdbc:derby://localhost:1527/BookDB
Or you can create the tables in sun-appserv-samples. The create-tables ant task included with the Java EE 5 Tutorial will create the tables in the correct database.
-ian -
SQL Parser supporting nested queries
Hi,
I require a SQL parser that supprt nested queries. JavaCC doesnt support nested queries so that one is out. If anyone knows of any open sourse parser, please enlighten me. I have already looked enough on Google but not of much use.
thanks,
abulkd| 1. as suggested , i was able to get the oraclexmlsql.jar
| from the servlet zip and loading it solved the problem of
| the jdbc string being printed int he cursor syntax . it
| works from the xmlgen utility withing pl/sql. but when
| using OracleXML in a java prog the results still printout
| the jdbc string.. any ideas...
Could only be a CLASSPATH problem difference in your two
tests.
| 2. Is there anyway to supress the rownum attribute tag in
| the subquery (cursor) results...that is the
| setRowIdAttrName .... w/o using xslt
Not at this time. Rownum supression on the subquery should
probably follow your settings on the main query. I'll
suggest to the devs.
| 3. We are implementing a solution using these tools.... we
| wanted to know which were the production versions.
XDK Components for XML and XSLT are production.
XML SQL Utility and XSQL Servlet are still Technical
Previews and as such are not yet production.
null -
We are running htmldb 1.5. We have an application running without problems on the development server. When we export the application and then import it on another server (QA or Production) we sometimes get the following errors in report regions that are retrieving data based on a page item:
failed to parse SQL query:
ORA-06502: PL/SQL: numeric or value error: NULL index table key value
The form with the page item is displaying the value for the item, but the reports based on the page item fail. If we go into the htmldb development environment and edit the page for viewing purposes, the problem appears to disappear from that point on. We do not make any changes to the page.
Is there a problem with the export/import process? Is there a way to make sure the page item has the value expected? We are using DML processing to fetch the record for the page. The fetch occurs 'After the Header'. Should the fetch be 'Before the Header'. Should we force a computation that reads the value into the page item again? If so, at what point?
Usually we invoke the page and set the page item values with a url that looks like:
f?p=&APP_ID.:510:#APP_SESSION#:UPDATE::510:P510_CLASS_ID:#CLASS_ID#
Thanks for your help,
PeterM Leclair (guest) wrote:
: Using PL/SQL Parser, is it possible to obtain the parsing
errors
: output in other place than a file (ref: setErrorLog function)?
: as varchar variables or kind?
It is not possible at this time. It has been filed as an
enhancement request.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
null -
Hello!
I'm developing a package that gets all the dependencies between the objects from a schema and since the table all_dependencies doesn't provide all the information needed (not enough detail), I thougth on making a pl/sql parser. Then I found Oracle Text, and I would like to now if will this feature have the capabily to help me in this task. If not, can someone indicate me some other oracle solution?
ThanksI'm working in windows 2000 professional 5.00.2195 and using Pl/SQL Developer version 7.1.1 and oracle 9i Enterprise Edition Release 9.2.0.7.
What I really want is, for exemple, instead of the objects related to a package, I wanna now to witch procedure or function in that package that object is related to. Also, when I have a dependency with a table, I wanna now if that procedure/function only writes or only reads (or both) on the table.
I hope I have made myself clear :)
Thank you -
Hi,
The Format SQL parser (up to latest 14.67) seems to have problems with certain characters (íìóò...), even though they're inside comments:
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
stop here
line 75:25: unexpected char: 0xF3
at oracle.dbtools.formatter.parser.PLSQLLexer.nextToken(PLSQLLexer.java:
773)
at oracle.dbtools.formatter.parser.PLSQLLexer.getNextToken(PLSQLLexer.ja
va:72)
at oracle.dbtools.formatter.PrettyPLSQL.format(PrettyPLSQL.java:66)
at oracle.dbtools.formatter.PrettyPLSQL.format(PrettyPLSQL.java:25)
at oracle.dbtools.sqlformatter.SQLFormatCommand.formatSQL(SQLFormatComma
nd.java:338)
at oracle.dbtools.sqlformatter.SQLFormatCommand.doit(SQLFormatCommand.ja
va:92)
at oracle.ide.controller.CommandProcessor$UndoStack.executeCommand(Comma
ndProcessor.java:819)
at oracle.ide.controller.CommandProcessor$UndoStack.doit(CommandProcesso
r.java:715)
at oracle.ide.controller.CommandProcessor$MasterStack.doit(CommandProces
sor.java:1004)
at oracle.ide.controller.CommandProcessor.invoke(CommandProcessor.java:1
78)
at oracle.dbtools.sqlformatter.SQLFormatter.executeCommand(SQLFormatter.
java:131)
at oracle.dbtools.sqlformatter.SQLFormatter.invoke(SQLFormatter.java:120
at oracle.dbtools.sqlformatter.SQLFormatter.handleEvent(SQLFormatter.jav
a:192)
at oracle.ide.controller.IdeAction.performAction(IdeAction.java:530)
at oracle.ide.controller.IdeAction$1.run(IdeAction.java:785)
at oracle.ide.controller.IdeAction.actionPerformedImpl(IdeAction.java:80
4)
at oracle.ide.controller.IdeAction.actionPerformed(IdeAction.java:499)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
49)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1
000)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMen
uItemUI.java:1041)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
I tried to evade the bug by making a selection of what I want to format, but the parser always starts at the beginning of the code. It's pretty incoherent that you make a selection, right-click on it for context-sensitive options, but then get results on the whole document. I would name it a bug: either disable (gray out) the functionality when there's a selection (indicating that's not supported right now), or do what the user expects to be done.
Could you please fix the parser bug and implement the selection-wise format feature?
TIA,
K.Barry,
Originally, I wanted to format a package made in another editor, having the indents horribly aligned.
The error I got is the one I mentioned: the 'ó' character inside a '--' comment.
Then I tried formatting only a selection of text, which also fails, as mentioned.
You can reproduce also in the SQL worksheet, also with other accentuated chars, and even in string values. For instance, try to format 'sELeCT 'testó' fROm DuaL;'.
Failing to format is probably a parser bug.
Formatting the whole pane instead of just the selected range of text is a flaw in application logic. If it's too hard to implement (or it gets low prio so it never gets fixed), I suggest disabling the entry when having made a selection. This would prevent the possibility of screwing up code when not being asked for.
Thanks for your interest!
K. -
PL/SQL + Parser: CLOB/Encoding
I'm traying to create my XML document in PL/SQL but the method
setCharset('ISO-8859-1')
does not work and is ignored. it works only with
setCharset('UTF8').
Does anybody know why??? Is this a bug??
There is also another issue:
We're using the Oracle XML Parser for PLSQL 1.0.2.0.0 on a Windows NT platform.
We're using the very latest available version of Oracle8i and Java.
When using the xmldom.WriteToCLOB procedure most of the non-US ASCII characters gets
converted to an inverterted question-mark.
When we use xmldom.WriteToFile the file contents are correct
(i.e. shows all ISO-8859-1 characters correctly on the NT platform).
Is it a bug in WriteToCLOB? If yes, is there any chance that it will be fixed, shortly??1/ we have filed a bug for your first question.
2/ for you second question, we have notice our limitation on current pl/sql API.
This mostly because of CLOB limitation:
As we known, the character repertoire of CLOB is limited by the database character set. This limitation may cause data loss if the database character set wasn't UTF8.
Please just ignore this API. In future release, we will accept new datatype "xmlobject". This will solve this problem.
Thanks for point out this problem.
Maybe you are looking for
-
Can't get new backup past the starting gate
After fouling up my first backup since upgrading to Snow Leopard (http://discussions.apple.com/message.jspa?messageID=12245539#12245539), I've reset TM (twice) and reformatted my backup drive (with a single pass of zeroes). But, I cannot get the back
-
Smart Objects in CS4 not opening correctly
I am experiencing a problem in CS4 at work that is giving some trouble. First off, I'm running a quad core, Mac Pro running Snow Leopard with 3GB of RAM. Here is my issue. If I have an existing Photoshop document with a placed EPS Smart Object file (
-
Hoe to read attachments of type MESSAGE/RFC822
hi, How to read attachments in mails of type MESSAGE/RFC822 this occurs when somebody puts "Forwarded mails" directly as an attachment inside the mail body itself.. guyz ur help for this will be very much helpful.. thanks sriram.B
-
Can i use the debit card details for payment in the itunes store
can i use the debit card details for payment in the itunes store
-
Using set operations (subqueries) with cursors
If would need the following statement fe.: select * from A where attr1 in (select attr3 from B where ...); and the substatement select att3... is very complex and i want to do it only once. Is it possible to use it as a cursor: open C0 for select att