Difference between revisions of "RDO CONNECT()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(5 intermediate revisions by one user not shown)
Line 1: Line 1:
{{YLM to do}}
 
 
==Purpose==
 
==Purpose==
 
Connect to a data source
 
Connect to a data source
Line 6: Line 5:
 
==Syntax==
 
==Syntax==
 
RDO_CONNECT(<expC1>, <expC2>, <expC3>, <expC4> [, <expC5>])
 
RDO_CONNECT(<expC1>, <expC2>, <expC3>, <expC4> [, <expC5>])
 +
 +
MYSQL_CONNECT(<expC1>, <expC2>, <expC3>, <expC4> [, <expC5>])
  
  
 
==See Also==
 
==See Also==
 
[[RDO_AFFECTED_ROWS()]], [[RDO_CLOSE()]], [[RDO_DATA_SEEK()]], [[RDO_ERRNO()]], [[RDO_ERROR()]], [[RDO_EXEC()]], [[RDO_FETCH_ARRAY()]], [[RDO_FETCH_ASSOC()]], [[RDO_FETCH_FIELD()]], [[RDO_FETCH_LENGTHS()]], [[RDO_FETCH_OBJECT()]], [[RDO_FETCH_ROW()]], [[RDO_FIELD_FLAGS()]], [[RDO_FIELD_LEN()]], [[RDO_FIELD_NAME()]], [[RDO_FIELD_SEEK()]], [[RDO_FIELD_TABLE()]], [[RDO_FIELD_TYPE()]], [[RDO_FREE_OBJECT()]], [[RDO_FREE_RESULT()]], [[RDO_GET_CLIENT_INFO()]], [[RDO_GET_HOST_INFO()]], [[RDO_INFO()]], [[RDO_LIST_DBS()]], [[RDO_NUM_FIELDS()]], [[RDO_NUM_ROWS()]], [[RDO_PING()]], [[RDO_QUERY()]], [[RDO_REAL_ESCAPE_STRING()]], [[RDO_RESULT()]], [[RDO_SELECT_DB()]], [[RDO_STAT()]], [[RDO_THREAD_ID()]], [[RDO_UNBUFFERED_QUERY()]]
 
[[RDO_AFFECTED_ROWS()]], [[RDO_CLOSE()]], [[RDO_DATA_SEEK()]], [[RDO_ERRNO()]], [[RDO_ERROR()]], [[RDO_EXEC()]], [[RDO_FETCH_ARRAY()]], [[RDO_FETCH_ASSOC()]], [[RDO_FETCH_FIELD()]], [[RDO_FETCH_LENGTHS()]], [[RDO_FETCH_OBJECT()]], [[RDO_FETCH_ROW()]], [[RDO_FIELD_FLAGS()]], [[RDO_FIELD_LEN()]], [[RDO_FIELD_NAME()]], [[RDO_FIELD_SEEK()]], [[RDO_FIELD_TABLE()]], [[RDO_FIELD_TYPE()]], [[RDO_FREE_OBJECT()]], [[RDO_FREE_RESULT()]], [[RDO_GET_CLIENT_INFO()]], [[RDO_GET_HOST_INFO()]], [[RDO_INFO()]], [[RDO_LIST_DBS()]], [[RDO_NUM_FIELDS()]], [[RDO_NUM_ROWS()]], [[RDO_PING()]], [[RDO_QUERY()]], [[RDO_REAL_ESCAPE_STRING()]], [[RDO_RESULT()]], [[RDO_SELECT_DB()]], [[RDO_STAT()]], [[RDO_THREAD_ID()]], [[RDO_UNBUFFERED_QUERY()]]
 +
  
 
==Description==
 
==Description==
The RDO_CONNECT() function is used to connect to a data source.
+
The RDO_CONNECT() function is used to connect to a data source. The numeric value returned should be saved to a variable to be used by other functions to reference the connection. Connection references start from 0 and correspond to the [[SELECT()|cursor/workarea]] -1.  If RDO_CONNECT() returns -1, the connection failed.
Returns a numeric, to be used by other functions.
+
 
  
 
