query dp values with oracle sql over soap...

Find and share HowTos to various installations / configurations!
8 posts • Page 1 of 1
vogler
Posts:122
Joined: Thu Oct 28, 2010 8:32 am

query dp values with oracle sql over soap...

Post by vogler »

Some time ago i had the requirement to query and also set datapoint values wit sql.

For example to create reports with a third-party report engine llike oracle reports, access, ... or every tool which can connect to oracle or odbc!

I created a small winccoa webservice (winccoa http server)... see script below
In oracle it is possible to call/use this webservices... see oracle package below

Some usage examples:

select pvss.dpGet('086_PM_CF_VSD2.') from dual -- get value of one dp

create table dps (el varchar2(2000)) -- create a table where we will store our datapoints we want to query
insert into dps (el) values ('086_PM_CF_VSD1.');
insert into dps (el) values ('086_PM_CF_VSD2.');
...

create or replace view dps_val as select el, pvss.dpGet(el) value from dps; -- create a view for easy access

select * from dps_val -- get all dp values

create or replace trigger dps_val_upd instead of update on dps_val -- create a trigger, so we can update the view!
begin
pPvss.dpSet(:old.el, :new.value);
end;
/
update dps_val set value=value+1 -- value will be increased in winccoa!

Of course by this way it will also be possible to create functions to read historical values of winccoa-value-archives (hdb, if you don't use the winccoa oracle rdb archive manager)...

Oracle source:

Code: Select all

CREATE OR REPLACE PACKAGE pvss AS

  PROCEDURE SetServer(gHostname VARCHAR2, gPort INTEGER DEFAULT 80);
  FUNCTION dpGet(dpName IN VARCHAR2) RETURN VARCHAR2;
  FUNCTION dpSet(dpName IN VARCHAR2, dpValue IN VARCHAR2) RETURN INTEGER;
END;
/
CREATE OR REPLACE PACKAGE BODY pvss AS

  gServer VARCHAR2(100) := localhost:81';
  
  gErrNum NUMBER;
  gErrTxt VARCHAR2(32767);
  gEnv    VARCHAR2(32767) := '';  
  
  /* A type to represent a SOAP RPC response */
  TYPE response IS RECORD (
    doc xmltype);  
    
  PROCEDURE setServer(gHostname VARCHAR2, gPort INTEGER DEFAULT 80)
  IS
  BEGIN
    gServer:=gHostname||':'||gPort;
  END;


  function urlencode( p_str in varchar2 ) return varchar2
  as
      l_tmp   varchar2(12000);
      l_len   number default length(p_str);
      l_bad   varchar2(100) default ' >%}\\~];?@&

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: query dp values with oracle sql over soap...

Post by Gertjan van Schijndel »

Andreas, why do you not use the code tag, so the code is easier to read?

vogler
Posts:122
Joined: Thu Oct 28, 2010 8:32 am

Re: query dp values with oracle sql over soap...

Post by vogler »

thx for that hint! i didn't know that a code tag exists ;-)

aorange
Posts:147
Joined: Thu Nov 04, 2010 10:07 am

Re: query dp values with oracle sql over soap...

Post by aorange »

Interesting, we use Crystal Reports and Business Objects to publish reports on the archive data held in our WinCC-OA Oracle database. There was no need to setup any specific connections to do this other than the Oracle ODBC driver.

We are not able to write any data to the Oracle tables however but I suppose we could use Oracle Developer or SQLPlus if we needed to write data.

Gertjan van Schijndel
Posts:634
Joined: Mon Aug 02, 2010 10:37 am

Re: query dp values with oracle sql over soap...

Post by Gertjan van Schijndel »

With this code it is possible to get non-archived values from WinCC-OA and set values in WinCC-OA by executing Oracle statements.

vogler
Posts:122
Joined: Thu Oct 28, 2010 8:32 am

Re: query dp values with oracle sql over soap...

Post by vogler »

I didn't talk about RDB-Archive-Manager!!
I didn't talk about history-values!

It is to get/set actual values of datapoints (doesn't matter if they are logged or not) from oracle! (select,pl/sql,...)

There was just one note: that in this way it would also be possible to read history values out of HDB-valarchs (not RDB-Archive-Manager!) from oracle! - but this is not implemented in the code i have published...

clear now?

aorange
Posts:147
Joined: Thu Nov 04, 2010 10:07 am

Re: query dp values with oracle sql over soap...

Post by aorange »

Ahh okay I see the difference... no need to get nasty, it was a simple misunderstanding.

vogler
Posts:122
Joined: Thu Oct 28, 2010 8:32 am

Re: query dp values with oracle sql over soap...

Post by vogler »

it shouldn't be nasty :unsure:
sorry if it came wrong by writing...

8 posts • Page 1 of 1