How to use stored procedure inside the stored procedure in Postgresql - postgresql

I have been working on my code for our activity in our major comp sci subject. The task asks to update a certain field in the table in postgresql using stored procedure
I have already create a gettopemp() to retrieved the data in the table, and I want to retrieve the information of gettopemp() to my new stored procedure updatetopemp(). How to use stored procedure inside the stored procedure ???

If you want to pass a function name as a parameter and call that in your code, you'll have to use dynamic SQL.

Related

Pass table as argument to postgreSQL function?

is it possible to pass table/list/json as argument to postgreSQL function from .net core API? The requirement is like for an invoice, there are multiple line items. so we want to save invoice first and then it's respective multiple line items. for line items, we have to either call postgreSQL function one by one and insert line item to DB. so just checking if SQL bulk inset like functionality is available in PostgreSQL.
CREATE FUNCTION test(table sometable)
RETURNS TABLE(id bigint, vendor_id bigint)
BEGIN
-- bulk or single insert multiple records from argument table into postgreSQL table
END;
Thanks,
So, I came to know that json can be passed to postgresql function and there are plenty of functionality is available to extract value from json in postgresql function makes life easy.

How to give stored procedured name dynamically in Talend tDBSP

I have a table name called abc in oracle db, which has two fields S.No, and procedure name. I am calling the S.No and procedure name, where SNO is input given by me (while executing the job, it asks for S.No). Once I get the procedure name related to that particular S.No, I am sending procedure name to tFixedFlowInput and from there, connecting to the tDBSP (Oracle) to execute the procedure.
In tDBSP (Oracle), I want to give the stored procedure name got from tFixedFlowInput dynamically. So, in future I need to give only the S.No, as input and it should execute the related stored procedure. Kindly help me in achieving this.
Also, the procedure has one input parameter.

PostgreSQL how to write a stored procedure to get the First and last name from a table

I want to write a stored procedure in PostgreSQL that get input parameters and then select data based on conditions using that input parameter values. How I can achieve this easily?
I only have to use the PostgreSQL stored procedure and and not function for this
In PostgreSQL if we want to return result set in tabular format we have to use functions. they are best way designed to do this all functionality

Join to Stored Procedure Using Entity Framework

I have a stored procedure that grabs data recursively. I did a function import in my entity set. I can create a function in my ObjectContext that looks like this:
public ObjectResult<ProviderAccountSetting> GetProviderAccountSettings(long providerAccountId)
{
string functionName = "MyContainer.GetProviderAccountSettings";
ObjectParameter providerAccountIdParameter = new ObjectParameter("providerAccountId", providerAccountId);
ObjectResult<ProviderAccountSetting> results = context.ExecuteFunction<ProviderAccountSetting>(functionName, providerAccountIdParameter);
return results;
}
However, I cannot perform a join with LINQ without getting an error. Is there a way to tell Entity Framework to use the stored procedure whenever I access an entity? I would like my stored procedure to be used any time I grab data for that entity. Furthermore, I want it to work with joins. Does Entity Framework support this type of stored-procedure to table mapping? Otherwise, is there a way to join a function import?
Neither of your requirement is possible. You cannot tell EF to use stored procedure every time when you query data. You must manually call your GetProviderAccountSettings to call stored procedure. You also cannot use join (on database side) when using stored procedures (it is even not possible in SQL directly). If you need to join any data to result set of your stored procedure it must be done directly in the procedure and returned as result set. Otherwise you must execute your stored procedure and joined query separately and join them in linq-to-objects.

map stored procedure to entity returning temproray table data

I have a stored procedure that returns the temporary table data. because i have used dynamic queries. When i tried to map stored procedure using complex types it returns no columns
how to handle temporary table columns name in complex types?
It is not supported by default because EF always executes SET FMTONLY ON before executing your stored procedure. This option will turn off logic execution - it will only ask for metadata but if logic execution is turned off no temporary table is created and no column's metadata exists.
There are some workarounds.