Answer the question
In order to leave comments, you need to log in
How to call a function with parameters from ms sql, which is located on the linked postgresql?
you need to call such a simple function and get the result.
create or replace function fn_order_exist(p_order_ms_id int)
returns int
language plpgsql
as
$$
declare
begin
if exists (select 1 from public.orders where order_ms_id=p_order_ms_id) then
return 1;
else
return 0;
end if;
end
$$;
select order_id from pgServer.aac.[public].orders where order_id=1;
maybe mssql 2000 and the driver does not understand some data types and falls off with type errors:Server: Msg 7356, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' supplied inconsistent metadata for a column. Metadata information was changed at execution time.
OLE DB error trace [Non-interface error: Column 'self_order' (compile-time ordinal 7) of object '"aac"."public"."orders"' was reported to have a DBCOLUMNFLAGS_ISLONG of 128 at compile time and 0 at run time].
Answer the question
In order to leave comments, you need to log in
>OPENQUERY does not understand parameters.
He understands everything perfectly, just form a query through dynamic sql - i.e. having previously collected the text of the request, and then executing it.
Like this:
declare @sql varchar(max)
set @sql = concat('OPENQUERY ....'''',@var1,'''' somesql'''',@var2,'''''.. .''')
exec (@sql)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question