Database>Table Object
Introduction Installation Beginning Admin Quick Ref FTP Server SMTP Server Database Security
Statements Objects String Parsing Events Queues Samples Special names Error Handling Accessories   Back
Caravan Business Server>Help>Database>Table Object
Syntax <CARAVAN>table tableInstance = Database name.Table name</CARAVAN>
Text 1. When a table object is declared within a web page, only Caravan code within that web page can access that object; it has a scope that is local to that web page.

2. Local objects declared with table clause remain in existence only as long as the web page is executing.
      
Sample
<CARAVAN>
table tblcontacts = contacts.contacts
</CARAVAN>

tblcontacts      -      Table table instance name
Contacts      -      Database name. Here the database name is contacts.
Contacts      -      Table name. Contacts is a table inside the Contacts database

<HTML>
<BODY>
<CARAVAN>
      table contacts=contacts.contacts
      //table object (contacts) is created.
      select  from  contacts where firstname="John"
      // rows are selected based on a search condition (firstname="John").
      if contacts(selected)>"0"
            // Check whether the select statement has returned any rows (if statement).
            // Process the data returned by the select query and display in a table.
            loop ctr (contacts(selected))
                  // A loop is created with ctr as the counter variable and the upper limit of the loop is the number of
                  //rows returned by the select statement (contacts(selected)).
                   testconn(firstname)
                   testconn(lastname)
                  contacts(nextrecord)
            // Move the current record pointer to the next record using the nextrecord keyword.
            repeat ctr 100
      // Continue the loop. 100 is the maximum number of iterations performed

      endif
</CARAVAN>
</BODY>
</HTML>

Positioning a record
<CARAVAN>
      table contacts = contacts.contacts
      //move the record pointer to the 2nd position.
      contacts(recordno)="2"
    "Current record number is ";contacts(recordno);"<br>
    //move the records ahead by five records
      contacts(recordno)+="5"
    "Current record number is ";contacts(recordno);"<br>

    //move the records backwards by three records
      contacts(recordno)-="3"
      "Current record number is ";contacts(recordno);"<br>
</CARAVAN>
Quick Reference
Properties selected
recordno
nextrecord
selectall
Home       Back