Reuse a piece of code in SQL?

I have a big SQL. And inside it, there is a piece of sub-query appear twice. So rather than writing the sub-query twice in the big SQL, I hope to reuse the sub-query in the "big SQL", i.e., is it possible that I only write it when it first appears, and when it appears again in the other places in the same big SQL, I only need to refer to it rather than re-write the whole sub-query once again? Hope the above does not confuse you. Thanks!

This is a nonsensical example of the WITH clause but should give you an idea of the syntax. I've created 2 subqueries (my_tabs, my_objs). Once they're given a name, they can be used in a statement anywhere where you would use a table (or subquery). You can use them multiple times, but they can't be correlated subqueries. They have to be 'stand alone'.
WITH
my_tabs AS (SELECT table_name FROM user_tables)
,my_objs AS (SELECT object_name FROM user_objects)
SELECT *
FROM my_tabs
    ,my_objs
WHERE my_tabs.table_name = my_objs.object_name
;

Similar Messages

  • Why won't this piece of code work?

    Hello all, i am new to HTML and web design and i'm trying to make a website. I created this piece of code so that when the user mouses over one of the links (jpg image) it will change colors ( i have the same image in different color scheme saved in the same folder).
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>XXXXXXXXXX</title>
    </head>
    <body bgcolor="#000000">
    <table width="1050" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="1050" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><img src="_images/XXXXbanner.jpg" width="1050" height="311" alt="banner" /></td>
          </tr>
        </table>
          <table width="901" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="150"><a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonOne','','_images/home_on.jpg',1)">
                 <img name="ButtonOne" border="0" src="_images/home.jpg" width="150" height="75" alt="home" /></a></td>
              <td width="150"><a href="gallery.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonTwo','','_images/gallery_on.jpg',1)">
                  <img name="ButtonTwo" border="0" src="_images/gallery.jpg" width="150" height="75" alt="gallery" /></a></td>
              <td width="150"><a href="products.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonThree','','_images/product_on.jpg',1)">
                 <img name="ButtonThree" border="0" src="_images/product.jpg" width="150" height="75" alt="products" /></a></td>
              <td width="150"><a href="store.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonFour','','_images/shop_on.jpg',1)">
                 <img name="ButtonFour" border="0" src="_images/shop.jpg" width="150" height="75" alt="store" /></a></td>
              <td width="150"><a href="profile.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonFive','','_images/profile_on.jpg',1)">
                 <img name="ButtonFive" border="0" src="_images/profile.jpg" width="150" height="75" alt="profile" /></a></td>
              <td width="151"><a href="contactus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('ButtonSix','','_images/contact_us_on.jpg',1)">
              <img name="ButtonSix" border="0" src="_images/contact_us.jpg" width="150" height="75" alt="contact" /></a></td>
            </tr>
          </table>
          <table width="1050" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td> </td>
              <td> </td>
              <td> </td>
            </tr>
          </table>
          <p> </p>
        <p> </p></td>
      </tr>
    </table>
    </body>
    </html>
    the images and banner are showing up fine and i havent mistpyed any of the locations/file names. why doesn't the icon change colors (display the "on" image) when u hover the mouse over it? please help thanks in advance.
    ** i'm using Adobe Dreamweaver CS4

    He's right...
    try instering this into the head tags of your html
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    //-->
    </script>

  • How to have the name of code PL/SQL

    I make a generique tools for logging in PL/SQL : http://log4plsql.sourceforge.net/
    1. how to have the name of the code PL/SQL which is run ?
    2. how have a pl/sql call stack dynamically ?
    proc1 -> proc2 -> package1.proc3

    For 2, check if DBMS_UTILITY.FORMAT_CALL_STACK will work for you:
    http://tahiti.oracle.com/pls/db901/db901.tabbed?section=32613
    For 1, is there anything in DBMS_DEBUG that would help?
    http://otn.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_deb.htm#1015019

  • Change the mapping generation code from sql*loader to pl/sql

    I want to use a mapping with a flat file operator to generate pl/sql code even if a mapping generate sql*loader code as default.
    I tried to change the Language generation property of the mapping but an API8548 error message is shown. The suggested solution by OWB is to change the language generation code in the property inspector of the mapping.
    I can't use external table because I have to work with a remote machine.
    What i have to do to change the generation code from SQL*Loader to PL/SQL?

    How about breaking this out into 2 mappings? In the first mapping, map a flat file operator to an table using SQL*Loader code. Then define a second mapping using the table as source and therefore generate PL/SQL. Then use process flow to launch the 2nd map to run after completion of first.

  • Re-Write the Node-DOM code with SQL-XML funtions

    Hi Friends,
    Could you please help in re-writing the below code using SQl-XML functions
    DECLARE
    l_domdoc dbms_xmldom.DOMDocument;
    l_xmltype XMLTYPE;
    l_root_node dbms_xmldom.DOMNode;
    l_departments_node dbms_xmldom.DOMNode;
    l_dept_element dbms_xmldom.DOMElement;
    l_dept_node dbms_xmldom.DOMNode;
    l_name_node dbms_xmldom.DOMNode;
    l_name_textnode dbms_xmldom.DOMNode;
    l_location_node dbms_xmldom.DOMNode;
    l_location_textnode dbms_xmldom.DOMNode;
    l_employees_node dbms_xmldom.DOMNode;
    l_emp_element dbms_xmldom.DOMElement;
    l_emp_node dbms_xmldom.DOMNode;
    l_emp_first_name_node dbms_xmldom.DOMNode;
    l_emp_first_name_textnode dbms_xmldom.DOMNode;
    l_emp_last_name_node dbms_xmldom.DOMNode;
    l_emp_last_name_textnode dbms_xmldom.DOMNode;
    BEGIN
    -- Create an empty XML document
    l_domdoc := dbms_xmldom.newDomDocument;
    -- Create a root node
    l_root_node := dbms_xmldom.makeNode(l_domdoc);
    -- Create a new node Departments and add it to the root node
    l_departments_node := dbms_xmldom.appendChild( l_root_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Deptartments' ))
    FOR r_dept IN (SELECT dept.department_id
    , dept.department_name
    , loc.city
    FROM departments dept
    JOIN locations loc
    ON loc.location_id = dept.location_id
    WHERE dept.department_id IN (10,20)
    LOOP
    -- For each record, create a new Dept element with the Department ID as attribute.
    -- and add this new Dept element to the Departments node
    l_dept_element := dbms_xmldom.createElement(l_domdoc, 'Dept' );
    dbms_xmldom.setAttribute(l_dept_element, 'Deptno', r_dept.Department_Id );
    l_dept_node := dbms_xmldom.appendChild( l_departments_node
    , dbms_xmldom.makeNode(l_dept_element)
    -- Each Dept node will get a Name node which contains the department name as text
    l_name_node := dbms_xmldom.appendChild( l_dept_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Name' ))
    l_name_textnode := dbms_xmldom.appendChild( l_name_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_dept.department_name ))
    -- Each Dept node will aslo get a Location node which contains the location(city) as text
    l_location_node := dbms_xmldom.appendChild( l_dept_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Location' ))
    l_location_textnode := dbms_xmldom.appendChild( l_location_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_dept.city ))
    -- For each department, add an Employees node
    l_employees_node := dbms_xmldom.appendChild( l_dept_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'Employees' ))
    FOR r_emp IN (SELECT employee_id
    , first_name
    , last_name
    FROM employees
    WHERE department_id = r_dept.department_id
    LOOP
    -- For each record, create a new Emp element with the Employee ID as attribute.
    -- and add this new Emp element to the Employees node
    l_emp_element := dbms_xmldom.createElement(l_domdoc, 'Emp' );
    dbms_xmldom.setAttribute(l_emp_element, 'empid', r_emp.employee_id );
    l_emp_node := dbms_xmldom.appendChild( l_employees_node
    , dbms_xmldom.makeNode(l_emp_element)
    -- Each emp node will get a First name and Last name node which contains the first name and last name as text
    l_emp_first_name_node := dbms_xmldom.appendChild( l_emp_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'FirstName' ))
    l_emp_first_name_textnode := dbms_xmldom.appendChild( l_emp_first_name_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_emp.first_name ))
    l_emp_last_name_node := dbms_xmldom.appendChild( l_emp_node
    , dbms_xmldom.makeNode(dbms_xmldom.createElement(l_domdoc, 'LastName' ))
    l_emp_last_name_textnode := dbms_xmldom.appendChild( l_emp_last_name_node
    , dbms_xmldom.makeNode(dbms_xmldom.createTextNode(l_domdoc, r_emp.last_name ))
    END LOOP;
      END LOOP;
    l_xmltype := dbms_xmldom.getXmlType(l_domdoc);
    dbms_xmldom.freeDocument(l_domdoc);
    dbms_output.put_line(l_xmltype.getClobVal);
    END;
    thanks and regards,
    Arun Thomas T

    It's as easy as this :
    SQL> select xmlserialize(document
      2           xmlelement("Departments"
      3           , xmlagg(
      4               xmlelement("Dept"
      5               , xmlattributes(d.department_id as "Deptno")
      6               , xmlforest(
      7                   d.department_name as "Name"
      8                 , l.city as "Location"
      9                 )
    10               , xmlelement("Employees"
    11                 , (
    12                     select xmlagg(
    13                              xmlelement("Emp"
    14                              , xmlattributes(e.employee_id as "empid")
    15                              , xmlforest(
    16                                  e.first_name as "FirstName"
    17                                , e.last_name as "LastName"
    18                                )
    19                              )
    20                            )
    21                     from hr.employees e
    22                     where e.department_id = d.department_id
    23                   )
    24                 )
    25               )
    26             )
    27           )
    28           indent
    29         )
    30  from hr.departments d
    31       join hr.locations l on l.location_id = d.location_id
    32  where d.department_id in (10,20) ;
    XMLSERIALIZE(DOCUMENTXMLELEMEN
    <Departments>
      <Dept Deptno="10">
        <Name>Administration</Name>
        <Location>Seattle</Location>
        <Employees>
          <Emp empid="200">
            <FirstName>Jennifer</FirstName>
            <LastName>Whalen</LastName>
          </Emp>
        </Employees>
      </Dept>
      <Dept Deptno="20">
        <Name>Marketing</Name>
        <Location>Toronto</Location>
        <Employees>
          <Emp empid="201">
            <FirstName>Michael</FirstName>
            <LastName>Hartstein</LastName>
          </Emp>
          <Emp empid="202">
            <FirstName>Pat</FirstName>
            <LastName>Fay</LastName>
          </Emp>
        </Employees>
      </Dept>
    </Departments>

  • FB4 hidding pieces of code like in FlashCS5 or DWCS5 and earlier.

    Hi!
    Quick Q: for how to do this in FB4. I can hide pieces of code but only for whole functions where on the left side nice small button (with + or - sign) appears.
    What if i want to hide a piece of the code inside this function. If I choose portion of the code in Flash or DW automatically appear line ended with two boxes, after clicking one, my code is rolled up.
    So how can I do that in the FB4?
    Thank you for comment:)

    Please read the adult content warning in my original post...
    I was able to cure my problem after a bit of flailing around. This may not be a "problem"; it may result from a difference in the way Mozilla sees the end of a line of text vs. how IE sees it.
    Please refer to http://officialeventlocator.com/bdsm/state_pages/bdsm_ca.php to follow along...the page cited above has no data.
    I looked at all of the pages on the site that had information. I found that the error only occurred on pages where the field labeled "Other location information" was blank, and it ALWAYS happened when that field was blank. I do not understand why that caused a problem, but my solution was to alter my PHP script so that I avoided printing blank/null fields. It simply meant checking the field for a non-null value before printing, and the problem went away.
    Hope this helps someone else.
    Steve E.

  • What's the logic error in this piece of  code?

    Hello All:
    I am doing a simple program dealing with restaurant operation. The problem is that when customer click check out button, the status of the corresponding table object doesn't change to "Vacant", whereas it should as according to my design.
    Following is the piece of code from the Interface class, where check out button (outB) is declared and add with an ActionListener:
    pCentre.setLayout(new GridLayout(3,2));
         outL = new Label("Pls type your table number to check out");
         outTable = new TextField(30);
         outMsg = new TextField(30);
         outB = new Button("Check Out");
         outB.addActionListener(new ActionListener(){
              public void actionPerformed(ActionEvent e)
              int tbNo = Integer.parseInt(outTable.getText());
              if (tbNo<1 || tbNo>5)
                   outMsg.setText("This table doesn't exist!");
              else
                   outMsg.setText("Thank you. See you again.");
    proc.checkout(tbNo);
              }// proc is the handler of Processor Class, which contain the checkout method.
    this is Processor class:
    public class Processor
    DataStore ds;
    public Processor()
    ds = new DataStore();
    public int searchTable(CusmInfo ci)
    for (int i=0; i<5; i++)
         if((ds.tInfo.tCap > ci.cNo) &&
         (ds.tInfo[i].tStat.equals("Vacant")))
         ds.tInfo[i].tStat = ci.name;
              return i+1;
         return -1;
         public String check(int i)
         if(i<1 || i>5)
         return("Table number exceeded");
    else
         return ds.tInfo[i-1].tStat;
    public void checkout(int i)
         ds.tInfo[i-1].tStat = "Vacant";     
    This is DataStore class which caters for table objects:
    public class DataStore
    public TableInfo[] tInfo = new TableInfo[5];
    public DataStore()
    tInfo[0] = new TableInfo(1, 4, "Vacant");
    tInfo[1] = new TableInfo(2, 4, "Vacant");
    tInfo[2] = new TableInfo(3, 6, "Occupy");
    tInfo[3] = new TableInfo(4, 6, "Occupy");
    tInfo[4] = new TableInfo(5, 8, "Vacant");
    public TableInfo getTableInfo(int i)
    return tInfo[i];
    class TableInfo
    int tNo;
    int tCap;
    String tStat;
    public TableInfo(int n, int c, String s)
    tNo = n;
         tCap = c;
         tStat = s;
    Why is it that after clicking the outB button, the status of the table is still customer's name but not "vacant". It seems the checkout method doesn't work. Is it because we can change the attribute of table object directly? BTW, the rest of methods in Prossor class all work properly.      

    Lol, "piece" of code is good...
    First, you should encapsule your code in "code" tags ([_code_] and [_/code_] w/o the underscores) so it will be much more readable.
    Then maybe you should assign some dukedollars to attract people to do the work for you. This is not an easy one-minute-thought question like "I'm new to java how do i print out text to stdout?" ....
    Do that and I'll check back to have a look...

  • Piece of code that is getting executed in determining vprs in billing

    Hi,
    I am a functional consultant and I desperatley need your help in finding out the piece of code that is responsible in calculating the value for VPRS condition in billing document. Its a special condition type(with condition category G) whose value is determined in the background by SAP. Generally the business scenario is like this
    SALES ORDER-DELIVERY DOCUMENT-BILLING.
    of course there are so many sources for the system to find out the value for VPRS  like from material master,sales order and material document .
    please give me the set of lines in the standard program which are relvant for this calculation because system is not behaving in a what SAP is saying .
    Thanks in advance.
    Ravi

    Can you post your bean and exception code? Is your exception checked or unchecked exception? If logMsg method throws an application exception, it should be thrown to the calling MDB as is.
    -cheng

  • Pagination of output  php code with sql code

    if one program of php including sql query
    it seems to output wrong .(means some data will be calculated sum)
    if php code output all data in one page.pagination
    it seems to output right(means some data will be calculated sum)
    if there has column of company including two companies of A and B.
    and if each page output 3 lines while A company has 4 lines in sql query,so
    the last line of A company will output in second page,
    i want to calculate A company including 4 lines sum
    how to calculate sum of company of A in second page.
    i think it will be a good interesting question of php code with sql code.
    who can solution thus question ?
    thanks !

    Hi,
    for Example:
    SELECT sum(quantity * price)
    FROM orders
    WHERE COMPANY = 'A';
    This will give you the total amount for company A.
    But remember that your example table will give no output, since you have no price column. So you must decide, what which sum to calculate.
    A sum only calculated over the quantity makes IMHO no sense, because there are apples and bananas ...
    Greetings from Hamburg
    Thorsten Körner

  • I need to run a piece of code which is inside a string object..is it possible?if so how?

    i need to run a piece of code which is inside a string object..is it possible?if so how?

    i need to run a piece of code which is inside a string object..is it possible?if so how?
    How would anyone know?
    You haven't said what 'code' you are talking about or what you mean by 'run' it.
    Since you are asking us to 'guess' what you need to do I will guess that it is a valid batch file for your OS. So just save the contents of that string to a file and then use a ProcessBuilder to 'run' it.
    See the example in the API
    ProcessBuilder (Java Platform SE 7 )

  • Improving effiency on following piece of code?

    Hello
    I was wondering is there a way in which i can improve the effiency on the following piece of code:
    public void addShapes(int x, int y, shape s){
              if(s instanceof circle){
              circle d = new circle();
              d.setX(x);
              d.setY(y);
              shapes.add(d);
              else if(s instanceof square){
                   square d = new sqaure();
                   d.setX(x);
                   d.setY(y);
                   shapes.add(d);
              else if(s instanceof triangle){
                   triangle d = new triangle();
                   d.setX(x);
                   d.setY(y);
                   shapes.add(d);
         }What the above code does is take in a shape and adds it to the arraylist of shapes which stores all shapes of all kinds such as circle, square, triangle etc...
    circle, sqaure and triangle all inheret abstract class shape therefore it checks the shape being passed in to see what kind of shape it is.
    Is there a better improved way of writing above code as that code is the only way i can think of to write it. It has many if ..else statements and bound to be more when i decide to add in more shapes.
    Im thinking surely there is a better efficient way of writing and also reduced method length.
    regards

    mpdan wrote:
    I'll chime in and ask a question.
    "...returned a copy of a "shape" object..."
    ...(...shape s)
    shape d = s.copy();
    }So does copy() return a new instance or another reference to shape s?
    If it returns a reference, why couldn't the OP just use shape s? If s.copy is implemented as return this, then it's the same as just getting rid of the copy method and using the original reference.
    One would expect, however, that copy creates a new instance of the same kind of shape, copies the instance members from the original, and returns a reference to that new instance.
    Of course, if a particular shape implementation happened to be immutable, then returning this would be perfectly acceptable, and the caller could always just call copy() without worrying about the details.
    Pardon if my question is silly.Not silly. Just typical of someone without a lot of experience coming to grips with the ideas of references and objects.
    Edit: I supposed the question should say "So +should+..."What it should do entirely depends on the requirements in the context in which it's being used. There's no one answer.

  • How can I get the return code of SQL*Plus under Win2000Pro

    How can I get the return code of SQL*Plus under Win2000Pro ?

    In a DOS batch script? Try ECHO %ERRORLEVEL%
    -- CJ

  • Mix jython code with sql

    Hi,
    I have just read the following sentence in the odi jyhon reference:
    "Oracle Data Integrator users may write procedures or knowledge modules using Jython, and may mix Jython code with SQL, PL/SQL, OS Calls, etc."
    Does anyone of you know how jython can be mixed with SQL in a knowledge module? I just know how to embed java code with the <% %> tag. But how about jython (e.g. when used in a knowledge module task with technology = "Oracle"?
    I appreciate your help.
    best regards,
    Hans

    So Firstly I have never done this in KM but it works well in Procedure so I think it would work in a KM but I'm not sure.
    So I will show you an exemple which will be easyer than lot of explanation.
    This exemple is a step of a procedure which is supposed to send an email if there is an error in an execution.
    This Step retrieve informations about the execution as the error message or the execution context...
    In the Target Command :
    Technology= Jython
    I have :
    EmailBody = EmailBody + r'''<TR><TD><CENTER>#NO</CENTER></TD><TD>#SESS_NAME</TD><TD>#STEP_NAME
    </TD><TD>#CONTEXT</TD><TD>#DEBUT</TD><TD>#MSG</TD></TR>'''
    Contexte = '#CONTEXT'.
    --> the #variable are the informations that I will extract in the source.
    In the Source Command :
    Technology = Oracle .
    SELECT L.SESS_NO || ' / ' || L.NNO "NO", STEP_NAME, SESS_NAME, SS.CONTEXT_CODE "CONTEXT", L.STEP_BEG "DEBUT", X.TXT "MSG", L.step_rc "RC"
    FROM <%=snpRef.getObjectName("L", "SNP_STEP_LOG", "D")%> L,
    <%=snpRef.getObjectName("L", "SNP_SESS_STEP", "D")%> SS,
    <%=snpRef.getObjectName("L", "SNP_SESSION", "D")%> S,
    <%=snpRef.getObjectName("L", "SNP_EXP_TXT", "D")%> X
    WHERE L.SESS_NO = <%=snpRef.getSession("SESS_NO")%> AND
    L.SESS_NO = SS.SESS_NO AND L.NNO = SS.NNO AND S.SESS_NO = L.SESS_NO AND
    STEP_STATUS = 'E' and L.I_TXT_STEP_MESS=X.I_TXT and X.TXT_ORD=0
    And with this the Jython keep the information of the Query...
    So I would like to apologize cause in my last post I have inversed the Target and the Source... Sorry. Hope that your problem didn't come from here...
    Evidently you will have SQL as Source and Jython as Target...

  • Do we have the option to unwrap the code(PL/SQL)

    Hi All,
    Do we have any option to upwrap the wraped PL/SQL Code.
    Regards
    Bond.

    user2481227 wrote:
    I thought the main purpose of wrapping code was to "secure intellectual property written in pl/sql". And in my opinion there should be a way to do that.That is a true statement, but your definition of "secure" may differ from others.
    If you deliver intellectual property to a customer that gets installed on a customer's servers, there is realistically no (technical) way to prevent the customer from reverse-engineering the code. Every language can be decompiled-- if the operating system or the database or some other piece of software can run the code, some other piece of software must necessarily be able to translate it back into source code. Doesn't matter whether it is C, PL/SQL, Java, or anything else-- you're always going to be able to decompile the code. Wrapping the code creates additional hoops that the customer has to jump through in order to view the source, which acts as a barrier against casual snooping, but a moderately determined person will always be able to get back to your source (or at least something functionally identical to your source).
    That said, how useful is code without comments going to be (and what version of Oracle are we talking about, since the wrap utility's algorithm was substantially strengthened in 10g)? If you really have intellectual property worth protecting, it probably isn't going to be hugely beneficial to someone to see tens of thousands of lines of code without comments. 9 times out of 10, in my experience primarily working for clients that purchase large, specialized applications, code obfuscation ends up annoying good customers (i.e. those that want to play by the rules) by making it harder to interoperate with the product they've purchased while providing little barrier to moderately determined hackers, so you may want to reconsider the requirement.
    If you're really concerned about protecting the code, one alternative option might be to play around with native compilation. I haven't looked, but I strongly suspect that variable names at least are going to be changed when Oracle generates the C code or the C compiler compiles it. Of course, there are plenty of C decompilers floating around, but then you'd be in basically the same situation that you'd be if you shipped an executable to the client.
    Justin

  • A difficult problem with php code and sql code

    it's good place to visit(Paged Result Sets with PHP and Oracle)
    http://www.oracle.com/technology/pub/articles/oracle_php_cookbook/fuecks_paged.html
    maybe below part php code could not be used in above address's php code.
    if((isset($l_company) and $l_company != $rows['COMPANY']) or empty($stmt) and empty($total_pages) ) {
    echo "<tr bgcolor='#CCFFCC'>";
    echo "<td colspan= 3 align='center'>".$l_company."</td>";
    echo "<td >".$totalcomany." </td>";
    $totalcomany = 0;
    echo "<td > </td>";
    echo "</tr>";
    $l_company = $rows['COMPANY'];
    because the same company in one page could calculate sum while if
    the same company in two pages could not do that.
    and what do you think of ?
    thanks !

    Hi,
    this is because your sql-statement selects only the rows, you need to build this one page.
    Neither php nor the given result from your query knows about data wich will be part of the result of another page.
    Greetings from Hamburg
    Thorsten Körner

Maybe you are looking for