Call SQL Server function through the gateway
Hello, Does anyone know if it is possible to call a SQL Server system function such as SERVERPROPERTY through the gateway?
I'd like to call a system function in the same way as a user defined function and not using DBMS_HS_PASSTHROUGH.
Maybe I need to be a little bit more precise. It really depends on the data types being returned. When you look at the SERVERPROPERTY function you mentioned earlier and try to select for example the Collation, then SQl Server will return a SQL_VARIANT data type and that will fail - even using passthrough as SQL_VARIANT is not a supported data type.
Let me use the passthrough example as it allows me to demonstrate it easily:
SQL> SQL> declare
2 val varchar2(100);
3 c integer;
4 nr integer;
5 begin
6 c:= dbms_hs_passthrough.open_cursor@DG4MSQL_EMGTW_1123_DB;
7 dbms_hs_passthrough.parse@DG4MSQL_EMGTW_1123_DB (c, 'SELECT SERVERPROPERTY(''Collation'') as Collation');
8 LOOP
9 nr:= DBMS_Hs_Passthrough.fetch_row@DG4MSQL_EMGTW_1123_DB(c);
10 exit when nr=0;
11 dbms_hs_passthrough.get_value@DG4MSQL_EMGTW_1123_DB(c,1,val);
12 dbms_output.put_line(val);
13 end loop;
14 dbms_hs_passthrough.close_cursor@DG4MSQL_EMGTW_1123_DB(c);
15 end;
16 /
declare
ERROR at line 1:
ORA-28511: lost RPC connection to heterogeneous remote agent using
SID=ORA-28511: lost RPC connection to heterogeneous remote agent using
SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=emeagtw.de.oracle.com)(PORT=11231)
)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=dg4msql)))
ORA-02063: preceding line from DG4MSQL_EMGTW_1123_DB
ORA-06512: at line 6
Process ID: 16919
Session ID: 148 Serial number: 16721
When I now make sure the return value is a char data type by slightly modifying the select and including a convert it will work:
SQL> declare
2 val varchar2(100);
3 c integer;
4 nr integer;
5 begin
6 c:= dbms_hs_passthrough.open_cursor@DG4MSQL_EMGTW_1123_DB;
7 dbms_hs_passthrough.parse@DG4MSQL_EMGTW_1123_DB (c, 'SELECT convert(char,SERVERPROPERTY(''Collation'')) as Collation');
8 LOOP
9 nr:= DBMS_Hs_Passthrough.fetch_row@DG4MSQL_EMGTW_1123_DB(c);
10 exit when nr=0;
11 dbms_hs_passthrough.get_value@DG4MSQL_EMGTW_1123_DB(c,1,val);
12 dbms_output.put_line(val);
13 end loop;
14 dbms_hs_passthrough.close_cursor@DG4MSQL_EMGTW_1123_DB(c);
15 end;
16 /
SQL_Latin1_General_CP1_CI_AS
PL/SQL procedure successfully completed.
Just in case you have a procedure that returns the correct data type you have to make sure the gateway is configured correctly which means the parameter
HS_FDS_PROC_IS_FUNC needs to be set to TRUE and the function you want to call is listed in the HS_CALL_NAME parameter.
Here for a userdefined function I have to specify:
HS_FDS_PROC_IS_FUNC=TRUE
HS_CALL_NAME = "dbo.fx_SumTwoValues"
and then the udf based select:
SQL> SELECT "dbo"."fx_SumTwoValues"@DG4MSQL_EMGTW_1123_DB('7','8') AS SumOfTwoValues from "dummy"@DG4MSQL_EMGTW_1123_DB;
SUMOFTWOVALUES
15
- Klaus
Similar Messages
-
Calling SQL Server function in ODI
Hi All,
In the Target data store in the interface I have a column called COUNT_BY_CERTDATE column and in the mapping I have teh following syntax, which does not work.
SUM(CASE WHEN ((dbo.getcertdate(person_id,getdate()) >= current_timestamp) THEN 1 ELSE 0 END). The 'getcertdate' is a SQL Server function which returns a date.
I am getting a "Expression is not valid for this DBMS error" with the details as getcertdate is not a recognized built in function name. Please help on fixing this issue.
Thanks for your time and help.Its defined on the source.
I am getting the following error, when I execute it.
ODI-1228: Task Load_Fact_Table1 (Integration) fails on the target MICROSOFT_SQL_SERVER connection SQLSERVER_USAASC.
Caused By: java.sql.SQLException: [FMWGEN][SQLServer JDBC Driver][SQLServer]Cannot find either column "main" or the user-defined function or aggregate "main.dbo.getCertDate", or the name is ambiguous.
Edited by: ssk1974 on Dec 20, 2012 6:30 AM -
Calling SQL Server Function from Oracle Database link
Hi ,
i have some data from a old SQL server i would i can access with a database link but i cant call function from my database link.
i would like to do something like
@SPAN_PROD = Database link
_EnerttObtApReelBassSys is a Table function from my SQL server
SELECT *
FROM "_EnerttObtApReelBassSys('20120504',4,1)"@SPAN_PROD
WHERE DateEffectiveDebut <= GetDate()
AND DateEffectiveFin > GetDate()
any help ?
Thnx951879 wrote:
I have a SP in SQL Server which will return a Result Set.
My requirement is to call that procedure in ORACLE using DB Link and insert that resultset(Data) in the temp table.First you need to setup Oracle to SQL Server connectivity. To do that you can either use HS - heterogeneous connectivity which comes for free or use Oracle Transparent Gateway which is not free. HS uses ODBC, so if your Oracle database in not on windows, you'll have to get ODBC SQL Server driver for Unix/Linux (e.g. from EasySoft). Since SQL Server selecting from table function syntax is different from Oracle's you will have to, if you use HS, to use DBMS_HS_PASSTHROUGH package. I never worked with Oracle Transparent Gateway to SQL Server, so I don't know if and how it supports selecting from SQL Server table function.
SY. -
Oracle 10g connectivity with sql server 2000 through oracle transpa gateway
dear gurus.
i am to connecto oracle 10g with sql server 2000 through oracle transparent gateway.
i have installed transparent gateway and proper configured. also link is created.
but when i execute query "select * from city@inventory" , so an error displayed.
ORA-12500: TNS:listener failed to start a dedicated server process.
kindly suggest me what could be the cause.
regards,if the listener fails to spawn a dedicated server process it is commonly indicating an issue with the listener. So posting the listener and also a listener trace including a description of the env where you installed the gateway into which directory would be helpfull. Please keep also in mind if you have for example a 10.2.0.3 database and you install into this directoty a 10.2.0.1 gateway you have to reapply the patchset again do get consistent file version.
So please describe more detailed your env. -
Invoking SQL Server function from Oracle
Hi all,
My question involves Oracle and SQL Server. I have a function in SQL Server that returns the count of rows in a table in SQL Server itself. I
wish to invoke this function (in SQL Server) from Oracle. I have Transparent Gateway through which I usually connect to SQL Server to get the count. Is there a way in which I can execute the function (in SQL Server) from Oracle, something like below:
select function_in_sql_server@transparent_gateway from dual;Thanks,
...I found below two links:
how to call a sql server stored procedure from oracle
http://en.allexperts.com/q/Oracle-1451/2008/6/Calling-SQL-Stored-procedure-1.htm
Regards
Girish Sharma -
How To Call SQL Server SP's in Oracle 11G
Hi
I have sucessfuly established the connectivity between Oracle 11G and SQl Server 2008 and I am able to select the data from views or tables of sql server in oracle.
but now I have 1 issue I am not able to call or execute the SP's or function of sql server in oracle 11G.
Can you please suggest or help me.
Thanks
Regards
Anant.Anant,
Which gateway are you using to connect to SQL*Server ? Is it the Database Gateway for SQL*Server (DG4MSQL) or Database Gateway for ODBC (DG4ODBC) ?
If it is DG4MSQL then have a look at this note in My Oracle Support -
Different Methods For Calling MS SQL Server Procedures Using DG4MSQL (Doc ID 197192.1)
If you still have problems using DG4MSQL then post an example of what you are trying to do and the errors you receive.
If you are using DG4ODBC then this does not support calling remote stored procedures.
Regards,
Mike
Edited by: mkirtley on Aug 8, 2012 3:32 PM -
Incorrect syntax errors in sql server function. Please help.
This is my sql server function:
create function dbo.CleanTheStringAdv (@theString nvar
char(500), @CleanMode as int)
returns nvarchar(500)
begin
--define variables
declare @strAlphaNumeric nvarchar(500)
declare @i int
declare @strChar nvarchar(500)
declare @CleanedString nvarchar(500)
--initiate values
set @CleanedString =''
set @theString = @theString + ''
SET @i = 1
--Determine if we are looking for numeric values only or numbers and letters
return case @CleanMode
WHEN 1
THEN @strAlphaNumeric = '0123456789'
WHEN 2
THEN @strAlphaNumeric = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
WHEN 3
THEN @strAlphaNumeric = '|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
else 0
end
--Search through chars in the string passed to the function
while (@i <= Len(@theString))
begin
@strChar = substring(@theString, @i, 1)
If (charindex(@strAlphaNumeric, @strChar) <>0)
--if the current char being reviewed is valid then add it to the new string
begin
@CleanedString = @CleanedString + @strChar
end
end
return @CleanedString
and below are the syntax errors I see when I press F5:
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 24
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 39
Incorrect syntax near '@strChar'.
Msg 102, Level 15, State 1, Procedure CleanTheStringAdv, Line 43
Incorrect syntax near '@CleanedString'.
Any help is highly appreciated.....Here is the full code for the function:
create function dbo.CleanTheStringAdv (@theString nvarchar(500), @CleanMode as int)
returns nvarchar(500)
as
begin
--define variables
declare @strAlphaNumeric nvarchar(500)
declare @i int
declare @strChar nvarchar(500)
declare @CleanedString nvarchar(500)
--initiate values
set @CleanedString =''
set @theString = @theString + ''
SET @i = 1
--Determine if we are looking for numeric values only or numbers and letters
SET @strAlphaNumeric = case @CleanMode
WHEN 1
THEN '0123456789'
WHEN 2
THEN '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
WHEN 3
THEN '|0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
else 0
end
--Search through chars in the string passed to the function
while (@i <= Len(@theString))
begin
set @strChar = substring(@theString, @i, 1);
If (charindex(@strAlphaNumeric, @strChar) <>0) --if the current char being reviewed is valid then add it to the new string
begin
SET @CleanedString = @CleanedString + @strChar;
end
END
return @CleanedString;
END -
SQL Server Functions with TopLink
I need to call the getDate function in the SQL server database to retrieve the current time. When I try and create a DB Adapter connection to the SQL server database I can click on the Insert/Update/Delete and am able to see the tables.
When I click on the Stored Procedures/Functions button I get an error. Has anybody out there used the DBAdapter to call SQL Server stored procedures/functions. I have done this with an Oracle database without any problems.
Thanks,
ChrisChris,
In Oracle database you can put a function in a query. If you can do the same thing in SQL Server I might have a solution for you. I was able to call functions like count(), max() and min() from SQL Server. Let me know if it might help you and I'll tell you how to do it.
~ronen -
How to install sql server 2012 using the license of sql 2014
Hello,
We want to install sql server 2012 on a server because of an application that can not work with sql server 2014.
We have a license for sql server 2014. The license is not visible for sql 2014 in our licenses because it is now included in the installation package. We also can not get a license key for SQL 2012 server now.
How can we get a valid sql server 2012 license key?
Thanks,
Gr. Peter.Hello Peter,
This is a community forum for technical questions & issues.
For question regarding pricing / licensing please contact a Microsoft sales partner or licensing expert.
Call (1-800-426-9400), Monday through Friday, 6:00 AM to 6:00 PM PST to speak directly to Microsoft licensing specialist.
Regards.
T-SQL Articles
T-SQL e-book by TechNet Wiki Community
T-SQL blog -
Cant see SQL Server tab on the New/Select Database Connection
Hi All,
I cant see the SQL Server tab in the new database connection window. I have added the SQL Server jdbc driver using the Tools->Preferences->Third Party JDBC Driver, but all I can see are the the Oracle and the Access tabs.
I am using version 1.5.4.
Any pointers is highly appreciated.
Regards,
Anish.Hi,
I have SQL Developer Version 1.5.4 Build MAIN-5940.
I downloaded JTDS from SQL Developer Migration page and unzipped.
I added the driver in SQL Developer through tool/perference/database/third party vendor
I still cannot see SQL Server tab.
What else do I need to do to see the tab?
Thanks.
Tracy -
How can I call a server function by a button?
Hello, world...
I have a problem...
I need to call a server function by pushing a button. I put the condition on the label...
This is my script:
writeBtn1.addEventListener (MouseEvent.CLICK,writeFile1);
private function writeFile1 (e:MouseEvent=null):void
checkBtn = (writeBtn1.label == "Conferma" && textInput1.text != "" ); //my condition...
if (checkBtn)
nc.call ("WriteNow",null,textInput1.text+"\n");
writeBtn1.label = "Fatto";
I'd like to call the function on the release of the button...
Can someone helps me?
Please...
Emiliano.use:
writeBtn1.addEventListener (MouseEvent.CLICK,writeFile1);
writeBtn2.addEventListener (MouseEvent.CLICK,writeFile1);
writeBtn3.addEventListener (MouseEvent.CLICK,writeFile1);
private function writeFile1 (e:MouseEvent=null):void
if(e.currentTarget==writeBtn1){
// do whatever
} else if(e.currentTarget==writeBtn2){
// do whateverelese
} else {
// it's writeBtn3 -
Update/Insert mode couldn't apply to SQL Server source via Transparent Gateway.
Hi all,
OWB version is 9.0.2.56,database version is 9i Release 2.
When set load type to "Insert",mapping works fine from SQL Server to Oracle table,via Transparent Gateway 901.
But "Update/Insert" always runs error with "Fatal error or maximum number of errors exceeded".while I define both source and destination table to oracle tables in mapping,"Update/Insert" works file.
Any suggestion?Hi Ignor,
Thanks for your reply!
The SQL Server version is SQL Server 2000.
I just want to ETL data from a SQL Server table via Transparent gateway into oracle table,the source table has a increment seq field,so I want to define mapping using update/insert loading method in OWB,according to this seq field,if there is the same seq in the target table,do update,if not,insert the row.I just find out that if I use a middle table in oracle to do truncate/insert mode from SQL Server source table,then do update/insert mode from the middle one to target table,it works.But can't do directly from source to target using update/insert mode.Does this means update/insert mode only apply to mapping from local table to local table?
Regards,
Robbin -
Calling user defined functions through OBIEE
Can anyone tell me how I can call the user defined functions on database through the new BI tool.
The idea is to collect certain parameters through the prompt when launching the request, the function is supposed to pick up the parameters, make a certain calculation, and return a value.
I wrote the function, I just need help over how to call the function through the BI tool - that was pretty easy in the old Discoverer.
Thanks.
Message was edited by:
user611377Hi Kresimir ,
You can use EVALUATE function to call a user defined function.
EVALUATE('FUNCTIONNAME(%1,..)' As DATATYPE,parameter1,...)
Here DATATYPE is the returntype of function.
Hope this will help.
Thanks
Ashok -
SQL Server interfaces through Schduler Agent
Hi All,
I have a SQL server source and 1 oracle source.For running the SQL server through agent , I have updated the odiparams.sh file as
ODI_SECU_DRIVER=oracle.jdbc.driver.OracleDriver
ODI_SECU_DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver
ODI_SECU_URL=jdbc:oracle:thin:@<hostno>:1521:DWHPROD1
ODI_SECU_URL=jdbc:sqlserver://<hostno>:1433
ODI_SECU_USER=odimaster
ODI_SECU_ENCODED_PASS=aYyXCYqP5mHizfQzZJqURp
ODI_SECU_WORK_REP=WORKREP
ODI_USER=SUPERVISOR
ODI_ENCODED_PASS=a7yXqYMFSzGapZjJUIq7CQ4np
I'm able to execute the SQL server interfaces through this using the listener agent.
I start the agent using
./agent.sh -port=20911
ANd the agent starts.
However when I try to start the scheduler agent using
./agentscheduler.sh -name="Test_Agent" -port=20911
it gives me error
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user odimaster
Now if i remove the sql related things from the odiparams i.e remove these statements
ODI_SECU_DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver
ODI_SECU_URL=jdbc:sqlserver://<hostno>:1433
After removing these statements,the scheduler agent works fine.
I want to start the scheduler agent for SQL SERVER interfaces as well.Please let me know if you have any pointers for the same.
Thanks,
PritikaHi ,
ODI_SECU_DRIVER and ODI_SECU_URL is related to ODI master repository .
You can have single master repository only which in turn can have multiple work repository .
So odiparams.sh file can have only 1 entry for ODI_SECU_DRIVER and ODI_SECU_URL.
You define your source and target data server information in Topology which will be stored in ODI repository .
You don't have to specify the data server information in odiparams.sh .
Regarding "whereas with these statements in odiparams.sh,Im able to execute the SQL Server interfaces using an agent"
agent will not look into odiparams.sh file for repository parameters .. that is why it is working .
But agentscheduler looks for repository parameters in odiparams.sh .. and your odiparams.sh file is not correct .. that is why it is failing .
Thanks,
Sutirtha -
Config of multiple SQL-Server databases without multiple gateways-possible?
Hi Guys
Can someone tell me if there's any way of connecting to different SQL Server databases (using Transparent Gateway) WITHOUT having to create multiple gateways?
I have read in various sources that I MUST create one gateway per target database. I was contemplating a workaround such as creating a sysadmin SS user (and using these credentials in the db link) and trying to access any one of the databases within the SS instance. As I'm sure you know, you can query a SS database via a sysadmin user like:
select * from my_db.dbo.my_table
I realise it was a long shot to execute this from Oracle select * from my_db.dbo.my_table@my_dblink and yes....it didn't work.
We have SS databases that are constantly dropped, recreated, renamed etc so we don't want to configure transparent gateway for a database only for it to be dropped 5 minutes later.
Thanks in advance, Jon
Edited by: user10240703 on 01-Oct-2009 03:07Thanks! I'm sure that's the fella...but things still progressing at snails pace.
after (somehow) fixing the following ....
ORA-02055: distributed update operation failed; rollback required
ORA-02067: transaction or savepoint rollback required
ora-1591 lock held in - doubt distributed transaction error
I now get and can't get round the following error:
PLS-00487: Invalid reference to variable 'REC1'
Here's the simple code
SQL Server
alter procedure jontest as
begin transaction
select test from dbo.a
commit
Note: test is a varchar(50)
PLSQL code
create or replace package rcpackage is type RCTYPE is ref cursor;end rcpackage;
declare
rc1 rcpackage.rctype;
rec1 varchar2(50);
out_arg varchar2(255);
begin
rollback;
out_arg := null;
dbo.jontest@omg(rc1);
fetch rc1 into rec1;
dbms_output.put_line(rec1.test);
close rc1;
end;
Note: as you can see, the sql server column and the rec1 are the same datatype so i've no idea why it doesn't like this. I've tried with different datatypes, integers etc with the same error. Any clue? Thanks,
Getting there, but slowly :-)
Maybe you are looking for
-
Set working directory for a single thread
Hi there, Well, there are already some threads about the "working directory" subject. Here's a new variant: I need to have different working directorys for each thread. I am currently enhancing an application to do some similar jobs multithreaded (bu
-
Very slow queries when connecting through the listener in Oracle 10.2.0.4
Hi, I have a 10g database with a little table (2 columns, 9 rows). When i connect to the db through the listener (sqlplus system/manager@SID) and run this query : select * from table, the execution time is about 500ms When i connect to the db by sett
-
Changing a aritist name in "Quick Browse itunes library"
I've moved a music folder from my old itunes (6.1 ver OSX 10. 2.8) into my new computer (OSX 10.4.8) itunes music folder. One of music folder has different artists but the folder is named Compliation. I CAN NOT get the name of the artist to show up i
-
Reg: SUPPRESS AND PICK in module pool?
what is SUPPRESS DAILOG in module pool. what is the PICK function type in module pool.
-
Advice for logical workflow for color correcting and color grading
I am an experienced user of PPRO CS5. I am a novice with color correcting and color grading. I am also just barely competant in AE CS5. It has been suggested that I use AE for color correcting my footage. Can you advise me as to the most logical