Showing posts with label path. Show all posts
Showing posts with label path. Show all posts

Sunday, March 11, 2012

Choose path to travel on!!

Hi there

I am up against a condition where my control flow should be divided into threads and depending on value of a variable i have to choose 1 of the threads.

Its something like

if a =1 then execute this

else execute this one.

Thanks and Regards

Rahul Kumar, Software Enggineer

You need conditional precedence constraints. This article explains them:

Introduction to Expressions on Workflow
(http://www.sqlis.com/default.aspx?306)

-Jamie

|||

Thanks a lot,

Regards

Rahul Kumar, Software Engineer

Thursday, March 8, 2012

childitem issues with xmlnamespaces and for xml path

I am having problems with the namespaces when using XML type data
inside a for XMLpath..
here is the first example
----
--
WITH XMLNAMESPACES(DEFAULT 'http://www.ratdog.com/example' )
select
'karl' as "name",
(select
'1' as "mine/one",
'2' as "mine/two"
for xml path('child'), type
)
for xml path('outer'), type
----
<outer xmlns="http://www.ratdog.com/example">
<name>karl</name>
<child xmlns="http://www.ratdog.com/example">
<mine>
<one>1</one>
<two>2</two>
</mine>
</child>
</outer>
----
you'll notice that it added the namespace to the "inner child" :),
which i'd rather it not do but at least its correct and it works.
however in the following example i put the "inner child" sql inside a
function as show :
----
create function dbo.testfunc()
returns XML
as
begin
return
(
select
'1' as "mine/one",
'2' as "mine/two"
for xml path('child'), type
)
end
WITH XMLNAMESPACES(DEFAULT 'http://www.ratdog.com/example' )
select
'karl' as "name",
dbo.testfunc()
for xml path('outer'), type
---
<outer xmlns="http://www.ratdog.com/example">
<name>karl</name>
<child xmlns="">
<mine>
<one>1</one>
<two>2</two>
</mine>
</child>
</outer>
---
and it puts the namespace as "", which i definately don't want.. i
don't want that clause in there at all
how can i get rid of it? or achieve a suitable workaround.
KarlNote that the function creates a document that has no namespace associated
with it. Since you include it in one that has the prefix, we have to
undeclare the default prefix.
So if you want to have the function have the same default namespace, you
need to use the WITH clause in the function.
And no, we currently do not remove the declarations on the inner level if
they are redundant...
Best regards
Michael
<klumsy@.xtra.co.nz> wrote in message
news:1144364933.977174.287100@.u72g2000cwu.googlegroups.com...
> I am having problems with the namespaces when using XML type data
> inside a for XMLpath..
> here is the first example
> ----
--
> WITH XMLNAMESPACES(DEFAULT 'http://www.ratdog.com/example' )
> select
> 'karl' as "name",
> (select
> '1' as "mine/one",
> '2' as "mine/two"
> for xml path('child'), type
> )
> for xml path('outer'), type
> ----
> <outer xmlns="http://www.ratdog.com/example">
> <name>karl</name>
> <child xmlns="http://www.ratdog.com/example">
> <mine>
> <one>1</one>
> <two>2</two>
> </mine>
> </child>
> </outer>
> ----
> you'll notice that it added the namespace to the "inner child" :),
> which i'd rather it not do but at least its correct and it works.
> however in the following example i put the "inner child" sql inside a
> function as show :
> ----
> create function dbo.testfunc()
> returns XML
> as
> begin
> return
> (
> select
> '1' as "mine/one",
> '2' as "mine/two"
> for xml path('child'), type
> )
> end
> WITH XMLNAMESPACES(DEFAULT 'http://www.ratdog.com/example' )
> select
> 'karl' as "name",
> dbo.testfunc()
> for xml path('outer'), type
> ---
> <outer xmlns="http://www.ratdog.com/example">
> <name>karl</name>
> <child xmlns="">
> <mine>
> <one>1</one>
> <two>2</two>
> </mine>
> </child>
> </outer>
> ---
> and it puts the namespace as "", which i definately don't want.. i
> don't want that clause in there at all
> how can i get rid of it? or achieve a suitable workaround.
> Karl
>

Saturday, February 25, 2012

Checking whether an external image exists

Hello,
I have a table containing an image with dynamic content. My dataset gives
me a path to the image, now I can't be sure that the image actually exists
in the file system so I check using File.Exists. This works fine on my development
box but when I deploy it to my production environment, File.Exists returns
false no matter what.
Thinking it might be a security issue I moved the files from the original
fileshare and placed them on the Reporting Services server locally. No effect.
Along those lines I created a small test application which uses the same
File.Exists method. The app is able to verify the files which exist correctly.
I'm at a loss as to what to try out next, so any help is greatly appreciated.
--
Med venlig hilsen,
Søren Lund
www.publicvoid.dkAs is often the case I found a solution shortly after posting this and I
thought I'd share in case some of you comes across something similar.
http://www.publicvoid.dk/NETMethodsRequiringSpecialPermissionsWithinReportingServices.aspx
Med venlig hilsen,
Søren Lund
www.publicvoid.d

Thursday, February 16, 2012

checking for file existence within an udf

hi ng,
hi friends,
i've a problem within an udf to find out wheter a file or a path exists or
not. unc pathes and wildcards have to be supported.
i've already checked the following solutions:
- exec master..xp_fileexist @.filename, @.file_exists=@.exists output
=> wildcards are not supported
=> pathes can't be checked
- exec master..sp_MSget_file_existence @.filename,@.exists=@.exists output
=> no extended stored procedure but works perfect in tsql
=> stored procedures can't be used in udfs
- exec master..xp_cmdshell @.command
=> no reuseable output value
maybe someone can help me.
thanks
dengo
-- hope you'll understand my englishxp_cmdshell *does* return a usable output value. Try this:
declare @.i as integer
exec @.i = master..xp_cmdshell 'dir c:\config.* /b'
print @.i
If @.i = 0 then the command executed successfully and one or more matching
files were found. If @.i <> 0, then no file was found or there was an error,
as might be the case here:
declare @.i as integer
exec @.i = master..xp_cmdshell 'dir c:\config.zzzz* /b'
print @.i
"Robert Denkmayr" <RobertDenkmayr@.discussions.microsoft.com> wrote in
message news:0D9C2CCD-B335-479C-B10B-E944D34A74FF@.microsoft.com...
> hi ng,
> hi friends,
> i've a problem within an udf to find out wheter a file or a path exists or
> not. unc pathes and wildcards have to be supported.
> i've already checked the following solutions:
> - exec master..xp_fileexist @.filename, @.file_exists=@.exists output
> => wildcards are not supported
> => pathes can't be checked
> - exec master..sp_MSget_file_existence @.filename,@.exists=@.exists output
> => no extended stored procedure but works perfect in tsql
> => stored procedures can't be used in udfs
> - exec master..xp_cmdshell @.command
> => no reuseable output value
> maybe someone can help me.
> thanks
> dengo
> -- hope you'll understand my english|||hi michael,
thanks for your reply.
you're right but your reply is my answer - see returncode on errors.
additional a remark from <sp_MSget_file_existence>.
/*
** The return code from xp_cmdshell is not a reliable way to check whether
** the file exists or not. It is always 0 on Win95 as long as xp_cmdshell
succeeds.
*/
another weak spot is that you need an other command for checking the
existence of a path.
dengo
"Michael C#" wrote:

> xp_cmdshell *does* return a usable output value. Try this:
> declare @.i as integer
> exec @.i = master..xp_cmdshell 'dir c:\config.* /b'
> print @.i
> If @.i = 0 then the command executed successfully and one or more matching
> files were found. If @.i <> 0, then no file was found or there was an erro
r,
> as might be the case here:
> declare @.i as integer
> exec @.i = master..xp_cmdshell 'dir c:\config.zzzz* /b'
> print @.i
> "Robert Denkmayr" <RobertDenkmayr@.discussions.microsoft.com> wrote in
> message news:0D9C2CCD-B335-479C-B10B-E944D34A74FF@.microsoft.com...
>
>|||Ahhh you're using Win95 are ya? Wowsa.
I haven't done anything on Win95 with this, but if you have a Win95 box
handy, you might try it out and see if it counts a "No Files Found" error as
a success or not. I have used this method on Win2K, XP Pro and 2003 Server
with no issues.
You might check out xp_dirtree or xp_subdirs for paths. I'd think you'd
need some sort of custom solution if you want to return two separate codes -
one for the existence of a path, and one for the existence of a file.
"Robert Denkmayr" <RobertDenkmayr@.discussions.microsoft.com> wrote in
message news:5E0B835F-FCD7-4770-9C08-B84922D5F8C1@.microsoft.com...
> hi michael,
> thanks for your reply.
> you're right but your reply is my answer - see returncode on errors.
> additional a remark from <sp_MSget_file_existence>.
> /*
> ** The return code from xp_cmdshell is not a reliable way to check whether
> ** the file exists or not. It is always 0 on Win95 as long as xp_cmdshell
> succeeds.
> */
> another weak spot is that you need an other command for checking the
> existence of a path.
> dengo
>
> "Michael C#" wrote:
>|||no i'm not using win95.
for the first time the udf will be used by dts packages on w2k server where
dynamic filename assignment is necessary to avoid overwriting existing files
or using prior created paths. that's why i need a reliable solution.
at the moment i'll implement 'xp_cmdshell' with the appropriate command
either for a filename or a path.
because i'm not familiar with programming in c/c++ the most preferred
solution would be a dll for an extended stored procedure like the
'xpstar.dll' which contains the function for 'xp_fileexists'.
another step would be the sourcecode of 'xpstar.dll' so i could extract the
necessary code for a new dll with the new function.
"Michael C#" wrote:

> Ahhh you're using Win95 are ya? Wowsa.
> I haven't done anything on Win95 with this, but if you have a Win95 box
> handy, you might try it out and see if it counts a "No Files Found" error
as
> a success or not. I have used this method on Win2K, XP Pro and 2003 Serve
r
> with no issues.
> You might check out xp_dirtree or xp_subdirs for paths. I'd think you'd
> need some sort of custom solution if you want to return two separate codes
-
> one for the existence of a path, and one for the existence of a file.
>|||If you're interested in creating your own XP's, here's an article on the
subject: http://www.codeproject.com/database/extended_sp.asp.
You could also look at generating a filename and path using GetDate() and a
random #, and/or a counter value stored in a table which you could increment
each time a new file is created. Not sure of the specifics of your
application, but those are a couple ideas which might work in some
circumstances.
"Robert Denkmayr" <RobertDenkmayr@.discussions.microsoft.com> wrote in
message news:CCD5EF04-52E8-42BA-A9F3-472986C53A6A@.microsoft.com...
> no i'm not using win95.
> for the first time the udf will be used by dts packages on w2k server
> where
> dynamic filename assignment is necessary to avoid overwriting existing
> files
> or using prior created paths. that's why i need a reliable solution.
> at the moment i'll implement 'xp_cmdshell' with the appropriate command
> either for a filename or a path.
> because i'm not familiar with programming in c/c++ the most preferred
> solution would be a dll for an extended stored procedure like the
> 'xpstar.dll' which contains the function for 'xp_fileexists'.
> another step would be the sourcecode of 'xpstar.dll' so i could extract
> the
> necessary code for a new dll with the new function.
>
> "Michael C#" wrote:
>|||i had the same ideas as you can see in a sample of the first implementation
below:
'p2lgb_%y%m%d_%n.txt' ... data file
'p2lgb_%y%m%d_%n.err' ... error file
'\\dfs.dom\dfs\sem' ... interface path
'\\dfs.dom\dfs\archiv\sem\%y' ... archiv path
%y=year, %m=month, %d=day ... using getdate()
%n=unique number ... counter value stored in a table
the problem in this implementation is the unique number. i can't be sure
that the next
number isn't used manually by an user or it's already used in the archiv
directory => check for file existence.
at the new (second) implementation i should check both the interface and
archiv paths for the first unused number (starting at 1) => check for file
existence.
i'll examine the article about writing xp's tomorrow because i'm from
austria and it's already 11:15 pm.
thanks and good night
dengo
"Michael C#" wrote:

> If you're interested in creating your own XP's, here's an article on the
> subject: http://www.codeproject.com/database/extended_sp.asp.
> You could also look at generating a filename and path using GetDate() and
a
> random #, and/or a counter value stored in a table which you could increme
nt
> each time a new file is created. Not sure of the specifics of your
> application, but those are a couple ideas which might work in some
> circumstances.
>