Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

HOW TO WORK WITH BLOB OBJECT

kotapatikotapati Member Posts: 1
I WANT TO KNOW HOW TO CREATE A TABLE WITH BLOB DATATYPE AND HOW TO INSERT VALUES TO IT AND HOW TO RETRIEVE VALUES USING VB OR SQL *PLUS
THANK U

Comments

  • Ara_camAra_cam Member Posts: 37
    Here is a sample procedure that gets data from a BLOB data type.
    You'll need to clean it up for your purposes. This is in Visual Basic
    and uses ADO.
    [code]
    Public Sub GetCodeReport()
    'Note that this is a BLOB datatype, so cannot simply
    ' use SELECT...FROM to get the data.
    Dim rs As ADODB.Recordset
    Dim unitid, effdt, legend, sql, fname
    Dim mstream
    Dim lngSize, lngOffset As Long
    Dim varTemplate, varChunk
    Dim Conn As ADODB.Connection
    Set Conn = New ADODB.Connection
    Dim dbconnstring As String
    dbconnstring = "..." ' Put your database connect string here.
    Conn.ConnectionString = dbconnstring
    Conn.Open ' database now open
    Set rs = New ADODB.Recordset
    sql = "SELECT * FROM UNIT_REPORT "
    rs.Open sql, Conn, adOpenKeyset, adLockOptimistic
    Set mstream = New ADODB.Stream
    rs.MoveFirst
    Const conChunkSize = 600
    Do Until rs.EOF
    unitid = rs.Fields("id") 'VarChar2(10)
    effdt = rs.Fields("effdt") 'Date
    legend = rs.Fields("legend") 'Char(1)
    'Template LONG
    fname = App.Path & "unit_" & _
    unitid & "_" & Format(effdt, "mm-dd-yyyy") & ".txt"
    lngSize = rs!template.ActualSize
    'Get Long data here
    Do While lngOffset < lngSize
    varChunk = rs!template.GetChunk(conChunkSize)
    varTemplate = varTemplate & varChunk
    lngOffset = lngOffset + conChunkSize
    Loop 'get 1 chunk of data at a time until all is retrieved
    Open fname For Output As #1 'output LONG to text file.
    Print #1, varTemplate
    Close #1
    rs.MoveNext
    Loop
    rs.Close
    Conn.Close
    MsgBox "Done saving LONG data from database"
    Exit Sub
    Command1_Error:
    MsgBox Str(Err) & " - " & Error, vbExclamation
    End Sub
    [/code]


    : I WANT TO KNOW HOW TO CREATE A TABLE WITH BLOB DATATYPE AND HOW TO INSERT VALUES TO IT AND HOW TO RETRIEVE VALUES USING VB OR SQL *PLUS
    : THANK U
    :

Sign In or Register to comment.