Oracle中的XMLType

时间:2019-04-12 09:29:59

标签: oracle plsql xmltype

我在SQL Server中具有以下代码:

    CREATE PROCEDURE [dbo].[spParseCapIQCurrency](
    @XMLString varchar(max))
AS
BEGIN

   SET NOCOUNT ON;

   --Validate proper xml format; SQL does not allow TRYCAST on xml.
   DECLARE @XML xml 
   BEGIN TRY
    SET @XML= Cast(@XMLString as xml)
   END TRY
   BEGIN CATCH
    RAISERROR('XMLString not in XML format.',16,1)
    RETURN
   END CATCH

   DECLARE @CURRENCY_EXCHANGE table(StartDate date, Currency varchar(50), Rate float)

   DECLARE @TABLE table(Currency varchar(50), ExchangeRate float, XMLProps xml)   
   insert into @TABLE(Currency,ExchangeRate, XMLProps)
    select X.c.value('(Identifier)[1]', 'varchar(50)') as Currency,
           X.c.value('(Body/Rows/Row/C_V)[1]','float') as ExangeRate,          
           X.c.query('Properties') as XMLProps
        from @XML.nodes('/SDKClientResponse/DataArea/MultiResponse/SingleResponse') as X(c)

  DECLARE @IXStartDate int=2
  select X.c.value('(Value)[1]','varchar(50)') as 'StartDate',
        Currency, 
        ExchangeRate        
    from @TABLE
        cross apply XMLProps.nodes('/Properties/Property[position()=(sql:variable("@IXStartDate"))]') as X(c)

END

我必须将以上内容转换为PLSQL,因为我对Plsql相对较新,因此我发现这非常困难,而且我似乎没有找到有关xml数据类型主题的很多信息。 有人可以帮忙转换吗?可以转换吗?

0 个答案:

没有答案