Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem:datetime&logical data expression in XML
Message
 
 
À
21/01/2005 01:47:09
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00979190
Message ID:
00979541
Vues:
21
This message has been marked as the solution to the initial question of the thread.
Hi Steven,

The date in XML is in the XML DateTime format and OPENXML has no problem converting it back to datetime. The logical field, on other hand, is a problem because SQL Server doesn't have logical data type. The bit data type is a numeric (integer) data type. You can do some post-processing to convert true/false to 1/0. Something like
cxml = STRTRAN(STRTRAN(cXml, "true", "1"), "false", "0")
> When I pass a XML string generated by vfp9 function cursortoxml() to a SQL SERVER 2000 stored procedure for parsing with openxml(),encountered a problem that Datetime data & Logic data is not able to be parsed into related rowset columns defined with colpattern patameters by respective Datetime and Bit field-type.Via checking the XML string at side of VFP,found a 'T' was inserted between the Date portion and time portion of datetime-type data i.e.
>"2000-10-03 02:02:02"->"2000-10-03T02:02:02",and .t.,.f. were converted into "true","false".
>
> Any ideas? The sample codes below are FYI:
>
> VFP9:-
>
>       create cursor  tmp ( f1 t, f2 L)
>       INSERT INTO  tmp values(DATETIME(),.t.)
>       INSERT INTO  tmp values(DATETIME(),.f.)
>       select tmp
>       BROWSE
>       ?CURSORTOXML("tmp","cxml",1,0,0)
>       ?cxml
>       ?SQLEXEC(_screen.sqlhnd,"exec ReadXml ?cxml",'sql_cur') && set your own SQL handle
>       select sql_cur
>       BROWSE
>
>SQL SP:-
>
>    CREATE PROCEDURE  ReadXML
>    (
>     @xml  text
>     )
>    as
>    declare @xdoc int
>    exec sp_xml_preparedocument @xdoc output, @xml
>    select a.*   from openxml (@xdoc, '/VFPData/tmp', 2) with (f1 datetime,f2  bit) as a
>    exec sp_xml_removedocument @xdoc
>    GO
>
> However,if
>
... with (f1 datetime,f2  bit) ...
is rewrited as
>
... with (f1 varchar(20),f2 varchar(10)) ...
> the procedure can perform with no problem.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform