BigQuery stored procedure access through simba jdbc driver - stored-procedures

All,
I am trying to execute a stored procedure in google bigquery using a jdbc connection but having no luck with it.
I followed the example here https://cloud.google.com/blog/products/data-analytics/command-and-control-now-easier-in-bigquery-with-scripting-and-stored-procedures.
I am able to create and call the stored procedure from bigquery web ui but when i set up a data source in intellij using the simba driver as explained here https://blog.jetbrains.com/datagrip/2018/07/10/using-bigquery-from-intellij-based-ide/
Then when i run the call to execute the stored procedure
DECLARE target_employee_id INT64 DEFAULT 9;
DECLARE employee_hierarchy ARRAY<INT64>;
dataset.GetEmployeeHierarchy(target_employee_id, employee_hierarchy);
SELECT target_employee_id, employee_hierarchy;
i get an error
[HY000][100032] [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: Unrecognized name: target_employee_id at [1:8] com.simba.googlebigquery.support.exceptions.GeneralException: [Simba][BigQueryJDBCDriver](100032) Error executing query job. Message: Unrecognized name: target_employee_id at [1:8]
As the stored procedure support is in pre-release beta, I am wondering if the Simba driver supports it as of now?
If not are there any other jdbc drivers that do currently?

So turns out all the 4 statements need to be executed as a single Bloc not as individual statements.
In intellij you can highlight all those statements and hit run to execute it and return the results.
In Java just pass them as a single string in statement.execute.

Related

DB2-12 (Z/OS) - Create Alias for Stored Procedure

it's possible to define an alias for a stored procedure (sql-native)?
In the documentation, reference is made only to: SEQUENCE and TABLES
1) CREATE PROCEDURE OWXXCOLL.STORED1()
2) CREATE ALIAS DB2C.STORED1 FOR OWXXCOLL.STORED1;
3) CALL DB2C.STORED1();
EDIT 2021-05-14
The original question arises for the following problem (I was hoping to get away with using aliases)
Intro
I have defined a native SP
The OWXXCOLL schema is the same one I also use for tables/index...
(I noticed that the tables also have different aliases)
CREATE PROCEDURE OWXXCOLL.STORED1(...)
LANGUAGE SQL
ISOLATION LEVEL CS
WLM ENVIRONMENT FOR DEBUG MODE WLMENV1
ALLOW DEBUG MODE
BEGIN
...
END#
I also modified the cobol program (name:PGMSTO1) to call the Stored with the CALL statement (without qualifier)
EXEC SQL
CALL STORED1 (...)
END-EXEC.
The problem
The various table accesses (SELECT) work correctly BUT When I run the PGMSTO1 the call to the Stored ends with sqlcode -440
NO AUTHORIZED PROCEDURE BY THE NAME STORED1 HAVING COMPATIBLE ARGUMENTS WAS FOUND<
The error comes from the fact that it is not using the owner OWXXCOLL but DB2C (DB2C is user who scheduled the jcl/batch)
If I enter the qualifier (OWXXCOLL) the call it's OK.
I don't understand what to check and what configurations are missing.
Thanks
The cobol program (PGMSTO1) that calls the stored procedure has the following BIND parameters:
COLLID NAME OWNER CREATOR QUALIFIER DYNAMICRULES PATHSCHEMAS
OWXXCOLL PGMSTO1 DB2C DB2C FPXX B "DB2C"
"DB2C" path is used to resolve unqualified stored procedure
I will need to modify the bind parameter "PATH".
I will try to ask to add my schema as well (OWXXCOLL)
PATH("OWXXCOLL","DB2C")

Is this a bug: stored procedure runs fine without parameters, causes error when parameters are added?

