发布新帖

查找

问题
· 八月 17, 2023

Custom task that exports query result in a csv file

Hello!

I'm new to Caché systems and I have a question...

I need to develop a custom task that daily exports the result of a query to a csv file in the database directory (I use the UNIX version).

Does anyone have any code or help to solve this case?

Thanks!!!

2 Comments
讨论 (2)1
登录或注册以继续
文章
· 八月 17, 2023 阅读大约需 1 分钟

Download Globals as XML using CSP

Inspired by a Question from @Evgeny Shvarov and a Reply from @Ashok Kumar T
I have created a base for Global download as XML file

How to use:
 
just call the page like http://<your_server>/csp/samples2/dc.Gdown.cls?GBL=global_name

gbl-name  without the initial ^ (caret)

The output has a default name <global_name>.XML  Your choice is available.

Known Limits:

  • you have to install it at your sourcing server
  • it is not tested/working across namespaces
  • there is no partial download
  • error handling is just basic or missing

There is space for personal improvements.

and this is it:

Class dc.Gdown Extends %CSP.Page
{

ClassMethod OnPreHTTP() As %Boolean [ ServerOnly = 1 ]
{
  #dim %response as %CSP.Response
  set %rcc=$Get(%request.Data("GBL",1),"")
  if %rcc]"" {
    set %rcd=$D(@("^"_%rcc))
    if %rcd {
      set %response.ContentType="application/xml"
      set %response.Headers("Content-Disposition")="attachment; filename="""_%rcc_".xml"""
    }
  }
  else  { 
    set %rcd=0
    set %rcc="Parameter GBL"
  }  
  quit $$$OK
}

ClassMethod OnPage() As %Status
{
  if '%rcd {
  &html<<html><head></head><body>
   #(%rcc)# &gt;&gt; not found </body></html>>
  quit $$$OK
  }
  do $system.OBJ.Export(%rcc_".GBL")
  Quit $$$OK
}
}





 





 

2 Comments
讨论 (2)2
登录或注册以继续
问题
· 八月 16, 2023

Web client from SOAP Service

I created a web service and used the Studio SOAP Wizard to generate a client from the WSDL file of the service. But the client is throwing the error as shown below

 WebServiceClientClass '' could not be instantiated, or the WebServiceURL Location could not be determined

What have I missed?

Is there a better way to create a client?

2 Comments
讨论 (2)2
登录或注册以继续
文章
· 八月 15, 2023 阅读大约需 2 分钟

Using NativeAPI Extension from Python

In my previous articles, I described my Command Line Extension to NativeAPI.
Of course, this is also available for any other NativeAPI package.
So I created this example in Python as a demo.

The package contains also an IRIS server in Docker for the demo
It is evident that it also works with any remote IRIS server.
You just have to provide it with my NativeAPI CommandLine Extension.

I think this demo is easy to follow and shows the essential features.

  • First, you install the package and start the container
  • then you start the demo
    docker-compose exec iris python3 src/rcc.py
  • Next, you connect  to your IRIS server defaults refer to the ádde IRIS server in the container
    >>> serverIP [127.0.0.1]:
    >>> serverPORT [1972]:
    >>> namespace [USER]:
    >>> username [_SYSTEM]:
    >>> password [SYS]:
    Connected to Instance IRIS on Server 1C09927CAE60 
  • Now, you get into the demo menu
    Select Demo to exercise 
     0 = free ObjectScript
     1 = $ZV from Server
     2 = Actual Time in Server
     3 = TimeZone Offset of Server
     4 = Server ArchitectureVendorModel
     5 = List Global in ZWRITE style
     * = Terminate demo
    >>> take a choice [1]:  
  • And this is the result when you run through all 5 examples
    >>> take a choice [1]:
     IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2023.2 (Build 227U) Mon Jul 31 2023 18:04:28 EDT 
    
    >>> take a choice [1]: 2
     2023-08-15 07:42:16 
    
    >>> take a choice [1]: 3
     0 
    
    >>> take a coice [1]: 4
     x86_64 * Intel * Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz 
    
    >>> take a choice [1]: 0 
    >>> Your ObjectScript [ quit "?"]: quit $ZTS
     66701,27813.678790226 
    
    >>> take a choice [1]: 0 
    >>> Your ObjectScript [ quit "?"]: quit 17/4
     4.250000000000000000 
    
    >>> take a choice [1]: 0 
    >>> Your ObjectScript [ quit "?"]: quit 17/0
     <DIVIDE> 18 x^%ZX 
    
    >>> take a choice [1]: 5 
    >>> Your Global [^dc.MultiD]:
     ^dc.MultiD = 5
     ^dc.MultiD(1) = $lb("Braam,Ted Q.",51353)
     ^dc.MultiD(1,"mJSON") = "{}"
     ^dc.MultiD(2) = $lb("Klingman,Uma C.",62459)
     ^dc.MultiD(2,2,"Multi","a") = 1
     ^dc.MultiD(2,2,"Multi","rob",1) = "rcc"
     ^dc.MultiD(2,2,"Multi","rob",2) = 2222
     ^dc.MultiD(2,"Multi","a") = 1
     ^dc.MultiD(2,"Multi","rob",1) = "rcc"
     ^dc.MultiD(2,"Multi","rob",2) = 2222
     ^dc.MultiD(2,"mJSON") = "{""A"":""ahahah"",""Rob"":""VIP"",""Rob2"":1111,""Rob3"":true}"
     ^dc.MultiD(3) = $lb("Goldman,Kenny H.",45831)
     ^dc.MultiD(3,"mJSON") = "{}"
     ^dc.MultiD(4) = $lb("","")
     ^dc.MultiD(4,"mJSON") = "{""rcc"":122}"
     ^dc.MultiD(5) = $lb("","")
     ^dc.MultiD(5,"mJSON") = "{}"
     **** done ***
    
     >>> take a choice [1]: *
       Thank you for trying the demo

