Created
March 29, 2018 14:42
-
-
Save saiteja09/8465403c603bdfdc6694f7932c310924 to your computer and use it in GitHub Desktop.
Script for Linked Server to query REST API using ODBC driver created using Progress DataDirect OpenAccess SDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE [Chinook2] | |
GO | |
/****** Object: StoredProcedure [dbo].[sp_stocksapi] Script Date: 3/29/2018 10:37:48 AM ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
CREATE PROCEDURE [dbo].[sp_stocksapi] | |
( | |
@pfunction varchar(100), | |
@psymbol varchar(5), | |
@pinterval varchar(10)) | |
AS | |
BEGIN | |
DECLARE @TSQL varchar(8000) | |
IF @pinterval is null | |
BEGIN | |
SELECT @TSQL='SELECT * FROM OPENQUERY(OPENACESSSTOCKS,''select INFORMATION,"FUNCTION",SYMBOL,LASTREFRESHED,"INTERVAL",OUTPUTSIZE,TIMEZONE,TIMESTAMP_RECORDED,OPEN,HIGH,LOW,CLOSE,CAST(VOLUME as decimal(38,6)) as volume FROM TIMESERIES WHERE "function" = ''''' + @pfunction + ''''' and symbol = '''''+ @psymbol + ''''''')' | |
END | |
IF @pinterval is not null | |
BEGIN | |
SELECT @TSQL='SELECT * FROM OPENQUERY(OPENACESSSTOCKS,''select INFORMATION,"FUNCTION",SYMBOL,LASTREFRESHED,"INTERVAL",OUTPUTSIZE,TIMEZONE,TIMESTAMP_RECORDED,OPEN,HIGH,LOW,CLOSE,CAST(VOLUME as decimal(38,6)) as volume FROM TIMESERIES WHERE "function" = ''''' + @pfunction + ''''' and symbol = '''''+ @psymbol + ''''' and "interval"=''''' +@pinterval+ ''''''')' | |
END | |
EXEC(@TSQL); | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment