Home
Main Introduction Features Constants Statements Database Objects Parser Serial-Communication Samples Misc
Database>Connection Object
Caravan Business Server>Help>Database>Connection Object
Syntax <CARAVAN>table connection object name = Database name.Table name</CARAVAN>
Text 1. When a connection 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 connection 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
//connection object (contacts) is created.
select firstname,lastname from contacts where firstname="John"
// Columns (firstname, lastname) and 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).
"<TABLE>"

// 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)).
"<TD>"
testconn(firstname)
"</TD>"
"<TD>"
testconn(lastname)
"</TD>"
"</TR>"
contacts(nextrecord)

// Move the current record pointer to the next record using the nextrecord keyword.
repeat ctr 100
// Continue the loop. 100 is the estimated number of records to be returned.
"</TABLE>"
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>
Properties selected
recordno
nextrecord
Back