# 22. Virtuoso Functions Guide - connection_set

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Virtuoso Functions Guide
Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
dav add & update fun...
dav manipulation fun...
dav search functions
dav_exp
lfs_exp
serv_queue_top
vhost_define
vhost_remove
webdav users & group...
client_attr
connection_get
connection_id
connection_is_dirty
connection_set
connection_vars
connection_vars_set
dbname
ftp_get
ftp_ls
ftp_put
get_certificate_info
get_keyword
get_keyword_ucase
http
http_acl_get
http_body_read
http_client
http_client_ip
http_debug_log
http_enable_gz
http_file
http_flush
http_get
http_header
http_header_get
http_kill
http_listen_host
http_map_get
http_map_table
http_param
http_path
http_pending_req
http_physical_path
http_proxy
http_request_get
http_request_header
http_request_status
http_rewrite
http_root
http_url
http_value
http_xslt
ses_connect
ses_disconnect
ses_read_line
ses_write
tcpip_gethostbyaddr
tcpip_gethostbyname
vsp_calculate_digest
wsdl_import_udt
XML
XPATH & XQUERY
Functions Index

## connection_set

Associates a value to the name in the context of the present connection
connection_set (in name varchar, in value any);
Description

This associates a value to the name in the context of present connection. The name should be a string and the value can be any data type except blob, open cursor or an XML entity. If the value is an array it may not contain the restricted types.

Connection variable setting is not logged and information stored will be lost when the connection is closed. The value can be retrieved by any future statement executing within the same connection. Connection variables can be used as a global variable mechanism for stored procedures, the scope being the client connection.

In the case of VSP or SOAP this mechanism cannot be used to pass information between requests by the same client. It will however, be useful for having 'global variables' between procedures called within the same HTTP request. Note that this mechanism is used to provide persistent HTTP session variables in some cases but this works through special before and after code which stores the values set with this function into an external session structure. In this sense this function itself has nothing to do with web session management although it can be used as a component for such.

Parameters
name – VARCHAR name to associate the value with.
value – value to be stored. May be any data type except LOB, open cursor or XML entity. If the value is an array, it may not contain the restricted types.
Return Values

None

Errors

SQLState | Error Code | Error Text | Description
--- | --- | --- | ---
22023 | SR049 | Data type is not suitable for storage into a global variable (connection_set) |

Examples
Setting and Retrieving Connection Variables

From SQL

    SQL> select connection_get('var_demo');
    callret
    VARCHAR
    __________________________________________________________________

    NULL

    SQL> connection_set('var_demo', 'some arb data');

    SQL> select connection_get('var_demo');
    callret
    VARCHAR
    __________________________________________________________________

    some arb data

From a VSP page

      <?vsp
        declare id integer;
        id := 12;
        connection_set ('ID', id);
        connection_set ('saved_request' , lines);
      ?>

See Also

connection_get

connection_is_dirty

connection_vars_set