This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,831 Users
  • 2,269,775 Discussions
  • 7,916,823 Comments

Discussions

*_SOURCE metadata views to indicate comments in the text field

Manik
Manik Technical SpecialistSingaporeMember Posts: 2,908 Gold Trophy
edited Jun 4, 2018 5:35AM in Database Ideas - Ideas

Hi all,

Just a thought if Oracle can provide an additional column in *_source metadata views to indicate if that particular line is a comment or not..

e.g.:

As you see below the string "Can this be ......." is within enclosed comments. Would it be better to show that this is commented line..

pastedImage_1.png

Some check flag like this if provided by oracle it would be very easy to filter out those lines which we search for some string within code base.

pastedImage_2.png

Comments welcome!

Cheers,

Manik.

ManikGregV
4 votes

Active · Last Updated

Comments

  • William Robertson
    William Robertson London, UKMember Posts: 9,579 Bronze Crown

    A lot of lines will be part comment, so I'm not sure this will be very useful. If you are searching source code for references to chk_this excluding comment lines, you will still find it in

    new_thing();  <em>-- Similar to chk_this but for bananas</em>

    and so on.

  • Manik
    Manik Technical Specialist SingaporeMember Posts: 2,908 Gold Trophy

    A lot of lines will be part comment, so I'm not sure this will be very useful. If you are searching source code for references to chk_this excluding comment lines, you will still find it in

    new_thing();  <em>-- Similar to chk_this but for bananas</em>

    and so on.

    Hi., firstly thanks for your comment. I agree that there are lot of possibilities to present the comment situations.

    One of the other possibilities can be as depicted below as well.

    pastedImage_0.png

    My intention is just to start something in the lines of classifying commented text. where its a "complete" comment. like the one stated in the original question.

    May be oracle can convert your example as : (observe line number does not add up because of the comment.)

    Line number      text                                        Comment_flag   

    10               new_thing();                                'N'

    <em>-10              -- Similar to chk_this but for bananas      'Y'</em>

    ------------------------------------------

    And second example may be transformed as:

    -------------------------------

    Line Number                    text                                                comment_flag

    10                                    begin                                              'N'

    11                                    new_thing(a,b                                'N'

    -11                                    /* this is optional parameter */       'Y'

    11                                     ,c);                                                  'N'

    12                                     end;                                                 'N'

    Again this is just a thought.. Comments welcome !

    Cheers,

    Manik.

  • Mike Kutz
    Mike Kutz Member Posts: 6,317 Gold Crown

    Hi., firstly thanks for your comment. I agree that there are lot of possibilities to present the comment situations.

    One of the other possibilities can be as depicted below as well.

    pastedImage_0.png

    My intention is just to start something in the lines of classifying commented text. where its a "complete" comment. like the one stated in the original question.

    May be oracle can convert your example as : (observe line number does not add up because of the comment.)

    Line number      text                                        Comment_flag   

    10               new_thing();                                'N'

    <em>-10              -- Similar to chk_this but for bananas      'Y'</em>

    ------------------------------------------

    And second example may be transformed as:

    -------------------------------

    Line Number                    text                                                comment_flag

    10                                    begin                                              'N'

    11                                    new_thing(a,b                                'N'

    -11                                    /* this is optional parameter */       'Y'

    11                                     ,c);                                                  'N'

    12                                     end;                                                 'N'

    Again this is just a thought.. Comments welcome !

    Cheers,

    Manik.

    I'm still not understanding why you want to know if LINE 5 is a comment line or not.

    Personally, I would prefer some way (dbms package? XML_COMMENTS field? ) to extract the PL/Doc style comments so I can create something with that information.

    I feel that knowing "Line 5 is a comment" is useless.

    Knowing the PL/Doc comment for "function LETS_KILL_THE_DBA return int" states that the function "orders a pizza using the DBA's CC" would be more useful.

    MK

  • BEDE
    BEDE Oracle Developer Bucharest, RomaniaMember Posts: 2,484 Gold Trophy

    I think that if you select * from all_source where lower(text) like '%x_type%' you would like to know if that x_type does not happen to be found in a comment and is actually used by the procedure. Isn't that it? Kind-of eliminating dead code and finding where some object is referenced in code.

    Manik
  • Manik
    Manik Technical Specialist SingaporeMember Posts: 2,908 Gold Trophy

    I think that if you select * from all_source where lower(text) like '%x_type%' you would like to know if that x_type does not happen to be found in a comment and is actually used by the procedure. Isn't that it? Kind-of eliminating dead code and finding where some object is referenced in code.

    Unfortunately the whole thing is made into lower or upper like this :

    pastedImage_0.png

    Cheers,

    Manik.

  • BEDE
    BEDE Oracle Developer Bucharest, RomaniaMember Posts: 2,484 Gold Trophy
    edited Jun 6, 2018 4:15AM

    Pondering deeper on the subject, I think this is the most difficult way to put things. So, to see if that is part of a comment or not, that would mean loading the whole stored program unit in memory and having it compiled and also having somehow indications that a referred object is found on certain lines.

    A better way to put it would be: if there could be some say pipelined function that would return all the program units that refer some database object or stored program (like refer a package or type or package.procedure or type.method or type.attribute).

    Wouldn't this look like being more feasible?

    And things get really tricky if some program units contain dynamic SQL. Then, it would be even more difficult to determine where some object is referred. I don't think there would be a complete solution to this kind of problem and I guess using dba_dependencies will have to suffice for quite a long time.

    Manik