[odb-users] Extended types SQL Server (table and/or xml type)

Fredrik Strand fredrik.strand at qliro.com
Mon Apr 27 03:55:30 EDT 2015


Thanks for the hints! Now I got a nice view how to use the XML type in normal queries. 

However, I can't really see how it will be used when using stored procedures. At the moment I'm calling a stored procedure as stated in the documentation under 21.7 SQL Server Stored Procedures:

#pragma db view query("EXEC....")
object

Db.query<object>(query:_val(value))....


In this case I'm just using a std::string as value and it automagically maps to an nvarchar in the procedure. Since I can't specify the actual type in the call how do I specify that it's an XML argument that I want to send/use?

Regards,
Fredrik

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Friday, April 24, 2015 5:13 PM
To: Fredrik Strand
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] Extended types SQL Server (table and/or xml type)

Hi Fredrik,

Fredrik Strand <fredrik.strand at qliro.com> writes:

> I want to execute a stored procedure in SQL Server with XML or table 
> type as an argument.

XML should be pretty straightforward. You will need to pieces of
information:

"Extended Database to C++ Type Mapping in ODB":

http://www.codesynthesis.com/~boris/blog/2012/07/18/custom-database-to-cxx-type-mapping-in-odb/

And the mssql/custom/ test from the odb-tests package. This test shows how to work with the XML type.

The table-valued parameters are a lot harder. Perhaps one could map them to XML using stored procedures. I don't think, however, this will be a general-purpose solution (i.e., it will be specific to the table types of an application), though who knows.

There are also plans (in the early stage) to have proper support for table-valued parameters using the ODBC support.

Boris



More information about the odb-users mailing list