Re: [SQL] Image Insert Postgresql DB
I use VB as develop tool and ADO for connect. My code is show below and for vPicMember is stand ADOStream in Binary. rs.Open "SELECT * FROM t_mbrpic WHERE mbrsysid = " & vSysId, conn, adOpenStatic, adLockOptimistic If rs.EOF Then rs.AddNew rs!MbrSysId = vSysId rs!MbrPic = vPicMember.Read rs.Update rs.Close In this case, Is I must still escape the octets with \\ that is two backslashes? Could anybody has some suggestion? >>> Kenneth Gonsalves <[EMAIL PROTECTED]> 23/11/2004 2:40:27 pm >>> On Tuesday 23 November 2004 12:48 pm, Premsun Choltanwanich wrote: > I face this same problem when I try to insert image by lo_import to > database with my client files. I already change the way to bytea data > type but it's not work. The error return like type mismatch when I try > to insert it from Binary variable. > > Why I cannot insert it? If anybody found some solution please reply on > this topic for me too. you must escape the octets with \\ that is two backslashes and not one backslash. for example if your binary data is like this: \x05\x00\x02 you must make it like so: \\x05\\x00\\x02 please see chapter 8.4 of the postgresql manual. kg ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
Re: [SQL] Image Insert Postgresql DB
On Tuesday 23 November 2004 01:49 pm, Premsun Choltanwanich wrote: > I use VB as develop tool and ADO for connect. My code is show below and > for vPicMember is stand ADOStream in Binary. > > rs.Open "SELECT * FROM t_mbrpic WHERE mbrsysid = " & vSysId, conn, > adOpenStatic, adLockOptimistic > If rs.EOF Then rs.AddNew > rs!MbrSysId = vSysId > rs!MbrPic = vPicMember.Read > rs.Update > rs.Close i use python, and have no idea about ado, this might help: http://gborg.postgresql.org/project/psqlodbc/genpage.php?howto-vblo kg ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [SQL] Image Insert Postgresql DB
I already try it on last week. Unfortunately that I cannot create the lo type using the appropriate functions available in contrib/lo in the Postgresql source tree because library file cannot be loaded. (I use PostgreSQL 8.0 Beta1 as Database backend.) However, it's look like a solution for this problem if I can create this lo type. >>> Kenneth Gonsalves <[EMAIL PROTECTED]> 23/11/2004 4:29:29 pm >>> On Tuesday 23 November 2004 01:49 pm, Premsun Choltanwanich wrote: > I use VB as develop tool and ADO for connect. My code is show below and > for vPicMember is stand ADOStream in Binary. > > rs.Open "SELECT * FROM t_mbrpic WHERE mbrsysid = " & vSysId, conn, > adOpenStatic, adLockOptimistic > If rs.EOF Then rs.AddNew > rs!MbrSysId = vSysId > rs!MbrPic = vPicMember.Read > rs.Update > rs.Close i use python, and have no idea about ado, this might help: http://gborg.postgresql.org/project/psqlodbc/genpage.php?howto-vblo kg ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings
Re: [SQL] Image Insert Doubt
First please tell us what interfacing program you are using. ? -- With Best Regards, Vishal Kashyap. Lead Software Developer, http://saihertz.com, http://vishalkashyap.tk ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster
Re: [SQL] NULLS and string concatenation
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Gregory S. Williamson wrote: | Someone on this list provided me with a rather elegant solution to this a few weeks ago: | | CREATE OR REPLACE FUNCTION text_concat_nulls_with_an_embedded_space(text, text) | RETURNS text | AS 'SELECT CASE WHEN $1 IS NULL THEN $2 WHEN $2 IS NULL THEN $1 ELSE $1 || '' '' || $2 END' | LANGUAGE sql; Ugly. As the previous poster mentioned, handling NULLs is what COALESCE is for. CREATE OR REPLACE FUNCTION text_concat_nulls_with_an_embedded_space(text,text) IMMUTABLE CALLED ON NULL INPUT RETURNS text AS 'SELECT COALESCE($1 || '' '' || $2, $2, $1);' LANGUAGE sql; | CREATE OPERATOR ||~ (PROCEDURE = text_concat_nulls_with_an_embedded_space, LEFTARG = text, RIGHTARG = text); | | And I call it as: | SELECT (trim(s_directio) ||~ trim(s_house) ||~ trim(s_post_dir) ||~ trim(s_street) ||~ trim(s_suffix)) as street ... (yadda yadda) | | Deals quite neatly with the NULLs in some of the columns. Or my personal favourite: CREATE OR REPLACE FUNCTION comma_concat (text,text) IMMUTABLE CALLED ON NULL INPUT RETURNS text AS 'SELECT COALESCE ($1 || '','' || $2, $2);' LANGUAGE sql; CREATE AGGREGATE comma_concat ( ~BASETYPE=text, ~SFUNC=comma_concat, ~STYPE=text ); Which is handy for 1:n reports like SELECT grade, comma_concat($name) AS members FROM test_results GROUP BY grade; - -- Andrew Hammond416-673-4138[EMAIL PROTECTED] Database Administrator, Afilias Canada Corp. CB83 2838 4B67 D40F D086 3568 81FC E7E5 27AF 4A9A -BEGIN PGP SIGNATURE- Version: GnuPG v1.2.5 (GNU/Linux) iD8DBQFBo4yHgfzn5SevSpoRAgjrAJ9M5WwQE1FOaxcs7o45KjdKZF6AQACgkCKS V+qljFHFtYbOMcRU+7SawmY= =xqTu -END PGP SIGNATURE- ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
