Identifying the WLM job picked my stored procedure - stored-procedures

How could we know which WLM job has picked my DB2 stored procedure call invoked. I see some set of jobs are running with DB2XWLM* where DB2X is database region. But how to check which particular job had taken my stored procedure call.
Hope I made clear, please let me know if something is not clear. Appreciate your interest.

By giving few 'unique display statements' in the Stored procedure and by making the display statements on , we can check which WLMjob has picked the Stored procedure.

Typically a stored procedure is assigned to a region when it's created.
If you are able to see the DDL for the CREATE PROCEDURE statement (perhaps through DB2 admin tool), there should be a line like:
WLM ENVIRONMENT DB2SP3
DB2SP3 would be the environment your stored procedure lives in. I'm not sure that it always works this way, but it's worth checking.

Go to the job output where you can see display statements of your SP. That JCL has WLM specified. Just search for WLM word and you can find it.

I realize this is an old post but here is the answer for future reference:
select schema ,owner ,name ,WLM_ENVIRONMENT
from SYSIBM.SYSROUTINES
where schema = 'yourschemaname'
and name = 'yourSPname'
WLM_environment is the column you are looking for.
(db2v11)

Related

How to encrypt stored procedure in Teradata

Is it possible to encrypt stored procedures in Teradata?
I would like to hide the code of procedure from others and I have no idea if it is even possible.
Some ideas?
Thanks,
Cris
There's no need to encrypt the source code of a SP in Teradata, you can simply use the NO SPL option and then no source code is stored.
Either during creation using ODBC, CLI or BTEQ, e.g. in BTEQ
.COMPILE FILE 'mysp.spl' WITH NOSPL
But the common way is to CREATE it first and then run:
ALTER PROCEDURE mySP COMPILE WITH NO SPL;

Creating a DTS package that uses a stored procedure

We're trying to make a DTS package where it'll launch a stored procedure and capture the contents in a flat file. This will have to run every night, and the new file should overwrite the existing file.
This wouldn't normally be a problem, as we just plug in the query and it runs, but this time everything was complicated enough that we chose to approach it with a stored procedure employing temporary tables. How can I go about using this in a DTS package? I tried going the normal route with the Wizard and then plugging in EXEC BlahBlah.dbo... It did not care for that:
The Statement could not be parsed. Additional information: Invalid object name '#DestinyDistHS'. (Microsoft SQL Server Native Client 10.0)
Can anyone guide me in the right direction here?
Thanks.
Is it an option to simply populate a non-temp table in your SP, call it and select from the non temp table when exporting?
This is only an issue if you have multiple simultaneous calls to the stored procedure. In this case you can't save to a single table.
If you do have multiple simultaneous calls then you might be able to:
Create a temp table to hold results
Use INSERT INTO #TempTable EXEC YourProc
SELECT FROM #TempTable
You might need to do this in a more forgiving command line tool (like SQLCMD). It's not as fussy about metadata.

Server opens Stored Procedure like Unicode

As you can see in the image bellow, my SQL Stored Procedures, somehow, my SQL Server opens Procedures like Unicode SPs.
That was not the case before, and I have no idea how this apeared now.
I have around 5.000 stored procedures so there is no chance I can edit it manualy.
My SPs starts from ALTER PROCEDURE , everything before that is somehow added.
Your SP's will still work just fine. This is just the way SQL Server Management Studio scripts the objects when you want to generate ALTER- or CREATE-statements.
To change this behavior, go to Tools > Options > SQL Server Object Explorer > Scripting
Set the option "Include IF NOT EXISTS clause" to "False".
(In other versions of SQL Server Management Studio the option might be called something like "Check for object existence")
As previously answered, changing the scripting option "Include IF NOT EXISTS clause" to false solves the problem. To add context, if this value is true, it has to be scripted by putting the entire Alter Procedure statement in an #statement variable, because the conditional logic associated with the check for existence requires the ALTER PROCEDURE statement be inside a BEGIN/END block, which is not allowed. So Microsoft's workaround is to put the entire ALTER PROCEDURE statement in the #statement variable, which is executed conditionally inside a BEGIN/END block.

iReport with Oracle Stored Procedure

