I need to save a few parameters into Teradata via Tableau, I created a Teradata procedure to do insertion but when I connect to the procedure in Tableau it kept on giving me error "xxxx stored procedure returned no result. bla bla".
In order to make stored procedure returns some result, I update the Teradata procedure to include a OUT parameter to return a dummy message, but in the list of Stored Procedures under Tableau connection, all procedures with OUT parameter are not showing.
Appreciate if anybody can help.
Tableau does not support procedure OUT parameters. You need the procedure to return a result set, e.g.
REPLACE PROCEDURE myProc(someInput INTEGER,...)
...
DYNAMIC RESULT SETS 1
...
BEGIN
DECLARE csr CURSOR WITH RETURN FOR SELECT 'OK';
...
OPEN csr;
END;
Related
I wanted to 'Call' MariaDB Procedure from Azure Data Factory.
How can this be achieved, are there any other service which can be integrated with ADF to call this MariaDB procedures
I tried calling the procedure by writing the query using lookup activity.
It fails while showing this error.
ErrorCode=InvalidParameter,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=The value of the property 'columns' is invalid: 'Value cannot be null.
Parameter name: columns'.,Source=,''Type=System.ArgumentNullException,Message=Value cannot be null.
Parameter name: columns,Source=Microsoft.DataTransfer.Common,'
Lookup activity reads and returns the content of the query. I tried to repro this by creating three stored procedures in Azure SQL database for Maria DB.
First Stored procedure is written to update the data in the table.
DELIMITER $$
CREATE PROCEDURE update_inventory()
BEGIN
UPDATE inventory SET quantity = 150
WHERE id = 1;
END$$
DELIMITER ;
When this procedure is called in ADF lookup activity, error occurs.
Second stored procedure is written with select query.
DELIMITER $$
CREATE PROCEDURE select_inventory()
BEGIN
select * from inventory;
END$$
DELIMITER ;
When this SP is called, ADF pipeline is executed successfully.
In order to execute the stored procedure with update statements (or any statements), a select statement is added in the Stored procedure.
DELIMITER $$
CREATE PROCEDURE update_select_inventory()
BEGIN
UPDATE inventory SET quantity = 150
WHERE id = 1;
select * from inventory;
END$$
DELIMITER ;
When this stored procedure is called through Lookup activity, it got executed successfully.
Try adding select statement in the stored procedure and execute it in Lookup activity. Or add Select statement after Call stored procedure statement.
By selecting the 'query' option, you can call the stored procedure using lookup activity. From your error message, it looks like you are missing the parameter columns while calling the stored procedure.
Did you try executing the same code using the client tools like MySQL workbench? If you can execute the stored proc from other client tools, then you should be able to execute the same using the lookup activity.
I tested from my end and was able to execute the Stored procedure using lookup activity. Please see the below screenshot for your reference.
I am using SQL Server always encrypted on feature for SSN column. I have created a stored procedure and calling it from .net code. I am using column encryption setting=true in my connection string. Calling the dynamic stored procedure from the .net code throws this error:
Operand type clash: varchar is incompatible with varchar(4) encrypted with (encryption_type = 'DETERMINISTIC', encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256', column_encryption_key_name = 'ColumnKey', column_encryption_key_database_name = 'DatabaseName') collation_name = 'SQL_Latin1_General_CP1_CI_AS'
Could someone please provide a sample code which would work to retrieve data with the search on encrypted column using parameterization?
CREATE PROCEDURE [dbo].[testSSN_Dynamic]
#Last4SSN VARCHAR(50)
AS
BEGIN
DECLARE #query NVARCHAR(4000);
SET #query = 'Select [SSNumber], [last4SSNumber] from table_XXX WHERE last4SSNumber = #Last4SSN ;'
EXEC sp_executesql #query, N'#Last4SSN varchar(4)', #Last4SSN ;
END
In the application SSN number is encrypted using Randomized encryption. Last4SSNumber is encrypted using Deterministic encryption. The search is based on last 4 digit of SSN number and the filtered list will get the SSN number only with the last 4 matching digit, rest all the digits are masked in the application. Since both the encryption Randomized and deterministic do not support like operation the column last4SSNumber was added.
When I call the above Stored procedure without the dynamic SQL from .NET code, it works fine and I am able to retrieve the list of matching last 4 digit of SSN..
In the application there are existing stored procedure with quite a few parameters passed to them. The search criteria is based on if the value is passed to the parameter or not. Last4SSNumber is one of the parameter passed. I have provided a simple sample of the stored procedure and not the entire stored procedure with all of the parameters. The search criteria is build, depending on the value passed to the parameter.
In various post it has been pointed out that the Dynamic SQL has to be converted to Parameterized query in order to use the always encrypted on feature. I applied parameterization to the above stored procedure still I receive the error when calling the stored procedure from the .NET code.
Use Dynamic SQL with parameters that evaluate against encrypted columns is currently not supported.
Unfortunately executing the query in the manner below is not supported by Always Encrypted
EXEC sp_executesql #query, N'#Last4SSN varchar(4)', #Last4SSN ;
However, if you are able to restructure your stored procedure in the following manner, you may have a working solution.
CREATE PROCEDURE [dbo].[testSSN]
#Last4SSN VARCHAR(50)
AS
BEGIN
Select [SSNumber], [last4SSNumber] from table_XXX WHERE last4SSNumber = #Last4SSN ;
END
I wrote a stored procedure ,
ALTER PROCEDURE [dbo].[getCustomerSearch]
-- Add the parameters for the stored procedure here
#clientNo varchar(50)
AS
BEGIN
-- Insert statements for procedure here
SELECT cs.* FROM [mm].[dbo].[CM_customerStatus] as cs WHERE cs.[ClientNo] like #clientNo;
END
I want to access that list of table records from spring JPA repository as List of object.Is there any way to do this task???
You can extend your JPA repository and use EntityManager to run a stored procedure in spring data jpa. Use createNamedStoredProcedureQuery to fire your stored procedure.
Query query = entityManager.createNamedStoredProcedureQuery("YOUR_PROCEDURE");
query.setParameter("arg", ARG);
query.getResultList();
Also check this question for more details.
I have written a Stored procedure which return some fields from a temporary table which i create in this stored procedure. but when I include it in my dbml file it show return type of my stored procedure as int. which should be not as am returning field from table although its temporary.
Linq-to-SQL uses the SQL Server "fmtonly" setting to determine return type from stored procedures. This is to avoid having stored procedures that make changes to the database do so inadvertedly when getting their signature.
If your stored procedure is safe to execute with no param values etc, you can simply add "set fmtonly off;" in the beginning of the procedure. Linq-to-SQL will then be able to correctly identify the return type from the stored proc.
there are a few suggestions as to how to work around this problem here.
I'm working on an ASP.NET project with an Oracle Database. We are using TOAD to add/manage the stored procedures -- and in general I like TOAD and Oracle. The one thing I've found frustrating is finding a simple way to test an Oracle Stored Proc, such as SQL Server's "exec [SP_NAME] Param1, Param2, ParamN" syntax.
All of our stored procedures output Ref Cursors. Here is an example of a Stored Proc:
CREATE OR REPLACE PROCEDURE APP_DB1.GET_JOB
(
p_JOB_ID IN JOB.JOB_ID%type,
outCursor OUT MYGEN.sqlcur
)
IS
BEGIN
OPEN outCursor FOR
SELECT *
FROM JOB
WHERE JOB_ID = p_JOB_ID;
END GET_JOB;
/
Any suggestions?
You just need a script that calls your stored procedure and has a bind variable for the ref cursor output to display it in TOAD's grid in the Editor window.
DECLARE
type result_set is ref cursor;
BEGIN
APP_DB1.GET_JOB(1, :result_set);
END;
When you then run this TOAD will prompt you to 'bind' :result_set, just select ref cursor from the list of types and then the result will display in the grid. The trick is to think of yourself as a 'client' calling your stored procedure and you need your own ref cursor to store the result.
If you just looking for a way to invoke the SP, then the Oracle way is:
begin
sp_name(....);
end;
I don't use Toad, but you should be able to put this into a SQL window and execute it.
In sqplus you can use the syntax
SQL>var rc refcursor
SQL>exec APP_DB1.GET_JOB(the job id you want to query, :rc)
SQL>print rc
That should do it. The first line defines a bind variable. You could also define a variable for the job id, or just type it in.
TOAD shows the result in a grid just fine with sample script from Russel. Run as script.
variable P_CUR refcursor;
exec PACK.GETEXECUTION ( '9f363e49-88c1-4295-b61e-60812d620d7e', '6', :P_CUR );
print P_CUR;
Thanks!
The idea is just to bind the outCursor variable to a cursor when toad prompts you for the variable type. Just pass the other variables the usual way. Like in the example below.
BEGIN
APP_DB1.GET_JOB(1, :v_outCursor);
END;
Run it and a dialogue box will prompt you to bind the :outCursor variable as shown in the following image.
Toad will then display the result in the result grid.