I have a stored procedure created in MySQL DB. This database is accessed as linked server through Microsoft SQL Server 2012 using Microsoft SQL Server Management Studio. The provider selected while creating linked server is "Microsoft OLE DB Provider for ODBC Drivers".
When I run following as text from Report builder 3.0 it runs fine and fetch data.
EXEC('CALL storedProcedureName(''string1'', ''string2'', ''string3'')') AT LinkedServerName;
But when I try to replace string1, string2, string3 with parameter name parameter1, parameter2, parameter3 as:
EXEC('CALL storedProcedureName(#parameter1, #parameter2, #parameter3)') AT LinkedServerName;
I get error:
Could not execute statement on remote server 'LinkedServerName'.
(Microsoft SQL Server, Error: 7215)
And when I try:
EXEC('CALL storedProcedureName('#parameter1', '#parameter2', '#parameter3')') AT LinkedServerName;
I get the prompt to enter values for parameter1, parameter2, parameter3. But when I enter the values and click ok, I get error:
Incorrect syntax near '#parameter1'. (Microsoft SQL Server, Error: 102)
Question: Am I missing something in syntax or is this a bug?
The linked server has:
"RPC" and "RPC out" set to True.
And the OLEDB provider has:
Enabled allow inprocess
Enabled dynamic parameter
I believe you have to call it like the below. So params become strings wrapped in single quotes:
EXEC('CALL storedProcedureName('''+#parameter1+''', '''+#parameter2+''', '''+#parameter3+''')') AT LinkedServerName;
I know this is an older question but the accepted answer is open to SQL Injection and I think it's important to offer a more secure method.
You really want to use a parameterized query
EXEC('CALL storedProcedureName(?,?,?)',#parameter1, #parameter2, #parameter3) AT LinkedServerName;
I know this works for oracle and it should work for MySql as well.

neo4j: user defined procedure exception "Write operations are not allowed for `READ` transactions"

I have implemented a user defined procedure using the example template.
The procedure is annotated using "#Procedure(value = "foo.bar", mode = Mode.WRITE)", nevertheless, when I try to execute an operation on a Node instance that modifies the graph, it fails with "Write operations are not allowed for READ transactions".
The node instance was obtained via db.findNode(...), and the write-operation that I am attempting to execute is nodeinstance.createRelationshipTo(...)
Interestingly, the code works fine when run in the context of the neo4j testing harness.
Any help greatly appreciated!
From inspecting the APOC user defined procedures, I learned the answer. I am using neo4j 3.0.7, for 3.0.x a procedure that wants to write to the graph must be annotated with "#PerformsWrites", as well as "#Procedure". The mode argument", mode = Mode.WRITE", is for 3.1, and "#PerformsWrites" is for 3.0.x -- learned this from Stefan Armbruster

On IBM i, how to run a stored procedure via DB2 command of QShell?

How would you run a stored procedure via DB2 command of QShell, as I need a simple way to unit test a change to a stored procedure?
On IBM i
Started qshell with
QSH
Entered these db2 commands in various formats without success
db2 call libraryname.stroredprocedurename('param1value' 'param2value' ?)
db2 call libraryname.stroredprocedurename ('param1value' 'param2value' ?)
db2 call libraryname.stroredprocedurename (param1value param2value ?)
Only reference source I could find
Have tried using CLP to call stored proceduresbut there are no CLP examples
here
You can also use the JDBC client included with jt400.jar. You can run it from QSH by using the following command.
java -cp /qibm/proddata/os400/jt400/lib/jt400.jar com.ibm.as400.access.jdbcClient.Main jdbc:db2:localhost
The client will also handle stored procedure output parameters as shown by the following example.
create procedure add1(in inparm int, out outparm int) language sql begin set outparm = inparm +1; end
call add1(1,?)
Parameter 1 returned 2
I use Squirrel SQL Client http://squirrel-sql.sourceforge.net/ to test all of my SQL.
call libraryname.stroredprocedurename('param1value', 'param2value')
Note the separator is a comma ,, and ? is not a valid parameter marker when called interactively like this.
In addition to the client, you will need a JDBC driver. You can use the JTOpen driver for IBM i found here: http://jt400.sourceforge.net/
From the CL command line, or inside a CL program, you can use the RUNSQL command to execute an SQL statement.
If you're going to be trying multiple ad hoc SQL statements, you might use the STRSQL command. Personally, I tend to use the SQL window provided as part iNavigator.
Finally got the basic syntax
db2 "CALL lib.proc ('parmvalue1')"
Which resulted in:
DB20000I THE SQL COMMAND COMPLETED SUCCESSFULLY.

SSIS Execute SQL Task MCH1202 Error

In an SSIS package I am developing I have an execute SQL task which uses an ODBC Connect to a database on iSeries AS400 the task calls a stored procedure:
{CALL DOCTRACK.CORRFEED (?,?,?,? )}
The stored procedure takes 4 parameters the first 2 input and last 2 output.
The Data types of the parameters are char(8), integer, decimal(7,0) and char(80) respectively. The parameters are mapped to the variables in the package that match the data types.
When I run the package I get the following error message on the Execute SQL Task:
[Execute SQL Task] Error: Executing the query "{CALL DOCTRACK.CORRFEED (?,?,?,? )}"
failed with the following error: "[IBM][System i Access ODBC Driver][DB2 for i5/OS]CEE9901 -
Application error. MCH1202 unmonitored by CORRFEED at statement 0000000020, instruction X'0000'.".
Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,
parameters not set correctly, or connection not established correctly.
Does anyone have any ideas what may be causing the error?

Resources