Through a select returns a string with the SQL clause IN. The clause IN contains all the values obtained in the select for the first column of this.
1 sql.toIN
<sql.toIN>
<select /> !
</sql.toIN>
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Eselect | string | Sentence SQL in baseto which the IN string is obtained. |
Returns | |
---|---|
Type | Description |
string | Returns a sql string with the sintaxis of a IN SQL clause. |
Example
Obtain a IN condition with all the codes of employers with OFIC categorie.
Copy
<xsql-script name='sql_toIN_sample'> <body> <!-- CREATE TABLE employers ( emp_code CHAR(10) NOT NULL, emp_name VARCHAR(10), emp_age SMALLINT NOT NULL, emp_category CHAR(4) NOT NULL, emp_calendar CHAR(4) NOT NULL ); CREATE UNIQUE INDEX p_employers ON employers(emp_code); ALTER TABLE employers ADD CONSTRAINT PRIMARY KEY (emp_code); --> <insert table='employers'> <column name='emp_code'>E0001</column> <column name='emp_name'><string>Jose Luís García Jurado</string></column> <column name='emp_age'>45</column> <column name='emp_category'>OFIC</column> <column name='emp_calendar'>C1</column> </insert> <insert table='employers'> <column name='emp_code'>E0002</column> <column name='emp_name'><string>Antonio Abadia Ávisl</string></column> <column name='emp_age'>41</column> <column name='emp_category'>OFIC</column> <column name='emp_calendar'>C1</column> </insert> <insert table='employers'> <column name='emp_code'>E0003</column> <column name='emp_name'><string>Asensio Ruiz Guijano</string></column> <column name='emp_age'>33</column> <column name='emp_category'>OFIC</column> <column name='emp_calendar'>C2</column> </insert> <insert table='employers'> <column name='emp_code'>E0004</column> <column name='emp_name'><string>Rosana Pérez Gispert</string></column> <column name='emp_age'>33</column> <column name='emp_category'>OFIC</column> <column name='emp_calendar'>C2</column> </insert> <set name='m_sqlcond'> <sql.toIN> <select> <columns>emp_code</columns> <from table='employers' /> <where> emp_category = 'OFIC' </where> </select> </sql.toIN> </set> <println>SQLCOND: <m_sqlcond /></println> </body> </xsql-script>
Result of the execution:
Copy
SQLCOND: IN ('E0001','E0002','E0003','E0004')