Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

PI SQL Client ODBC

Workaround 2 - use pass-through query

  • Last UpdatedJan 04, 2023
  • 1 minute read

Use a pass-through query to avoid any manipulation of the remote query by Oracle.

For example:

set pagesize 50000
set serveroutput on size 30000;
--Using bind variables in a query
declare
v_cursor binary_integer;
v_ret binary_integer;
v_elementname nvarchar2(30);
v_attributename nvarchar2(30);
v_time timestamp;
v_value nvarchar2(30);
v_value2 float;
v_bind_elementname varchar2(30);
begin
v_cursor:=dbms_hs_passthrough.open_cursor@pi;
dbms_hs_passthrough.parse@pi(v_cursor,
'SELECT e.Name Element, ea.Name Attribute, a.TimeStamp, a.Value, a.Value_Double
FROM Element.Element e
INNER JOIN Element.Attribute ea ON ea.ElementID = e.ID
INNER JOIN Element.Archive a ON a.AttributeID = ea.ID
WHERE a.TimeStamp BETWEEN ''25-APR-2019'' AND ''26-APR-2019''
AND e.Name = ?
AND ea.Name = ''Environment''
ORDER BY e.Name, ea.Name;
');
v_bind_elementname := 'Houston';
dbms_hs_passthrough.bind_variable@pi(v_cursor,1,v_bind_elementname);
loop
v_ret:=dbms_hs_passthrough.fetch_row@pi(v_cursor,false);
EXIT WHEN v_ret = 0;
dbms_hs_passthrough.get_value@pi(v_cursor,1,v_elementname);
dbms_hs_passthrough.get_value@pi(v_cursor,2,v_attributename);
dbms_hs_passthrough.get_value@pi(v_cursor,3,v_time);
dbms_hs_passthrough.get_value@pi(v_cursor,4,v_value);
dbms_hs_passthrough.get_value@pi(v_cursor,5,v_value2);
dbms_output.put_line('Element '||v_elementname);
dbms_output.put_line('Attribute '||v_attributename);
dbms_output.put_line('TimeStamp '|| to_char(v_time,
'DD-MON-YYYY HH24:MI:SS.FF3'));
dbms_output.put_line('Value '|| v_value);
dbms_output.put_line('Value_Double '|| v_value2);
end loop;
dbms_hs_passthrough.close_cursor@pi(v_cursor);
end;
/

TitleResults for “How to create a CRG?”Also Available in