Professional Web Applications Themes

How to capture this error? - Microsoft SQL / MS SQL Server

I found codes like this: EXEC( 'DECLARE Handle int EXEC sp_xml_preparedoent Handle OUT, ''' + xml_0 + xml_1 + xml_2 + xml_3 + ''' DECLARE he_cur CURSOR FOR SELECT Handle' ) OPEN he_cur FETCH he_cur INTO xml_he DEALLOCATE he_cur IF xml_he IS NULL RAISERROR( 'Invalid Handle!', 16, 1 ) but I tried it on my Query yzer, it will stop and give me such error: Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedoent, Line 2 XML parsing error: Invalid at the top level of the doent. that means it will never reach the if check, any idea? thanks!...

  1. #1

    Default How to capture this error?

    I found codes like this:

    EXEC(
    'DECLARE Handle int
    EXEC sp_xml_preparedoent Handle OUT, ''' +
    xml_0 + xml_1 + xml_2 + xml_3 + '''
    DECLARE he_cur CURSOR FOR SELECT Handle'
    )
    OPEN he_cur
    FETCH he_cur INTO xml_he
    DEALLOCATE he_cur

    IF xml_he IS NULL
    RAISERROR( 'Invalid Handle!', 16, 1 )

    but I tried it on my Query yzer, it will stop and give me such error:

    Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedoent, Line
    2
    XML parsing error: Invalid at the top level of the doent.

    that means it will never reach the if check, any idea?

    thanks!


    davidw Guest

  2. #2

    Default Re: How to capture this error?

    Hi

    The EXEC will mean that the variable Handle and he_cur are out of scope.
    Create a procedure with a text parameter and pass xml_0 + xml_1 + xml_2 +
    xml_3 (assuming non of these are null).

    If you are wanting to validate the XML first then you should load it into a
    dom.

    SQLServer does not have a try/catch mechanism, but sp_xml_preparedoent
    will return 0 on success and >0 otherwise which you could check.

    HTH

    John

    "davidw" <wyx1999hotmail.com> wrote in message
    news:uBwmn0lQDHA.1752TK2MSFTNGP12.phx.gbl...
    > I found codes like this:
    >
    > EXEC(
    > 'DECLARE Handle int
    > EXEC sp_xml_preparedoent Handle OUT, ''' +
    > xml_0 + xml_1 + xml_2 + xml_3 + '''
    > DECLARE he_cur CURSOR FOR SELECT Handle'
    > )
    > OPEN he_cur
    > FETCH he_cur INTO xml_he
    > DEALLOCATE he_cur
    >
    > IF xml_he IS NULL
    > RAISERROR( 'Invalid Handle!', 16, 1 )
    >
    > but I tried it on my Query yzer, it will stop and give me such error:
    >
    > Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedoent,
    Line
    > 2
    > XML parsing error: Invalid at the top level of the doent.
    >
    > that means it will never reach the if check, any idea?
    >
    > thanks!
    >
    >

    John Bell Guest

  3. #3

    Default Re: How to capture this error?

    Hi

    Ideally your XML will be checked before it is entered into the database.
    Containually creating/destroying the DOM will be a slow process.

    Check out [url]http://sqlxml.org/[/url]

    in particular:

    [url]http://sqlxml.org/faqs.aspx?faq=39[/url]
    [url]http://sqlxml.org/faqs.aspx?faq=61[/url]

    John

    "davidw" <wyx1999hotmail.com> wrote in message
    news:%23J9fbgzQDHA.3664tk2msftngp13.phx.gbl...
    > Thank you very much for you reply.
    >
    > From my experience, I know there is no try/cach mechanism in SQL, I am not
    > sure why a lot of people just give out those example as if they really did
    > try out.
    >
    > You said I need load xml to DOM if I want to validate it, do you mean I
    need
    > use sp_oacreate to create a MSXML2 object and call its method?
    >
    > I think dll like MSXML provive more functionality, the problem is that
    there
    > is not a easy way to get result like a table from them, am I right?
    >
    > I remember sp_xml_preparedoc and openxml are using MSXML to p xml, any
    > idea how openxml be implemented?
    >
    > Thanks
    >
    > "John Bell" <jbellnewspostshotmail.com> wrote in message
    > news:3f0733f4$0$5084$afc38c87news.easynet.co.uk.. .
    > > Hi
    > >
    > > The EXEC will mean that the variable Handle and he_cur are out of
    scope.
    > > Create a procedure with a text parameter and pass xml_0 + xml_1 +
    xml_2
    > +
    > > xml_3 (assuming non of these are null).
    > >
    > > If you are wanting to validate the XML first then you should load it
    into
    > a
    > > dom.
    > >
    > > SQLServer does not have a try/catch mechanism, but
    sp_xml_preparedoent
    > > will return 0 on success and >0 otherwise which you could check.
    > >
    > > HTH
    > >
    > > John
    > >
    > > "davidw" <wyx1999hotmail.com> wrote in message
    > > news:uBwmn0lQDHA.1752TK2MSFTNGP12.phx.gbl...
    > > > I found codes like this:
    > > >
    > > > EXEC(
    > > > 'DECLARE Handle int
    > > > EXEC sp_xml_preparedoent Handle OUT, ''' +
    > > > xml_0 + xml_1 + xml_2 + xml_3 + '''
    > > > DECLARE he_cur CURSOR FOR SELECT Handle'
    > > > )
    > > > OPEN he_cur
    > > > FETCH he_cur INTO xml_he
    > > > DEALLOCATE he_cur
    > > >
    > > > IF xml_he IS NULL
    > > > RAISERROR( 'Invalid Handle!', 16, 1 )
    > > >
    > > > but I tried it on my Query yzer, it will stop and give me such
    > error:
    > > >
    > > > Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedoent,
    > > Line
    > > > 2
    > > > XML parsing error: Invalid at the top level of the doent.
    > > >
    > > > that means it will never reach the if check, any idea?
    > > >
    > > > thanks!
    > > >
    > > >
    > >
    > >
    >
    >

    John Bell Guest

Similar Threads

  1. Paper Capture recognition service experienced an error (15000)
    By james_i._porter@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 1
    Last Post: September 19th, 09:26 PM
  2. Acrobat Pro 7.0.8 Paper Capture Recognition service commo error
    By John_Czyzewski@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 1
    Last Post: July 19th, 03:18 AM
  3. Capture Server Error
    By Richard_Sowa@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 22
    Last Post: May 4th, 04:28 PM
  4. How can I capture the Script timeout Error?
    By Mathieu Blais in forum ASP
    Replies: 8
    Last Post: September 29th, 02:46 PM
  5. tion DB2 V7.1 Capture error ASN0009E
    By Halberstadt in forum IBM DB2
    Replies: 1
    Last Post: September 17th, 11:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139