OPEN (Snowflake Scripting) | Snowflake Documentation (original) (raw)

ReferenceScripting referenceOPEN

Opens a cursor.

For more information on cursors, see Working with cursors.

See also:

DECLARE, FETCH, CLOSE

Syntax

OPEN [ USING (bind_variable_1 [, bind_variable_2 ...] ) ] ;

Where:

_cursorname_

The name of the cursor.

_bindvariable_

A bind variable holds a value to be used in the cursor’s query definition (e.g. in a WHERE clause).

An example of binding is included in the examples later in this section.

Usage notes

Examples

DECLARE c1 CURSOR FOR SELECT price FROM invoices; BEGIN OPEN c1; ...

The following shows how to bind a variable when opening a cursor:

DECLARE price_to_search_for FLOAT; price_count INTEGER; c2 CURSOR FOR SELECT COUNT(*) FROM invoices WHERE price = ?; BEGIN price_to_search_for := 11.11; OPEN c2 USING (price_to_search_for);

For a more complete example of using a cursor, seethe introductory cursor example.