{| class="wikitable"
 
{| class="wikitable"
 
!Keywords||Description
 
!Keywords||Description
 
|-
 
|-
|<expC1>||Servertype
+
|<expC1>||Servertype: "recital", "oracle", "db2", "mysql" or "postgres"
 
|-
 
|-
|<expC2>||Hostname
+
|<expC2>||Hostname: IP address or character name
 
|-
 
|-
|<expC3>||Username
+
|<expC3>||Username: account used to access the data source
 
|-
 
|-
|<expC4>||Password
+
|<expC4>||Password: password for account above
 
|-
 
|-
|<expC5>||Database
+
|<expC5>||Database: database to connect to
 
|-
 
|-
 
|}
 
|}
Line 33: Line 35:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
 +
conn = rdo_connect("mysql","localhost", "user", "pass", "test")
 +
if conn > -1
 +
    rdo_exec("create table mytable (phrase char(20))", conn)
 +
    rdo_exec("insert into mytable values ('Hello world')")
 +
    echo rdo_affected_rows()
 +
    rdo_close(conn)
 +
endif
 
</code>
 
</code>
 +
  
 
==Products==
 
==Products==
Line 40: Line 50:
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:SQL]]
 
[[Category:SQL]]
 +
[[Category:Remote Data Connectivity]]
 
[[Category:Remote Data Connectivity Functions]]
 
[[Category:Remote Data Connectivity Functions]]

Latest revision as of 11:57, 22 June 2010

Purpose

Connect to a data source


Syntax

RDO_CONNECT(<expC1>, <expC2>, <expC3>, <expC4> [, <expC5>])

MYSQL_CONNECT(<expC1>, <expC2>, <expC3>, <expC4> [, <expC5>])


See Also

RDO_AFFECTED_ROWS(), RDO_CLOSE(), RDO_DATA_SEEK(), RDO_ERRNO(), RDO_ERROR(), RDO_EXEC(), RDO_FETCH_ARRAY(), RDO_FETCH_ASSOC(), RDO_FETCH_FIELD(), RDO_FETCH_LENGTHS(), RDO_FETCH_OBJECT(), RDO_FETCH_ROW(), RDO_FIELD_FLAGS(), RDO_FIELD_LEN(), RDO_FIELD_NAME(), RDO_FIELD_SEEK(), RDO_FIELD_TABLE(), RDO_FIELD_TYPE(), RDO_FREE_OBJECT(), RDO_FREE_RESULT(), RDO_GET_CLIENT_INFO(), RDO_GET_HOST_INFO(), RDO_INFO(), RDO_LIST_DBS(), RDO_NUM_FIELDS(), RDO_NUM_ROWS(), RDO_PING(), RDO_QUERY(), RDO_REAL_ESCAPE_STRING(), RDO_RESULT(), RDO_SELECT_DB(), RDO_STAT(), RDO_THREAD_ID(), RDO_UNBUFFERED_QUERY()


Description

The RDO_CONNECT() function is used to connect to a data source. The numeric value returned should be saved to a variable to be used by other functions to reference the connection. Connection references start from 0 and correspond to the cursor/workarea -1. If RDO_CONNECT() returns -1, the connection failed.


Keywords Description
<expC1> Servertype: "recital", "oracle", "db2", "mysql" or "postgres"
<expC2> Hostname: IP address or character name
<expC3> Username: account used to access the data source
<expC4> Password: password for account above
<expC5> Database: database to connect to


Example

conn = rdo_connect("mysql","localhost", "user", "pass", "test")
if conn > -1
    rdo_exec("create table mytable (phrase char(20))", conn)
    rdo_exec("insert into mytable values ('Hello world')")
    echo rdo_affected_rows()
    rdo_close(conn)
endif


Products

Recital, Recital Server