Menu
Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
Database
Database General Discussion
How to handle an error in TSQL and take control of the stored procedure
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="robert54" data-source="post: 184701" data-attributes="member: 69596"><p>I never have learned error trapping in T-SQL. Darn. Sometimes curl.xget in</p><p></p><p>[CODE=vbnet]SELECT @JSON = curl.xget(null, ''+@GETSTRING+'')</p><p></p><p>INSERT INTO [pcrd].[stg1_fredSeries]</p><p> ([SeriesCode]</p><p> ,[realStartTime]</p><p> ,[realEndTime]</p><p> ,[observationDate]</p><p> ,[observationValue]</p><p> ,[etl_dateUpdate]</p><p> ,[ETL_UserUpdate]</p><p> ,fk_series_id</p><p> ,api_url)</p><p> SELECT</p><p> @SERIES_CODE AS SeriesID,</p><p> *,</p><p> GETDATE() AS etl_dateUpdate,</p><p> 'sp_get_fredSeriesPCTpe4' AS etl_userUpdate,</p><p> @api_type,</p><p> @GETSTRING</p><p> FROM</p><p> OPENJSON(@JSON,'$.observations') [/CODE]</p><p></p><p></p><p>Throws an error:</p><p></p><p>[CODE=vbnet]Msg 6522, Level 16, State 1, Procedure pcrd.sp_get_fredSeriesPCType4, Line 72 [Batch Start Line 20]</p><p>A .NET Framework error occurred during execution of user-defined routine or aggregate "XGET":</p><p>System.Net.WebException: The remote server returned an error: (400) Bad Request.</p><p>System.Net.WebException:</p><p>at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)</p><p>at System.Net.WebClient.DownloadString(Uri address)</p><p>at Curl.Get(SqlChars H, SqlChars url)[/CODE]</p><p></p><p></p><p>Is this just a matter or raising an error and looking for Msg 6522? This insert and the building of the @GETSTRING is in a cursor fetch. Can there be a BEGIN TRY in a cursor fetch? Assuming this is the way to go.</p></blockquote><p></p>
[QUOTE="robert54, post: 184701, member: 69596"] I never have learned error trapping in T-SQL. Darn. Sometimes curl.xget in [CODE=vbnet]SELECT @JSON = curl.xget(null, ''+@GETSTRING+'') INSERT INTO [pcrd].[stg1_fredSeries] ([SeriesCode] ,[realStartTime] ,[realEndTime] ,[observationDate] ,[observationValue] ,[etl_dateUpdate] ,[ETL_UserUpdate] ,fk_series_id ,api_url) SELECT @SERIES_CODE AS SeriesID, *, GETDATE() AS etl_dateUpdate, 'sp_get_fredSeriesPCTpe4' AS etl_userUpdate, @api_type, @GETSTRING FROM OPENJSON(@JSON,'$.observations') [/CODE] Throws an error: [CODE=vbnet]Msg 6522, Level 16, State 1, Procedure pcrd.sp_get_fredSeriesPCType4, Line 72 [Batch Start Line 20] A .NET Framework error occurred during execution of user-defined routine or aggregate "XGET": System.Net.WebException: The remote server returned an error: (400) Bad Request. System.Net.WebException: at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) at System.Net.WebClient.DownloadString(Uri address) at Curl.Get(SqlChars H, SqlChars url)[/CODE] Is this just a matter or raising an error and looking for Msg 6522? This insert and the building of the @GETSTRING is in a cursor fetch. Can there be a BEGIN TRY in a cursor fetch? Assuming this is the way to go. [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
Database
Database General Discussion
How to handle an error in TSQL and take control of the stored procedure
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom