It is possible to call Functions using QueryDSL , but is it possible to call Stored procedure present in Derby database using QueryDSL ?
Related
I need to quickly execute stored procedure which updates table with data from different data source in SQL Server. Is it possible to do it with EF7, I have tried FromSql, but this seems to only works with the mapped entities.
It doesn't need to return anything, just execute.
Is there any other method than using SQLConnection, or SQL job running every 10 minutes on the server?
I think you can use DbContext.Database and ExecuteSqlCommand to execute your stored procedure.
_db.Database.ExecuteSqlCommand("EXEC mySp");
I have a PL/SQL package (say package1) which contains only 1 procedure. This procedure is used for security purpose and stores the application logged in user using SET_CONTEXT method.
I have another package (say package2) which contains several procedures related to application functionality but they use the SYS_CONTEXT to get the logged in user.
Whenever I want to call package2's procedures from Java, I want package1's procedure to be executed first and then package2's procedures. The reason is I want both these calls to happen in the same database connection.
Is there a way to configure this in Oracle instead of repeating the call to package1's procedure inside each and every package2's procedures.
Assuming your procedure in package1 is public (i.e., declared in the package specification), and assuming your package2 procedures have an EXECUTE authority on package1, one of the possible solutions will be using INITIALIZING PACKAGE .
The initialization consists of all the statements following the BEGIN statement at the end of the package declaration to the END statement
Ex.
PACKAGE BODY package2
IS
--All your package2 procedures
--initialization section at the end of package2:
BEGIN
package1.procedure1();
END package2;
This initialization section, will be run only the first time your session uses a package2 (by using any function/procedure in it). The package will be re-initialized in the same session if it is recompiled.
Another way to solve this problem is place code of package1 (package1.procedure1();) into user logon trigger or call that procedure from that trigger; please find example bellow for trigger
Example:
CREATE OR REPLACE TRIGGER hr_logon_trigger
AFTER LOGON
ON HR.SCHEMA
BEGIN
-- you code here or call to package1.procedure1();
END;
I need help in creating logs in a stored procedure.
Scenario is like:
I am creating a procedure. I need to log some intermediate information from the procedure in a log file, such that each time the procedure is executed the logs are generated.
Normally i was using SPOOL for this purpose, but as SPOOL is SQL PLUS and cannot be used in PL/SQL, i was look for a better way through which logs written to specific file each time the procedure is triggered informing the updates which are made in the procedure.
Can someone please help me in identifying any such code snap which i can insert in the stored procedure in order to meet my requirement.
NOTE: I am using Oracle.
You could simply create a package with simple logging functionality, which opens, writes and closes a log file that is stored on the database server. Look into the UTL_FILE package;
Is it possible to do
alter session set current_schema=MySchema;
inside a package?
Our asp.net web application call Oracle packages. We'd like to connect to database with an Oracle user that is not the owner of MySchema. For that, we grant execute permissions on Other_User to package MyPackage.
Example:
grant execute on MySchema.MyPackage to Other_User
But when web app connects to Oracle and try to execute the stored procedures of MyPackage, it gets errors because tables don't belong to Other_User.
One way to avoid errors is creating synonyms, but we would prefere to use
alter session set current_schema=MySchema;
if possible, inside the package.
EDIT: When trying to put "alter session" in package:
You cannot use DDL statements (which ALTER SESSION is) directly in PL/SQL.
You need to use an EXECUTE IMMEDIATE:
execute immediate 'alter session set current_schema=MySchema';
We noticed in a SQL Server Profiler trace that this proc is being called:
sp_procedure_params_managed
Each call has 350+ reads in the trace!
We are using Microsoft.Practices.EnterpriseLibrary.Data in an ASP.NET front end.
How can we eliminate these stored procedure calls? We are not explicitly calling it in code.
I'm running Sql Server 2005 and Enterprise library 3.1.0.0.
sp_procedure_params_managed is used determine the stored procedure parameters. I guess the Microsoft.Practices.EnterpriseLibrary.Data uses it to determine what the parameters are for the stored procedure call. It will probably cache the results to prevent extra overhead.