Calling stored procedure inside View in Netezza - netezza

Can we call a stored procedure inside the View in Netezza?
I am doing Oracle to Netezza Migration.
We have a view in Netezza that uses CONNECT BY ROOT.
To replicate CONNECT BY ROOT, we have written a stored procedure.
How to call that stored procedure from a view?

While stored procedures can be called with a SELECT form, I don't think they can be called that way from within a view.

Related

What is "assembly stored procedure" type mean?

I have a SQL Server database with a lot of stored procedures. I use the system stored procedure sp_help to view information about these stored procedures.
There are a lot of stored procedure that have type = 'stored procedure' in information view, but some of the stored procedures have type 'assembly stored procedure'.
What is the difference between them?
And what is the purpose of using that type of stored procedure?
In SQL Server you are able to create SQL CLR objects, which basically allows you to create .NET routines (functions, stored procedures, triggers and even custom aggregates).
For example, you can use .NET to implement regex functions, or in the past, when STRING_AGG did not exist, to create custom aggregate for string concatenation.

PL/SQL Package DBMS_HS_PASSTHROUGH

I have an oracle function which needs to call a SQL Server Stored Procedure.
I created a database link in oracle to the SQL Server.
I'm using DBMS_HS_PASSTHROUGH to call the stored procedure and it actually calls it. The stored procedure has some logic in it. There are some select statements in the Stored Procedure and those actually work, but it also contains some update/insert/delete statements and those do not work.
When I commented out all the update/insert/delete, I get a successful response from the SQL Server executing the Stored Procedure back to Oracle. When those updates and inserts are to be performed, I get
"ORA-00942: table or view does not exist"
Like I said I'm able to execute stored procedure, also a nested stored procedure gets executed, functions work as well. The problem is when update/insert/delete are to be performed. I checked the permission on the table and all seem to be correct.
For example, if I Deny execution of stored procedure for the DBLINK user, I will get a response Access Denied. But if I Deny Select Statements for the DBLINK for that table, those Select Statements will still get executed. It seems like if once we are in the Stored Procedure, the user executing the select/update/insert/delete is not longer "DBLINK".
any help would be appreciated!
I'm not expert on this, so if you guys know of a better way to call a stored procedure from oracle, please let me know.

SQL Server stored procedure - designate database to use

I am tasked with creating a stored procedure from a script I wrote which will update tables with data.
Since I run this script against a dev database and a live database, we have always manually changed the USE DATABASE in the script before running.
I am looking for a way to use USE DATABASE within a stored procedure.
Is this possible without having to create two stored procedures of the same script for each database (dev versus live)?
Assuming you mean MS SQL Server. You cannot use USE ... within a stored procedure, but you can directly reference a different database with fully qualified object notation.
database.schema.objectname
Example:
dev_mydb.dbo.MyTable
Do note though that if you need that database name to be variable then you will need to use dynamic SQL to set the dbname.

How to execute a SQL query in Azure Data Factory

I create a pipeline in ADF for performing copy activity. My source database is Azure SQL database and Sink is Azure Blob .I want to execute an SQL Query in ADF to delete data from source once data is copied to blob. I am not allowed to use copy or lookup to execute query.Is their any custom way to do this.I need to create a view and have to do some activity.Please help
You can also use the built-in stored procedure sp_executesql, which allows you to provide a random SQL statement as parameter.
That way you don't have to implement your own stored procedure.
See more information about this stored procedure on sp_executesql (Transact-SQL).
If you are using data mapping flows, there is a new activity to execute custom SQL scripts:
Azure Data Factory mapping data flows adds SQL scripts to sink transformation
In a regular pipeline, you probably have to resort to using the Stored Procedure activity:
Transform data by using the SQL Server Stored Procedure activity in Azure Data Factory
You would have to write the delete logic in the SP, and then invoke the SP from Data Factory.
You can write a stored procedure for deleting the data from source table and call that stored procedure in "Stored procedure" activity after copy activity.
Your data flow will look like:
COPY ACTIVITY -----> STORED PROCEDURE ACTIVITY
They have rolled out the script activity
The script task can be used for the following purposes:
Truncate a table or view in preparation for inserting data.
Create, alter, and drop database objects such as tables and views.
Re-create fact and dimension tables before loading data into them.
Run stored procedures. If the SQL statement invokes a stored procedure that returns results from a temporary table, use the WITH RESULT SETS option to define metadata for the result set.
Save the rowset returned from a query as activity output for downstream consumption.
Script task is present under General tab of Activities.
Ref 1
https://learn.microsoft.com/en-us/azure/data-factory/transform-data-using-script
Ref 2
https://techcommunity.microsoft.com/t5/azure-data-factory-blog/execute-sql-statements-using-the-new-script-activity-in-azure/ba-p/3239969

How to use a system stored procedure in LINQ to SQL

I'd like to add the "msdb.dbo.sp_help_job" system stored procedure to a LINQ to SQL object, but I can't figure out how to specify it. If I create a new Data Connection in Server Explorer and specify the "msdb" database of the server I want, and navigate to "Stored Procedures", that procedure is not listed. Am I looking in the wrong place?
I've added regular (user defined) stored procedures in the past with no problem. I know I could get there by executing it via "ExecuteCommand" on the data context, and I could also create a "wrapper" stored procedure that did nothing but call "sp_help_job", but I'd like to know how to hook it up directly to LINQ, or if it's even possible.
The System Stored Procedures are not actually sitting inside your database, but rather the Read-Only Resource database.
http://msdn.microsoft.com/en-us/library/ms190940.aspx
However, here's how you can make it possible to find them:
Accessing System Databases/Tables using LINQ to SQL?

Resources