Inserting Data Directly from Adaptive Server Enterprise

To insert data from an Adaptive Server Enterprise (ASE) or SQL Server database, use the LOCATION syntax of the INSERT statement.

To use insert data directly from SAP Sybase IQ, all of the following must be true:
  1. Connect to both the Adaptive Server Enterprise and the SAP Sybase IQ database using the same user ID and password.
  2. On the SAP Sybase IQ database, issue:
    INSERT INTO iq_table 
    LOCATION 'ase_servername.ase_dbname' 
    { SELECT col1, col2, col3,...
    FROM owner.ase_table } 
  3. Issue a COMMIT to commit the insert.
When SAP Sybase IQ connects to the remote server, INSERT...LOCATION can also use the remote login for the user ID of the current connection, if a remote login has been created with CREATE EXTERNLOGIN and the remote server has been defined with a CREATE SERVER statement.
Note: You can also use this method to move selected columns between two SAP Sybase IQ databases.

Loading ASE Text and Images

SAP Sybase IQdoes not support the Adaptive Server Enterprise data type TEXT, but you can execute INSERT...LOCATION (Syntax 3) from both an IQ CHAR or VARCHAR column with length is greater than 255 bytes, or a LONG VARCHAR column, and from an ASE database column of data type TEXT. ASE TEXT and IMAGE columns can be inserted into columns of other SAP Sybase IQ data types, if SAP Sybase IQ supports the internal conversion. INSERT...LOCATION does not support the use of variables in the SELECT statement. By default, if a remote data column contains over 2GB, SAP Sybase IQ silently truncates the column value to 2GB.

Users must be specifically licensed to use the Unstructured Data Analytics functionality.

You may substitute curly braces {} for the single quotation marks that delimit the SELECT statement. (However, curly braces represent the start and end of an escape sequence in the ODBC standard, and may generate errors in the context of ODBC.)

Example

The following command inserts data from the l_shipdate and l_orderkey columns of the lineitem table from the SAP Sybase IQ database iq11db.dba on the server detroit, into the corresponding columns of the lineitem table in the current database:
INSERT INTO lineitem
    (l_shipdate, l_orderkey)
	 LOCATION 'detroit.iq11db'
    { SELECT l_shipdate, l_orderkey
    FROM lineitem }
  • The destination and source columns may have different names.

  • The order in which you specify the columns is important, because data from the first source column named is inserted into the first target column named, and so on.

  • You can use the predicates of the SELECT statement within the INSERT command to insert data from only certain rows in the table.

Example

This example inserts the same columns as the previous example, but only for the rows where the value of l_orderkey is 1. Also in this example, the TDS packet size is specified as 512 bytes.
INSERT INTO lineitem
    (l_shipdate, l_orderkey)
    LOCATION 'detroit.iqdb'
	PACKETSIZE 512
	{ SELECT l_shipdate, l_orderkey
    FROM lineitem
    WHERE l_orderkey = 1 }