See actual code of function in DB2 for IBM i - db2

Hello guy I create a function in DB2 UDB for AS/400 version 07.01.0000 V7R1m0
I use a windows with dbvisualizer to connect the server.
My function is...
CREATE FUNCTION JVAOBJ.BNOWPAPOL(POL VARCHAR(10)) RETURNS DECIMAL(7,7) LANGUAGE SQL NOT
DETERMINISTIC READS SQL DATA
RETURN
(
SELECT
CASE
WHEN NUM IN (1,2)
THEN 0.3
ELSE 0.19698
END AS VALOR
FROM
LMDDTA.VERT240
WHERE
POLLIFE = POL )
It return 0.3 or 0.19698 depending of POL param
To do it I delete DROP FUNCTION JVAOBJ.BNOWPAPOL and run CREATE until work well.
My problem is I can not see the actual code of the function in dbvisualizer I cant see the function created
How I can see the actual code?
Note:
The server administrator has access to the console as400 (yes, that black screen with green letters or orange letters, which I have not much knowledge)
maybe, I can see it from here.
Note 2:
I use jt400 driver to connect.

Try IBM i Navigator for web. If it is configured on your machine, you can reach it through this URL: https://your.ibm.i:2005/ibm/console/login.do?action=secure
If it is not configured, then perhaps you can ask the admin to install the Windows client. It is part of Client Access for Windows and is called IBM i Navigator for Windows.
In either case, use the navigation tree to go to Databases > machine > Schemas > JVAOBJ > Functions. Right click your function > Definition and then choose Routine Body
EDIT Add SYSROUTINE
Another way to see the routine body is via the DB2 catalog table SYSROUTINE. select specific_schema, specific_name, routine_definition from sysroutine

I know IBM i Navigator its a great tool, but you need some amount of knowledge to master it.
The easiest way is to query the SQL system tables using dbvisualizer
SELECT * FROM qsys2/sysfuncs
WHERE (SPECIFIC_SCHEMA, SPECIFIC_NAME) = ('JVAOBJ', 'BNOWPAPOL')

Related

oracle-sqldeveloper: where does the output of plugins go to in v21?

A while ago I wrote myself a nice SQL Developer plugin (back then for Oracle SQL Developer v19.x).
I haven't used for a while and meanwhile I migrated to SQL Developer v21.2.1.204.
When I wanted to run my plugin again, there is no output displayed anywhere!? Where does the output generated by a plugin and emitted by dbms_output.put_line(...) end up?
In "Messages - Log" which used to be the tab where the output ended up, the execution only emits a final "PL/SQL procedure successfully completed." but nothing else.
For my colleagues who still run Oracle SQL Developer v19 it still works - all output goes to "Messages - Log".
I also tried "Dbms Output" (View --> Dmbs Outout) but nothing appears there.
Thus my question: Where does the output of an SQL Developer Plugin go to in OSD v21+? Do I need to enable anything beforehand to capture or redirect its output?
Nevermind - problem solved:
while experimenting I had commented the script's preamble
set serveroutput on;
set wrap off;
set linesize 4000;
...
and then - of course - there is no script output returned to SQLDeveloper.
Everything's working now...

Object reference exception when importing content in Episerver

We are using Optimizely/Episerver CMS 11.20. When trying to export a page hierarchy from our production environment and then import the resulting ExportedFile.episerverdata file to our acceptance test environment I get the following error:
[Importing content 70725_133679] Exception: Object reference not set to an instance of an object.
I have no idea what 70725_133679 is referring to. Is there a way to look this up, e.g. via an SQL query against the "EPi" database?
It refers to a specific version of some content (which could be just about anything).
You could try to browse to https://yoursite/EPiServer/CMS/#context=epi.cms.contentdata:///70725_133679 (note the ID at the end) to see which content it is.
Got another answer on a Optimizely forum (thanks to Surjit Bharath):
The following SQL against the EPi database gives information about the referenced content:
select * from tblContent where pkID = 70725 
select * from tblWorkContent where pkID = 133679
This too points to a submit button. I have yet to understand why that block would cause an exception during import, but now I at least have a place to start digging.

Execute SSIS (package) in SSMS using T-SQL and return a value

