# 1 Selector in Sql-Table

#### In this example, an object is created with a Sql-Table, the content of which shows the albums of the system. The Sql-Table allows you to select records and press a button to perform a process with the selected records.

Object with the set of system albums.

Sql-Table in the form. It is important the Memo of the Sql-Table, because the value will contain the reference to be able to obtain the data selected in the program.

Access Layout/SQL table tab by means of the Box settings option of Celldata box.

Parameterization of the Sql-Table, Main box: The selection field is marked with the value 'Multiple'.

Sentence used:

Copy
<select>
<columns>
album.albumid,
album.title,
album.artistid,
artist.name,
album.state
</columns>
<from table='album'>
<join table='artist' type='left'>
<on>album.artistid = artist.artistid</on>
</join>
<join table='album_images' type='left'>
<on>album.albumid = album_images.albumid</on>
</join>
</from>
<where>
\$0
</where>
</select>

The output fields are added, coinciding with the fields used in the statement.

Creation of the 'DROP'('Baja') button with the program that updates the status of the selected albums.

Sentence XSQL-Script used: It is observed that the program contains the Memo of the Sql-Table 'BOX_ALBUM' to obtain the selected values.

Copy
<call>
<xsql-script>

<body>

<!-- v_table with the set of rows selected in the form -->
<set name='v_process_album'>
<http.request.sqltable.getSelected code='BOX_ALBUM' />
</set>

<!-- For each registration the state is updated -->
<foreach>
<in prefix='v_'>
<v_process_album />
</in>
<do>

<update table='album'>
<column name='state'>B</column>
<where>
album.albumid = <v_albumid/>
</where>
</update>

</do>
</foreach>

</body>
</xsql-script>

]]>
</call>

Result: