Select the body of a stored procedure in Teradata - teradata

I would like to apply a hash function to a stored procedure in Teradata, but I haven't found the table/view in the catalog where the definition (the content, the body) of the stored procedure is.

Related

How to execute MariaDB stored procedure from azure data factory?

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.

Tableau connecting to Teradata procedure with out parameters not showing

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;

SQL Server always encrypted with Dynamic SQL

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

To retrieve list of object from stored procedure SQL server through spring-jpa

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.

Linq dbml show int return type for an SP which SP return some fields from temporary table

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.

Resources