Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Update image into MsSQL2005

2 posts in Powerscript Last posting was on 2010-01-05 21:21:57.0Z
budhi Posted on 2009-12-24 04:04:49.0Z
From: "budhi" <budhi@apfserver.com>
Newsgroups: sybase.public.powerbuilder.powerscript
Subject: Update image into MsSQL2005
Lines: 60
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b32e861@forums-1-dub>
Date: 23 Dec 2009 20:04:49 -0800
X-Trace: forums-1-dub 1261627489 10.22.241.152 (23 Dec 2009 20:04:49 -0800)
X-Original-Trace: 23 Dec 2009 20:04:49 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.powerscript:27214
Article PK: 793626

Hi All , I have a problem with storing Image into my MsSQL2005 database. The
Image never retrievecorrectly. Help me to find the mistake.

Thank You


I try to save my picture into my database using SQL Syntax , example :

UPDATEBLOB msbarang SET b_picture = :Emp_id_picWHERE b_kode = 'L00001';

But when I retrieve again the image, with this script

ls_filename = 'imagedata.jpg'
SELECTBLOB b_picture INTO :imagedata FROM msbarang WHERE b_kode =
'L00001' USING sqlca;
of_filewrite ( ls_filename, imagedata )
dw_1.object.p_1.FileName = ls_filename

// of_filewrite Function //

Function of_filewrite ( as_FileName string, ablb_data blob )

integer li_FileNo, li_Writes, li_Cnt
long ll_BlobLen, ll_CurrentPos
blob lblb_Data

li_FileNo = FileOpen(as_FileName, StreamMode!, Write!, LockReadWrite!,
Replace! )
If li_FileNo < 0 Then Return -1

ll_BlobLen = Len(ablb_Data)

// Determine the number of writes required to write the entire blob
If ll_BlobLen > 32765 Then
If Mod(ll_BlobLen, 32765) = 0 Then
li_Writes = ll_BlobLen / 32765
Else
li_Writes = (ll_BlobLen / 32765) + 1
End if
Else
li_Writes = 1
End if

ll_CurrentPos = 1

For li_Cnt = 1 To li_Writes
lblb_Data = BlobMid(ablb_Data, ll_CurrentPos, 32765)
ll_CurrentPos += 32765
If FileWrite(li_FileNo, lblb_Data) = -1 Then
Return -1
End if
Next

FileClose(li_FileNo)

Return 1

// end of_filewrite Function //


cch Posted on 2010-01-05 21:21:57.0Z
From: "cch" <cchamorro@arazozabrothers.com>
Newsgroups: sybase.public.powerbuilder.powerscript
References: <4b32e861@forums-1-dub>
Subject: Re: Update image into MsSQL2005
Lines: 67
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4b43ad75$1@forums-1-dub>
Date: 5 Jan 2010 13:21:57 -0800
X-Trace: forums-1-dub 1262726517 10.22.241.152 (5 Jan 2010 13:21:57 -0800)
X-Original-Trace: 5 Jan 2010 13:21:57 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.powerbuilder.powerscript:27225
Article PK: 761768

Make sure your variable imagedata is declared as a blob. It should work ok.
did you debug the proccess?

"budhi" <budhi@apfserver.com> wrote in message news:4b32e861@forums-1-dub...
> Hi All , I have a problem with storing Image into my MsSQL2005 database.
> The Image never retrievecorrectly. Help me to find the mistake.
>
> Thank You
>
>
> I try to save my picture into my database using SQL Syntax , example :
>
> UPDATEBLOB msbarang SET b_picture = :Emp_id_picWHERE b_kode =
> 'L00001';
>
> But when I retrieve again the image, with this script
>
> ls_filename = 'imagedata.jpg'
> SELECTBLOB b_picture INTO :imagedata FROM msbarang WHERE b_kode =
> 'L00001' USING sqlca;
> of_filewrite ( ls_filename, imagedata )
> dw_1.object.p_1.FileName = ls_filename
>
> // of_filewrite Function //
>
> Function of_filewrite ( as_FileName string, ablb_data blob )
>
> integer li_FileNo, li_Writes, li_Cnt
> long ll_BlobLen, ll_CurrentPos
> blob lblb_Data
>
> li_FileNo = FileOpen(as_FileName, StreamMode!, Write!, LockReadWrite!,
> Replace! )
> If li_FileNo < 0 Then Return -1
>
> ll_BlobLen = Len(ablb_Data)
>
> // Determine the number of writes required to write the entire blob
> If ll_BlobLen > 32765 Then
> If Mod(ll_BlobLen, 32765) = 0 Then
> li_Writes = ll_BlobLen / 32765
> Else
> li_Writes = (ll_BlobLen / 32765) + 1
> End if
> Else
> li_Writes = 1
> End if
>
> ll_CurrentPos = 1
>
> For li_Cnt = 1 To li_Writes
> lblb_Data = BlobMid(ablb_Data, ll_CurrentPos, 32765)
> ll_CurrentPos += 32765
> If FileWrite(li_FileNo, lblb_Data) = -1 Then
> Return -1
> End if
> Next
>
> FileClose(li_FileNo)
>
> Return 1
>
> // end of_filewrite Function //
>