On Sep 24, 2007, at 03.31h, Hans Peter Würmli wrote:
>
>> import "x-alice:/lib/system/UnsafeComponent"
>> val c = Component.fromPackage(pack (val it = 666) : (val it : int))
>> val s = UnsafeComponent.pack_ c
>> val c' = UnsafeComponent.unpack_ s
>> val p = ComponentManager.eval(Url.fromString "", c')
>> open unpack p : (val it : int)
>
> The interface to sqlite though does not accept s as a string. For  
> example I
> tried on a table
>
> tpackages (id int, seamstring text)
>
> with above's s
>
> val updateTable = "update tpackages set seamstring='"^
>                             s ^
>                             "' where id=1"
> val ct : unit list   = await (SQLite.query(dbase,updateTable))
>
> and received the error:
>
> Uncaught exception
>    SQLError "unrecognized token: \"'seam\^E\""

No surprise, since s isn't really a printable string - it may contain  
arbitrary characters, particularly control codes and SQL's end-of- 
string character.

The solution is to use quoting, i.e. translate the string using the  
String.toCString and String.fromCString functions. AFAIK, SQL uses  
the same escape syntax as C.

> I also tried with a blob column, but realised that I wouldn't  
> really know how
> to feed, say, a package to the insert-into-a-blob-column statement.
>
> Would you know of a way to do that?

Sorry, I have never used blobs, so I have no idea. I don't think  
there is a way to insert it directly from the ML heap using the  
SQLite binding. Maybe you can insert it from a file somehow?

- Andreas





_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to