WELCOME, GUEST
Minimize
Blogger List

Steven Feuerstein Indicates Oracle ACE director status
PL/SQL Obsession

Guy Harrison Indicates Oracle ACE status
Database topics

Bert Scalzo Indicates Oracle ACE status
Toad for Oracle, Data Modeling, Benchmarking
Dan Hotka Indicates Oracle ACE director status
SQL Tuning & PL/SQL Tips

Valentin Baev
It's all about Toad

Ben Boise
Toad SC Discussions

Dan Clamage
SQL and PL/SQL

Kevin Dalton
Benchmark Factory

Peter Evans 
Business Intelligence, Data Integration, Cloud and Big Data

Vaclav Frolik  
Toad Data Modeler, Toad Extension for Eclipse

Devin Gallagher
Toad SC discussions

Stuart Hodgins
JProbe Discussions

Julie Hyman
Toad for Data Analysts

  Henrik "Mauritz" Johnson
Toad Tips & Tricks on the "other" Toads
  Mark Kurtz
Toad SC discussions
Daniel Norwood
Tips & Tricks on Toad Solutions
Amit Parikh
Toad for Oracle, Benchmark Factory,Quest Backup Reporter
Debbie Peabody
Toad Data Point
Gary Piper
Toad Reports Manager
John Pocknell
Toad Solutions
Jeff Podlasek
Toad for DB2
Kuljit Sangha
Toad SC discussions
Michael Sass 
Toad for DB2
Brad Wulf
Toad SC discussions
Richard To
SQL Optimization
  Toad Data Modeler Opens in a new window
Data Modeling
 
  Toad Higher Education
How Hi-Ed Uses Toad
  Real Automated Code Testing for Oracle
Quest Code Tester blog
  中文技术资料库
技术文章
 

Blogs

Toad World blogs are a mix of insightful how-tos from Quest experts as well as their commentary on experiences with new database technologies.  Have some views of your own to share?  Post your comments!  Note:  Comments are restricted to registered Toad World users.

Do you have a topic that you'd like discussed?  We'd love to hear from you.  Send us your idea for a blog topic.


Mar 15

Written by: StevenFeuersteinTW
Tuesday, March 15, 2011 11:35 AM  RssIcon

I discovered something curious today. Check out the following block; it runs without any compilation or runtime error:
DECLARE
   l_char   CHAR (1);

   CURSOR x
   IS
      SELECT dummy INTO l_char FROM DUAL;
BEGIN
   OPEN x;

   FETCH x INTO l_char;

   CLOSE x;
END;
 
Can anyone see why I find it odd and curious? I have sent a note to the PL/SQL Product Manager asking what he thinks. What do you think?
 
Cheers, Steven

4 comment(s) so far...


Gravatar

Re: Curious PL/SQL Code

The strange thing is that you define an into clause in the cursor. It doesn;t do anything though, but the variable you use MUST be declared or the code will not compile.
I think it is odd that you would even try this ;-). I think the PL/SQL Engine removes the into clause from the cursor, but the compiler doesn't. That is odd. IMHO either they should both use it, or both ignore it.
Kindest regards,
Patrick Barel

By Patch on   Wednesday, March 16, 2011 6:21 AM
Gravatar

Re: Curious PL/SQL Code

In terms of it being odd that I would try this, that's easy: I didn't "try" it, I cut-and-pasted it. I had an implicit query in my executable section and needed to switch to an implicit cursor. So I moved the cursor up there, compiled and then noticed the INTO clause.

I checked in with Bryn Llewellyn, PL/SQL Product Manager, and he had this to say:

===========================================
Remember the golden rule: try something in SQL (via SQL*Plus) before assuming that you're seeing a PL/SQL curiosity.

So you might have said that this SQL statement:

select 'Curiosity' "?" into :b from Dual

runs without error in SQL*Plus, and prints out this:

?
---------
Curiosity

To which I'd've said this:

Yes, odd isn't it? But this is an example of an embedded SQL statement. See this extract from 11.2 SQL Language Reference (in the section Types of SQL Statements):

>

In other words, the into is syntactically legal but has no effect when submitted as an ordinary SQL statement. And of course, this is what the PL/SQL compiler does on your behalf when it parses the cursor statement.

Like many things, there must have been a reason for allowing this, taken by people who are no longer with us; but it's too late to change it now.
===========================================

Thanks, Bryn!

By StevenFeuersteinTW on   Wednesday, March 16, 2011 8:09 AM
Gravatar

Re: Curious PL/SQL Code

Hi,

It's not related to this code though, I wanted to ask, some time back you developed Qute for PL/SQL code unit testing. Did you discontinue the product or was it renamed to something else. I could find URL for Qute, and neither am I able to find any discontinuation news from you...

By Muscle on   Sunday, March 20, 2011 3:10 PM
Gravatar

Re: Curious PL/SQL Code

Yep, not related at all, but that's OK! :-) Qute the caterpillar has transformed itself into an amazing and wonderful butterfly named Quest Code Tester for Oracle.

That is, the automated testing tool for PL/SQL now sold by Quest is dramatically better and more powerful than that early incarnation (Qute).

Check it out - I am certain you will be impressed by all it can do for you.

SF

By StevenFeuersteinTW on   Monday, March 21, 2011 5:08 AM
Search Blog Entries
 
Blog Archives
 
Archive
<May 2013>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Monthly
May, 2013 (11)
April, 2013 (13)
March, 2013 (10)
February, 2013 (5)
January, 2013 (7)
December, 2012 (6)
November, 2012 (10)
October, 2012 (8)
September, 2012 (6)
August, 2012 (8)
July, 2012 (8)
June, 2012 (12)
May, 2012 (21)
April, 2012 (10)
March, 2012 (16)
February, 2012 (19)
January, 2012 (20)
December, 2011 (19)
November, 2011 (14)
October, 2011 (12)
September, 2011 (17)
August, 2011 (15)
July, 2011 (16)
June, 2011 (13)
May, 2011 (15)
April, 2011 (8)
March, 2011 (21)
February, 2011 (17)
January, 2011 (16)
December, 2010 (13)
November, 2010 (13)
October, 2010 (7)
September, 2010 (15)
August, 2010 (11)
July, 2010 (13)
June, 2010 (12)
May, 2010 (14)
April, 2010 (12)
March, 2010 (13)
February, 2010 (12)
January, 2010 (7)
December, 2009 (10)
November, 2009 (12)
October, 2009 (15)
September, 2009 (18)
August, 2009 (13)
July, 2009 (23)
June, 2009 (14)
May, 2009 (17)
April, 2009 (7)
March, 2009 (14)
February, 2009 (7)
January, 2009 (12)
December, 2008 (7)
November, 2008 (11)
October, 2008 (19)
September, 2008 (14)
August, 2008 (11)
July, 2008 (14)
June, 2008 (19)
May, 2008 (12)
April, 2008 (18)
March, 2008 (13)
February, 2008 (8)
January, 2008 (7)
December, 2007 (5)
November, 2007 (8)
October, 2007 (13)
September, 2007 (13)
August, 2007 (16)
July, 2007 (11)
June, 2007 (6)
May, 2007 (5)
April, 2007 (5)
March, 2007 (8)
February, 2007 (6)
January, 2007 (6)
December, 2006 (5)
November, 2006 (8)
October, 2006 (4)
August, 2006 (3)