A database element allows you to query a back-end database and display the results in a mobile application.
Using Sybase WorkSpace to create database elements allows you to leverage other Sybase products that are integrated into Sybase WorkSpace (such as PowerBuilder) to help create and build your database elements. For example, you can create a .qry file using PowerBuilder (or other tool), and drag and drop it onto a Mobile Application folder to create a new mobile application with the properties of the .qry file. The steps below describe how to create a database element using the database element wizard.
Creating a database element
From the Mobile Application perspective, select File | New | Mobile Application. alternatively right-click the mobile status folder and select “Create Approved (or other status) Mobile Application with Database element”.
When the Mobile Application wizard appears, select Launch Element Wizard, select Database from the Element Type drop-down list and click Finish.
Alternatively, right-click the Mobile Application status folder in which you want to create the mobile application, and select Create (status name) Mobile Application With | Database Element. You can also drag the .qry file into the definitions element section and drop (Or drag the .qry file and drop on a mobile application status folder).
Complete the Database Element Definition:
Database Connection Parameters - you can use the Enterprise Explorer within Sybase WorkSpace to create your connection profiles. When selecting a connection, you have two choices for database connection parameters:
Connection Cache - the connection cache used to access the database. Select the JNDI reference from the drop-down list. These are created on the Unwired Accelerator server to which you are connected.
Connection Profile - a JDBC connection profile to use to establish a connection to the database. Selecting a connection profile from the drop-down list fills in the following fields automatically, or you can manually fill in the fields:
Username - the user name used to access the database; for example, to access Adaptive Server Anywhere, the default user name is dba.
Password - the password used to access the database; for example, the default password for the Adaptive Server Anywhere database is SQL.
Connection URL - the connection string to access the database; for example:
jdbc:sybase:Tds:host:port/portaldatabase?ServiceName=portaldatabase
where host is the name of installed database server, port is the port used to connect to the specified database, and portaldatabase is the name of the database to which you want to connect.
If the database server is installed on the same machine as Unwired Accelerator, you do not have to change the "localhost" value.
JDBC Driver - the JDBC driver used to access the database; for example:
com.sybase.jdbc2.jdbc.SybDriver
SQL Query - displays the SQL statement to retrieve the requested data from the database. If you import a .qry file, the query from that file displays in the SQL Query field, or you can enter the query directly into the field. For example, the simple query shown below displays everything in the users table.
select * from users
Validate - validates that your SQL contains no errors. This is "Enabled" if you select a connection profile. It returns true if the SQL is valid.
Visual SQL - allows you to visually generate SQL syntax without writing SQL code. You can create select, insert, update, and delete statements using Visual SQL. If a query already exists in the SQL Query screen, the query is displayed in the Visual SQL editor, where you can modify it as needed. This option is only enabled if you select a connection profile. Also, the SQL type is only enabled if you are creating SQL for the first time (IE. nothing exists in the SQL edit box). After creating SQL, only “select” statements can be edited here.
See Using Visual SQL to Edit a Procedural Object for additional information about Visual SQL.
UI XSLT - (optional) the complete URL of the XSLT to be applied to the content returned by the database. This field is not editable. you must use the “Search” button to choose an existing XSL template.
Click Next. Depending on the SQL, you may or may not see the Rules screen. Based on the SQL in this example, the Rules screen does not appear.
Click Finish to close the window and display Sybase WorkSpace with the new database element, or you can define rules or CGI parameters for the database element.
Send your feedback on this help topic to Sybase Tech Pubs: pubs@sybase.com