Showing posts with label queried. Show all posts
Showing posts with label queried. Show all posts

Monday, March 26, 2012

How to insert a node, with value queried from another node

We're trying to move some of our data between nodes in an XML column.
I basically want to migrate:
FROM
<OldNodeParent>
<OldNode>1234</OldNode>
</OldNodeParent>
TO
<OldNodeParent>
<OldNode>1234</OldNode>
</OldNodeParent>
<NewNode>1234</NewNode>
I was trying something like (which doesn't work):
UPDATE MyTable
SET XmlColumn.modify('
insert <NewNode>(/OldNodeParent/OldNode)[1]</NewNode> as last
into (/)[1]
')
WHERE XmlColumn.exist('/OldNodeParent/OldNode') = 1
AND XmlColumn.exist('/NewNode') = 0
Any ideas on how this could be achieved?
Thanks,
LubdhaTry this
UPDATE MyTable
SET XmlColumn.modify('
insert
if (count(/NewNode) = 0)
then element NewNode {(/OldNodeParent/OldNode/text())[1]}
else ()
as last into (/)[1]
')|||More correctly
UPDATE MyTable
SET XmlColumn.modify('
insert
if ( (/OldNodeParent/OldNode/text()) and not (/NewNode) )
then element NewNode {(/OldNodeParent/OldNode/text())[1]}
else ()
as last into (/)[1]
')|||Wow! That worked like a charm, thanks a lot!

Sunday, February 19, 2012

How to hold report generation till "View Report" is clicked ?

I have a report, for which I have defined queried multi-valued default values for all the parameters.Now when I click on the report, it picks the default values automatically without clicking the “View Report” button.

Can we control this feature,so that unless user clicks on the “View Report” button, the report is not generated ?

The only way to get this behavior is to put a parameter on the report which is not nullable and has no default value. The viewer control will require the user select a value for this parameter before executing the report.

Another option is to not use the built-in UI, and instead use the viewer control in your application.