xpath position() function always returning 0 when used in sql processor

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

xpath position() function always returning 0 when used in sql processor

James Liang
Hi all,

I am using the sql processor to insert some xml list data into a
table.  The database table has a "display_order" column which should
be the position() of the of xml node currently being inserted.

xml data:

<some_table>
  <row name='a' />
  <row name='b' />
  <row name='c' />
</some_table>

sql processor script snippet:

<sql:execute>
<sql:update select="/some_table/row">
insert into some_table
set
name = <sql:param type="xs:string" select="@name" />,
display_order = <sql:param type="xs:int" select="position()" />;
</sql:update>
</sql:execute>

When I ran this, the display_order is 0 for all rows inserted.

What am I doing wrong?

Thanks,
James


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xpath position() function always returning 0 when used in sql processor

Erik Bruchez
Administrator
James,

You might have some luck with the $position variable instead.

-Erik

On Sun, Jun 5, 2011 at 4:51 PM, James Liang <[hidden email]> wrote:

> Hi all,
>
> I am using the sql processor to insert some xml list data into a
> table.  The database table has a "display_order" column which should
> be the position() of the of xml node currently being inserted.
>
> xml data:
>
> <some_table>
>  <row name='a' />
>  <row name='b' />
>  <row name='c' />
> </some_table>
>
> sql processor script snippet:
>
> <sql:execute>
> <sql:update select="/some_table/row">
> insert into some_table
> set
> name = <sql:param type="xs:string" select="@name" />,
> display_order = <sql:param type="xs:int" select="position()" />;
> </sql:update>
> </sql:execute>
>
> When I ran this, the display_order is 0 for all rows inserted.
>
> What am I doing wrong?
>
> Thanks,
> James
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>
>


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws