Pessoal
 
O tratamento de campos longos em Sybase com Centura n�o � nada simples. Abaixo colei parte do que est� no help do Centura:
 
To write IMAGE or TEXT data of up to 64K, you may use the INSERT or UPDATE SQL statements, but you must then supply the data as a literal or a constant. You can write IMAGE or TEXT data of any size using the function SybWriteText; assign the data to a variable and pass that variable as an argument to SybWriteText.
Note: If you attempt to execute an INSERT or UPDATE statement using bind variables on an IMAGE or TEXT column, the current transaction will be rolled back and you will be presented with the error message returned by the database server. This is because Sybase does not support dynamic parameters for TEXT and IMAGE data.
 
To retrieve IMAGE or TEXT data that you do not intend to update:
 
1. Define a normal SQL cursor to fetch the data.
(To scroll backwards and forwards in the result set, turn on result set mode.)
2. To retrieve IMAGE or TEXT data that you wish to update:
3. Get a SQL handle (for example, hSql1).
4. Turn off result set mode (specifying the handle hSql1). To preserve the cursor context, turn on CCP before turning off result set mode.
5. Execute a SELECTFOR LONG UPDATE statement, specifying hSql1. (The FOR LONG UPDATE clause is an extension to SQL that Centura SQLWindows uses for Sybase System 10 and System 11 only.)
 
6. Position to the row you wish to update.
7. Get another SQL handle (for example, hSql2).
8. Call SybWriteText (using hSql2) to update the row.
 
To insert IMAGE or TEXT data:
 
1. Get a SQL handle (for example, hSql1).
2. Insert a dummy value (such as a space) into the target column by preparing and executing the SQL INSERT statement and specifying the handle hSql1.
3. Commit the insert operation (if autocommit is off) specifying the handle hSql1.
4. Turn off result set mode (specifying the handle hSql1). To preserve the cursor context, turn on CCP before turning off result set mode.
5. Execute a SELECTFOR LONG UPDATE statement, specifying hSql1. (The FOR LONG UPDATE clause is an extension to SQL that Centura SQLWindows uses for Sybase System 10 and System 11 only.)
 
6. Position to the desired row.
7. Get another SQL handle (for example, hSql2).
8. Call SybWriteText (using hSql2) to update the row.
 
To delete IMAGE or TEXT data:
 
1. Turn on result set mode.
2. Execute a SELECTFOR UPDATE statement.
3. Position to the desired row.
4. Execute the DELETE statement.
 
When calling SybWriteText, you can choose whether or not to log the update of the IMAGE or TEXT column by setting the bLogging argument to this function appropriately   �   if bLogging is FALSE, the database server will not log the update. Note that you must enable the sp_dboption option (select into/bulkcopy) on the database server to perform operations without logging.
Important: You should ignore the information about hex strings and updating IMAGE or TEXT data with the SELECT...FOR LONG UPDATE statement in that book.
 
Paci�ncia ...
 
Marcelo Urbano
 
----- Original Message -----
Sent: Friday, June 13, 2003 12:15 PM
Subject: [sqlwin] Ajuda ao inserir imagem no Sybase 12.

Ol� pessoal,
 
Estou tentando inserir uma imagem numa tabela.
O banco � o Sybase 12.5.03
A coluna � do tipo IMAGE
 
Tentei diversas formas, mas ainda n�o consegui.
 
Minha ultima tentativa foi essa:
 
!!CB!! 70
Set n = 7
Call SalPicGetImage( picIMAGEM, lsImagem, n )
Call SqlPrepareAndExecute( hSql,  "DELETE FROM testeimage" )
!
Call SqlPrepareAndExecute( hSql,  'INSERT INTO testeimage ( cod ) VALUES ( :dfCod ) ')
Call SqlSetResultSet( hSql , FALSE )
Call SqlPrepareAndExecute ( hSql, "Update testeimage Set imagem = NULL where cod = :dfCod " )
Call SqlPrepare ( hSql, "SELECT cod FROM testeimage FOR LONG UPDATE ")
Call SqlOpen( hSql, "Cursor1" )
If SqlFetchNext( hSql, lParam )
 Call SybWriteText( hSql2, "Cursor1", 1, "testeimage.imagem", lsImagem, 0, 0 )
 
Se algu�m puder ajudar eu agrade�o muito.
 
um abra�o,
Lairton N de Almeida Jr.

Responder a