I just installed iReport(Product Version: iReport Professional 3.7.1.1) and try to create exiting crystal report file using iReport to see it makes my life easier.
First bump that I faced was Oracle stored procedure. I found below post and tried to apply it.
1) Set the Query language in the Report Query to plsql
2) Use the following syntax for the call "{call MyPackage.MyStoredProc($P{Cursor},$P {InputParam})}"
3) Define the Cursor param as java.sql.ResultSet
4) Type in the Fields of the result set by hand. I could not get the Automatically Retrieve Fields to work.
I am using iReport 3.7.1 on Windows XP which is bundled with the jasperreports-extensions-3.5.3.jar that contains the necessary PlSqlQueryExecuter classes.
I have conformed PlSqlQueryExecuter class exits in my classpath, the error message I got is
The parameter 'Cursor' is not defined
Here is my question.
1. Does anyone know how to define Ref Curssor in the iReport?
2. How do I type in the fields of the result set by hand??
Thanks for you time
You will have to set your Cusor out parameter datatype as java.sql.ResultSet you can do this by clicking the Add New Parameter and just type the data type as said above and click ok...Also make sure you uncheck the "Prompt for Parameter" in the Cursor's property in the report designer...
You can follow the article in the below link... this article gives a step by step instruction on how to create stored Procedures and call the stored procedure in your JasperReport / iReport... hope this helps
http://meezageekyside.blogspot.com/#!/2012/04/jasper-reports-ireport-45-using-oracle.html
keep us posted on your findings as well....

How to call a stored procedure in IBM System i Access for Windows GUI Tool

I would like to test a DB2 stored procedure running on an AS400 system.
I have the IBM System i Access for Windows installed and can run SQL commands against the DB2 database.
My question is: What is the syntax to execute a stored procedure that takes in a parameter and returns a result as an output parameter and print the value to the screen?
Just to clarify: I am not asking how to call the proc in code. I want to execute the proc and see the results in the gui tool (which is similar to SQL Enterprise Manager).
use the keyword call and pass in the parameters.
call myStoredProc(parm1, parm2, ?);
for more details see here http://www.ibm.com/developerworks/data/library/techarticle/dm-0503melnyk/. The interesting part is Figure 5. Using the Command Editor to call an SQL procedure
What you want is possible. I have done it myself many times. Unfortunaly, I'm not at the office right now so it must be from the top of my head.
Start System i Access
Go to your iSeries icons and log on to the one where your stored procedure lives
Go to the databases icons and connect to the correct one (you've one local and probably one or more remotes)
Only then, you will see the option "run SQL script" at the bottom of your screen
Start that option and you will see a SQL editor (editor on top, viewer/messages at the bottom)
Remember that you are already connected to the correct iSeries but your JDBC request will get the *LIBL of the userprofile of your connection. Therefore you must know the schema (iseries library) of your stored procedure
Enter "call YOURSCHEMA.YOURSTOREDPROCEDURE(?,?);" and use the menu or shortcut to run that statement. Notice that - depending on your JDBC settings (see menu) - the correct syntax may be "/" instead of ".". Also, notice that you can replace the first question mark with a value.
On an additional note,
In iAccess, under every schema you will see icons for the tables, views and so on. Also an icon for stored procedures is available. You will see your SP there. Use the options to see the definition and so. This information includes detailed information about the parameters
If you want to check that on your iSeries, use the system catalog (this can be done from the SQL editor too) with "select * from qsys2.sysprocedures where procedure_name (sorry, not sure about the name of this column right now) = 'YOURSTOREDPROCEDURE';"
VERY IMPORTANT: I was never able to test the SP with the SQL editor (STRSQL) on the iSeries itself. Only the iAccess SQL editor did work correctly.
You should be able to run your SP like this:
DECLARE
usr_in YOUR_TABLE.YOUR_COLM%TYPE; --Gets the correct type by looking at column type
app_in YOUR_TABLE.YOUR_OTHER_COLM%TYPE;
BEGIN
usr_in:='some value';
app_in:='another_value';
YOUR_SP_NAME(usr_in, app_in);
END;
Or you can use EXECUTE, but it can't be dynamically prepared (not run in Java) and I think there's some other disadvantages.
EXECUTE myStoredProc(parm1, parm2, ?);

Resources