home *** CD-ROM | disk | FTP | other *** search
- <include sesfield.hei>
- <include layout/heilay.hei>
-
- <session mode="create"> // We are working in session mode now
-
-
- <heitmlpage title="SQL Scroll Form" mis/67//h>
-
- Now you can enter an arbitrary SQL-Query on our example database. Here are a
- few variations on the SELECT command that you might like to try:
- <p>
-
- <let x = = 5>
-
- <box>
- <FONT SIZE="-1"><b>
- <ul>
- <li> SELECT * FROM guestbook
- <li> SELECT Guest_Name FROM guestbook ORDER BY Guest_Name
- <li> SELECT DISTINCT Guest_Name, Email, Address FROM guestbook ORDER BY Guest_Name
- <li> SELECT COUNT (*) FROM guestbook
- <li> SELECT COUNT (*) FROM guestbook WHERE Country="USA"
- <li> SELECT * FROM guestbook WHERE Guest_Name LIKE 'R%'
- </ul>
- </FONT></b>
- </box>
-
- <p>
- Watch how the Query Result changes depending on the form of the SELECT command that you enter.
-
-
- /******************************************************************
- Here is the input form that allows the user to enter
- an SQL query. It is a sessionForm, displaying and updating
- session variables.
- ******************************************************************/
- <sessionForm>
- <sessionButton name="SQuery" value="Query">
- <INPUT TYPE="reset" VALUE="Reset">
- <a href="demo.hei"> Back </a>
- <sessionButton name="Apply">
- <br>
- <if (isempty(se.query)); se.query="SELECT * FROM guestbook"; /if>
- <sessionTextArea "Query" ROWS=6 COLS=55 wrap="physical">
- <p>
- Maximal Number of rows to read :
- <let se.max=default(se.max,100); sessionFi "max" 10 type="i"><br>
- Number of Rows per page:
- <let se.pgsize=default(se.pgsize,5); sessionFi "pgsize" 10 type="i">
- </sessionForm>
-
- // We do the following, when the QUERY button has been pressed
- <if !isempty(ff.Squery) && SrvDebug;
- i=0; SrvMax=se.max;
- se.buffer=array(1); // Create an empty array
- se.pos=0;
- dbquery q> <? se.query> < // Do the query
- dbrow resize(se.buffer,i+1); // and add each record to the array
- se.buffer[i]= clone(q);
- i=i+1;
- dbempty
- se.buffer=null; // in case the result is empty
- /db;
- /if>
-
-
-
- /*************** End of SQL query input FORM ************/
-
-
- // Now we show the buffer (if its not empty)
- <if !isempty(se.buffer);
-
- // First handle the scroll buttons
- if (!isempty(ff.next)); se.pos=se.pos+se.pgsize; /if
- if (!isempty(ff.prev)); se.pos=se.pos-se.pgsize; /if
- if (len(se.buffer)<se.pos); se.pos=len(se.buffer)-se.pgsize; /if;
- if (se.pos<0); se.pos=0; /if;
-
- > <h1> Query Result </h1>
- Contains <? len(se.buffer)> Records.
- <table border>
- <tr>
- <let i=0;
- h=se.buffer[0];
- > <th> Nr </th> <
- while (i<len(h));
- > <th> <? fname(h[i])> </th> <
- let i=i+1;
- /while;
-
- l=0;
- while l<se.pgsize && l+se.pos<len(se.buffer);
- > <tr> <
- let h=se.buffer[l+se.pos];
- > <td> <? l+se.pos> </td> <
- let i=0;
- while (i<len(h));
- > <td> <? h[i]> </td> <
- let i=i+1;
- /while;
- > </tr> <
- let l=l+1;
- /while;
- >
- </table>
- <let par=emptytuple; par.next="t">
- <sa par=par>next</sa>
- <let par=emptytuple; par.prev="t">
- <sa par=par>prev</sa>
- <
- /if;
-
- /heitmlpage;
- /session>
-
-
-
-
-
-
-
-
-
-
-