How to give stored procedured name dynamically in Talend tDBSP - talend

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.

Related

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

How to use stored procedure inside the stored procedure in 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.

Passing schema name as parameter in db2 - unix

I have one stored proc in db2 (luw) on schema A which looks like below.
CREATE PROCEDURE A.GET_TOTAL (IN ID CHARACTER(23))
BEGIN
DECLARE CURSOR1 CURSOR WITH HOLD WITH RETURN TO CLIENT FOR
SELECT * FROM B.employee e where e.id=ID
END
Given sproc which exist on schema "A" runs query on another schema "B". This another schema name B may changed based on application logic. How can i pass the schema name as parameter to this sproc?
First, I do not think that stored procedure works because the select statement is not defined in a cursor or a prepared statement.
If you want to execute a dynamic SQL in a stored procedure, you need to define in a stmt, then prepare it and execute it.
Let's suppose you pass the schema name as parameter; If you want to change the schema, you can execute dynamically "set current schema" or concatenate the schema name in your query.
For more information: http://www.toadworld.com/platforms/ibmdb2/w/wiki/7461.prepare-execute-and-parameter-markers.aspx

Decide which procedure to call, depending on field value

I have about 20 (and there will be more) specific stored procedures in my PostgreSQL 9.2 DB. They are used to make some calculations, some kind of financial "reports" (unfortunately, I can't just store data in tables and implement algorithms in the programs's code).
Procedures are very different one from another, they're operating on different tables, columns, implementing different algorithms etc.
Every procedure returns the same data type (numeric value).
And now, my client wants to create the funcionality, where user can select specific procedure (or combination of them, e.g. 10% of procedure's 1 returning value + 90% of procedure's 2 returning value), and use it as a "base" for later modeling.
He wants also my user to be able to change his selection later, without calling programmers every time. ;-)
I thought about making some tables:
Table: base_models
id <PK>,
user_id, <FK from users table>
model_name (varchar, or sth.)
Table: base_models_algorithms
base_model_id <FK from base_models>
algorithm_id <FK from algorithms>
percent_value (percent value of specific algorithm in model, eg. 10)
...and then, I need to store also my algorithm names (= stored procedures) in some table:
Table: algorithms
name: (stored procedure name, varchar?)
... and that's where the problem is.
Of course I can later create some view, with a column calculated by another procedure (model_current_value :-)), and decide what procedure to call depending on name stored in my algorithm's table, but that look awful for me. :(
There would be no data control (you can write anything to algorithms' table, and there is no way to ensure that this string is a name of procedure, returning correct data type etc.).
Of course I can fill the table myself, and won't let anyone to change it's data :-)
But maybe there is more elegant way to do the whole thing?
It sounds like you want the PL/PgSQL EXECUTE statement. You can use this to invoke dynamic SQL, eg for a 2-argument procedure with dynamic name:
EXECUTE format('SELECT %I($1,$2)', func_name) USING arg1, arg2;
This is a PL/PgSQL statement. It is not available in regular SQL. You can of course create a simple PL/PgSQL procedure that does this statement and call that from SQL.

Advantage database how to retieve connection name

I am using Sybase Advantage, I have 2 tables:
The first table has the data records
The second table stores a history of the first
The first table has triggers to populate records in the second table depending on which fields get changed.
I would like to store the connection name (PC which made the request), the name that is displayed in the active queries page (Server Info dialog) and not the username. Does anyone know if this is possible?
Thanks
The following SQL statement can be used to retrieve the computer name instead of the user name.
SELECT *
FROM
( EXECUTE PROCEDURE sp_mgGetConnectedUsers() ) ConnUsers
WHERE
ConnUsers.DictionaryUser = USER();
The stored procedure sp_mgGetConnectedUsers is documented here.