If you prefer to test it with embedded Python use

docker-compose exec iris iris session iris "##class(nacl.rcc).py()"

 

Video

3 Comments
讨论 (3)2
登录或注册以继续
文章
· 八月 10, 2023 阅读大约需 3 分钟

Remote Global Listing using NativeAPI for ObjectScript #2

As noted in the previous article Native API has some limits.
So I did some research on a more Terminal-like interface that
provides me with access like a console or the IRIS terminal
to allow my  $QUERY over a global and other nice commands
that are not supported/mapped in NativeAPI for ObjectScript.

The basic tools are well-prepared and available.

  • Connection() creates a fully operational and stable partition for me
  • Function() allows calling any routine or method I need
  • similar ClassMethodValue and ClassMethodVoid

There is just no method CommandLine and some already prepared code is needed.

My simple approach: Send the  code and let it eXECUTE
It is just a 1-liner to mimic a single command line

;; routine %ZX.int
x(%rcc) try {return $xecute(%rcc)} catch %rcc {return %rcc.DisplayString()}

If you don't have access to some programming tool you may use this
Stored Procedure from MgmtPortal/SQL for installation:

CREATE PROCEDURE %Zrcc.X()
LANGUAGE OBJECTSCRIPT
{
 set %rcc=##class(%Routine).%New("%ZX.int")
 set %rccline="x(%rcc) try {return $xecute(%rcc)} catch %rcc {return %rcc.DisplayString()}"
 do %rcc.WriteLine(%rccline)
 do %rcc.Save()
 quit %rcc.Compile()
}

And next you need your connection object

ClassMethod Connect(
    serverIP = "192.168.0.9",
    serverPORT = 1972,
    namespace = "USER",
    username = "_SYSTEM",
    password = "SYS") As %Net.DB.Iris
{
  try {
    set %rccon=##class(%Net.DB.DataSource).CreateConnection(serverIP
                           ,serverPORT,namespace,username,password)
    set %rccdb=%rccon.CreateIris()
    }
  catch { zw  b  }  ;; do some error handling
  quit %rccdb
}

Now a few preliminary examples using method Function
CON is my CommectionObject

USER>write CON.Function("%ZX","","quit $job")
1920

The 3rd argument will always return something as %RawString
And if something fails:

USER>write CON.Function("%ZX","","set x=27,y=0 quit x/y ; will fail")
<DIVIDE> 18 x^%ZX

and this is a simple Remote Global Lister.
Then making a copy or renaming is a rather trivial task:

gl ; list remote Global
  set global="^dc.MultiD"  ;; adjust as required
  set a=CON.Function("%ZX","","quit $LB($D("_global_",%rcc),%rcc)")
  Write !,global," = ",$li(a,2)," $DATA = ",$li(a),!
  if $li(a)#10 {
    for { 
      set a=CON.Function("%ZX","","q $LB($q(@$zr),@$ZR)")
      quit:$li(a)=""
      write $li(a), " = "
        ,##class(%Utility).FormatString($li(a,2)),! 
      }
    }
 Write "-------done----------",!

The focus is on getting all control local and just 1 call by Global node
Test action:

USER>do ^gl
 
^dc.MultiD = 5 $DATA = 11
^dc.MultiD(1) = $lb("Braam,Ted Q.",51353)
^dc.MultiD(1,"mJSON") = "{}"
^dc.MultiD(2) = $lb("Klingman,Uma C.",62459)
^dc.MultiD(2,2,"Multi","a") = 1
^dc.MultiD(2,2,"Multi","rob",1) = "rcc"
^dc.MultiD(2,2,"Multi","rob",2) = 2222
^dc.MultiD(2,"Multi","a") = 1
^dc.MultiD(2,"Multi","rob",1) = "rcc"
^dc.MultiD(2,"Multi","rob",2) = 2222
^dc.MultiD(2,"mJSON") = "{""A"":""ahahah"",""Rob"":""VIP"",""Rob2"":1111,""Rob3"":true}"
^dc.MultiD(3) = $lb("Goldman,Kenny H.",45831)
^dc.MultiD(3,"mJSON") = "{}"
^dc.MultiD(4) = $lb("","")
^dc.MultiD(4,"mJSON") = "{""rcc"":122}"
-------done----------

Of course, there are a lot of other activities than just Global listing possible
You may take a look into the ages-old Global ^% to get a feeling,
what programming with XECUTE + $XECUTE() can do.


BTW:
this is not a contribution to ePy contest
  😉
 

1 Comment
讨论 (1)1
登录或注册以继续