Position within a smart large object
The IfxLoTell() method in the IfxSmartBlob class
returns the current seek position, which is the offset for the next
read or write operation on the smart large object. The IfxLoSeek() method
in the IfxSmartBlob class sets the read or write position within
an already opened large object.
public long IfxLoTell(int lofd) public long IfxLoSeek(int lofd, long offset, int whence) throws SQLException
The absolute position depends on the value of the second parameter, offset, and the value of the third parameter, whence.
The lofd parameter is the locator file descriptor returned by the IfxLoCreate() or IfxLoOpen() method. The offset parameter is an offset from the starting seek position.
The whence parameter
identifies the starting seek position. Use the whence values
in the following table to define the position within a smart large
object to start a seek operation.
Starting seek position | Whence value |
---|---|
Beginning of the smart large object | IfxSmartBlob.LO_SEEK_SET |
Current® location in the smart large object | IfxSmartBlob.LO_SEEK_CUR |
End of the smart large object | IfxSmartBlob.LO_SEEK_END |
The return value is a long integer representing the absolute position within the smart large object.
The following example shows how to use a LO_SEEK_SET whence value:
IfxLobDescriptor loDesc = new IfxLobDescriptor(myConn);
IfxLocator loPtr = new IfxLocator();
IfxSmartBlob smb = new IfxSmartBlob(myConn);
int loFd = smb.IfxLoCreate(loDesc, smb.LO_RDWR, loPtr);
int n = smb.IfxLoWrite(loFd, fin, fileLength);
smb.IfxLoClose(loFd);
loFd = smb.IfxLoOpen(loPtr, smb.LO_RDWR);
long m = smb.IfxLoSeek(loFd, 200, smb.LO_SEEK_SET);
The writing position is set at an offset of 200 bytes from the beginning of the smart large object.