Using VS (2019) I created an Integration Services Project to code an SSIS package. The goal was to call a Web API from an SSIS package using input variables like username/password/url and so on. I successfully achieved this using Script Task and Dts.Variables and F5/Run to see successful results. What I want to achieve now is to return (like an out parameter) an Id returned to me by the Web API. I want to have this Id returned in the SSMS Results window when I execute the SSIS script in SSMS.
Here is what I have done:
VS > Open dtsx file in Designer and in the "Control Flow" tab, right clicked to add variable:
Right clicked the Script Task I had created and added the variable created above in the ReadWriteVariables section:
Using "Edit Script" to code the Web API call and return a value and set it as follows:
//MessageBox.Show(id);
Dts.Variables["User::Id"].Value = Convert.ToInt32(id);
The MessageBox was just to test if the id is returned by the Web API and I get an alert of the "id" when I Run/F5 the SSIS project in Visual Studio. The second line is where I have set the Variable.
I execute the SSIS in using T-SQL in SSMS from an example here:
Declare #execution_id bigint
EXEC [SSISDB].[catalog].[create_execution] #package_name=N'ssisWAP.dtsx', #execution_id=#execution_id OUTPUT, #folder_name=N'SSIFolder', #project_name=N'SampleProject', #use32bitruntime=False, #reference_id=Null
Select #execution_id
DECLARE #var0 sql_variant = N'username'
EXEC [SSISDB].[catalog].[set_execution_parameter_value] #execution_id, #object_type=20, #parameter_name=N'Username', #parameter_value=#var0
DECLARE #var1 sql_variant = N'password'
EXEC [SSISDB].[catalog].[set_execution_parameter_value] #execution_id, #object_type=20, #parameter_name=N'Password', #parameter_value=#var1
EXEC [SSISDB].[catalog].[start_execution] #execution_id
The above executes properly, calling the API and an out #execution_id is shown in Result window. But no sign of the variables User::Id I created earlier. Is it possible to show that value in the Result window? If not, is there a way to see that the data in that variable in SSMS after SSIS execution (even from designer)?
I already had a look at this post: Returning Output Paramters or Variables From SSIS Script Task / Script Component
where the solution is to use "Execute SQL Task" and "pass" the variable into a procedure. This I guess is one way to do it but I want to just get the Id in the return when I execute the script as shown above.
Any help will be appreciated. Thanks

Windows Defender to find localization numeric value for Reporting

i need to create some SSRS reports For Windows Defender .. i need to find localization numeric values for Detection source
Detection Source: <Detection source> for example:
User: user initiated
System: system initiated
Real-time: real-time component initiated
IOAV: IE Downloads and Outlook Express Attachments initiated
NIS: Network inspection system
IEPROTECT: IE - IExtensionValidation; this protects against malicious webpage controls
Early Launch Antimalware (ELAM). This includes malware detected by the boot sequence
Remote attestation
Reference link enter link description here
i need to select in case so i need to know numeric values for each of option.
one thing is can use
SrsResources.Localization.GetString(Choose(Fields!DetectionSource.Value,"DetectionByUser","System","Realtime","IOAV","NIS","BHO","ELAM","LocalAttestation","RemoteAttestation","AMSI","UAC"), User!Language)
but then i dont have acces to Visual Studio as iam database person.. so cant create DLL and include in reference of report.
Please help me out how to find numeric values to each one of these.
From the statement SrsResources.Localization.GetString, I am guessing that you're using SCCM since that exact statement is part of the SCCM report:
Endpoint Protection -> Endpoint Protection - Hidden -> Computer malware list
If that's the case, then just copy the report and change what you need and the function will work.
Because in the report properties the srsresources.dll is referenced as SrsResources, culture=neutral, the dll is needed in order to translate the value to the correct name in the language the user running the report is using.
If you're just interested in the numeric values behind each entry, however, then it is just a list starting with one. Meaning:
"DetectionByUser",
“System",
“Realtime",
“IOAV",
"NIS",
"BHO",
"ELAM",
“LocalAttestation",
"RemoteAttestation",
"AMSI",
"UAC"

LibreOffice BASIC : Connect to PostgreSQL

I've created a PostgreSQL connection File using LibreOffice Base (6.1) and I can run SQL Queries in there just fine but I was wondering if it's possible to use this Base connection in a LibreOffice BASIC function.
I know you can use JDBC connections for MySQL
mysql://hostname:port/database_name
But I'm hoping there's a way to use the Base File seeing as it works so well
I've been trying to find documentation on this online but I am struggling to find anything that bridges the gap between BASIC and Base.
I've found the answer, the solution was to use createUnoService and that allows you to specify the name of the odb that was setup in Base.
oService = createUnoService("com.sun.star.sdb.DatabaseContext")
oBase = oService.getByName("basePostgreSQL")
oConn = oBase.getConnection("","")
oQuery = oConn.createStatement()
oSql = "select col from table"
oResult = oQuery.executeQuery(oSql)
while oResult.next()
msgBox oResult.getString(1)
wend
oConn.close()