PDA

View Full Version : sql query


pixel
03-11-2008, 17:31
in a break from tradition for this place, i actually need some assistance that is work related, so im posting it in the working hours section...

ive written for the following query:


declare @contno varchar(10), @filename varchar(128), @name varchar(128), @i int
select @contno='CEN/003469', @filename='', @name=''

DECLARE doc_cursor CURSOR FOR
SELECT [filename],[name] FROM ContDoc where contno=@contno

OPEN doc_cursor

FETCH NEXT FROM doc_cursor
INTO @filename, @name

WHILE @@FETCH_STATUS = 0
BEGIN

exec master..xp_fileexist @filename, @i out

if @i=1
print ''+@contno+': '+@filename+' exists'
else
print ''+@contno+': '+@filename+' does not exist'

END

CLOSE doc_cursor
DEALLOCATE doc_cursor


this query is meant to utilise the xp_fileexist route to scan the filesystem and check if the file exists, however upon run it just sits there indefinitely (4 minutes so far)

any ideas?

pixel
03-11-2008, 17:37
nevermind, worked it out myself coz i r leet


SET NOCOUNT ON

declare @contno varchar(10), @filename varchar(128), @name varchar(128), @i int
select @contno='CEN/003469', @filename='', @name=''

DECLARE doc_cursor CURSOR FOR
SELECT [filename],[name] FROM ContDoc where contno=@contno

OPEN doc_cursor

FETCH NEXT FROM doc_cursor
INTO @filename, @name

WHILE @@FETCH_STATUS = 0
BEGIN

exec master..xp_fileexist @filename, @i out

if @i=1
print ''+@contno+': '+@filename+' exists'
else
print ''+@contno+': '+@filename+' does not exist'

FETCH NEXT FROM doc_cursor
INTO @filename, @name

END

CLOSE doc_cursor
DEALLOCATE doc_cursor

hinch
03-11-2008, 17:37
the only thing that springs to mind is why the fuck are you doing a os file check in a stored proc oO your locking a db read thread for checking a file system you'd be much better doing that check in code than in query.

pixel
03-11-2008, 17:45
quick fix on a customers system :)

hinch
03-11-2008, 17:47
you are hense forth banned from touching code tbh :)

pixel
03-11-2008, 17:54
its not a quick fix that has come about due to my own oversight, i got reassigned on friday from development to 3rd line support (i have a whole team consisting of just me) to bridge the gap between development and support... i still get to step through code for problem shooting but now i just have a job that i can do while half asleep, which is excellent for me...

the code that this is quickfixing is several years old so far predates me joining the company... and there is only one site out of thousands with the problem

vampire
03-11-2008, 17:59
Conclusion: Never let a Danish company design your sql infrastructure.

Na im just being a meanie...

pixel
03-11-2008, 18:03
im surprised i didn't get a 'thats a lil geeky for a girl' etc, thats what i got from the guys on support after writing this for them :/

hinch
03-11-2008, 18:07
i know a fair few females who are very very good coders i see no reason why a girl can't do this job as good as any male just most of them don't choose this directly in career as they see it as too geeky themselves

pixel
03-11-2008, 18:09
exactly what i said! i duno i just guess most guys are still a lil unused to the fact

Carl
03-11-2008, 18:47
I see lots of girls at car shows and stuff (not working there) with some serious cars.

Some of them like to make it a point that they are girls, one of them has an expensive bra in a custom fabricated and lit display case in the trunk of her S15.

I should do the same with my skid marked grundies, wonder if it will generate the same effect.

pixel
03-11-2008, 18:50
i see people slipping off topic :P

Carl
03-11-2008, 19:01
I'm just keeping up with traffic :P

giga191
03-11-2008, 19:06
That's a mighty fine query you have there, top draw

pixel
03-11-2008, 19:37
are you being sarcastic again giga?

vampire
03-11-2008, 20:01
are you being sarcastic again giga?

No didn't you know, giga is like one of the best 0.1% sql experts in the world...