stored-procedures

Get scalar value from SELECT statement in stored proc, from within a stored proc

与世无争的帅哥 提交于 2021-02-07 08:57:20
问题 I know the preferred method for returning scalar values from stored procs is either using RETURN or an OUTPUT parameter. But lets say that I have a stored proc that returns the value using a select statement: CREATE PROC spReturnNumber AS SELECT 1 Is it possible to get this value from within another stored proc? CREATE PROC spCheckNumber AS EXEC spReturnNumber -- <-- get the return value here? Clarification: I need a solution that doesn't require using an OUTPUT parameter, or using RETURN to

create a procedure that retrieves all indexes on my table and rebuilt

戏子无情 提交于 2021-02-07 07:43:44
问题 I want to create a procedure that retrieves all indexes on my table and rebuilt i retrieves all indexes with this query: select index_name from user_indexes where table_name='your_table_name' and i rebuilt with this query: alter index <index_name> rebuild; Thx. 回答1: create or replace procedure rebuild_indexes( p_owner in varchar2, p_table_name in varchar2 ) as begin for indexes_to_rebuild in ( select index_name from all_indexes where owner = p_owner and table_name = p_table_name ) loop

How to execute Stored Procedures with Symfony2, Doctrine2

♀尐吖头ヾ 提交于 2021-02-07 07:32:14
问题 I am using the following code: use Doctrine\ORM\Query\ResultSetMapping; ... ... ... ... $em = $this->get( 'doctrine.orm.entity_manager' ); $rsm = new ResultSetMapping(); $query = $em->createNativeQuery( 'CALL procedureName(:param1, :param2)', $rsm ) ->setParameters( array( 'param1' => 'foo', 'param2' => 'bar' ) ); $result = $query->getResult(); //$result = $query->execute(); // Also tried $em->flush(); die(var_dump($result)); I am not getting any thing in the $result parameter. Can anyone

HOW TO pass List of objects(a DTO) as single IN parameter to Stored Procedure

戏子无情 提交于 2021-02-07 07:20:31
问题 I want to pass Dto as in parameters and call stored procedure in spring jdbc.Is it possible,In doing so? I want to call stored procedures with dto as in paratmeters instead of setting parameters?Because I have large number of parameters. 回答1: At the moment, there is no way to pass (or return) objects in MySQL stored procedures and functions. BUT, MySQL 5.7 have JSON functions, you can pass a varchar parameter and extract values using JSON_EXTRACT function. See MySQL 5.7 manual: Functions That

Scalar Value from stored procedure via Entity Framework

旧巷老猫 提交于 2021-02-07 05:47:28
问题 I have found a few articles like this one: http://devtoolshed.com/using-stored-procedures-entity-framework-scalar-return-values Yet when I take the step to create a function import for a int32 scalar, this is what gets generated: public ObjectResult<Nullable<global::System.Int32>> MyStoredProcedure(Nullable<global::System.Int32> orderId) { ObjectParameter orderIdParameter; if (orderId.HasValue) { orderIdParameter = new ObjectParameter("OrderId", orderId); } else { orderIdParameter = new

Oracle - return newly inserted key value

雨燕双飞 提交于 2021-02-07 05:43:21
问题 We have a table with a Primary Key that gets populated on insert by a trigger on the table - the trigger gets the next sequence number from a sequence we created for the table and uses that for the value of the key on insert. Now we would like to be able to return that value in our insert procedure (PL\SQL), similar to select @@scope_identity in SQL Server. I have been googling all day and basically come up with nothing - anyone been successful with this before? Thanks 回答1: I don't know if it

How to find out the dependencies of stored procedure using sql

匆匆过客 提交于 2021-02-07 03:44:22
问题 I want a script which will show the dependencies of stored procedure in database. Actually when we manually do view dependency it will take a lot of time I have more than 500 stored procedures. So, I wanted to know that these stored procedures are used in database or not so that I can remove the useless stored procedure. sp_depends is not showing all results because I want all objects that depends on this stored procedure 'usp_Constant_Get_Pvt' and objects on which it depends. EXEC sp_depends

How to find out the dependencies of stored procedure using sql

我们两清 提交于 2021-02-07 03:38:15
问题 I want a script which will show the dependencies of stored procedure in database. Actually when we manually do view dependency it will take a lot of time I have more than 500 stored procedures. So, I wanted to know that these stored procedures are used in database or not so that I can remove the useless stored procedure. sp_depends is not showing all results because I want all objects that depends on this stored procedure 'usp_Constant_Get_Pvt' and objects on which it depends. EXEC sp_depends

Can I have a postgres plpgsql function return variable-column records?

喜欢而已 提交于 2021-02-05 07:52:05
问题 I want to create a postgres function that builds the set of columns it returns on-the-fly; in short, it should take in a list of keys, build one column per-key, and return a record consisting of whatever that set of columns was. Briefly, here's the code: CREATE OR REPLACE FUNCTION reports.get_activities_for_report() RETURNS int[] AS $F$ BEGIN RETURN ARRAY(SELECT activity_id FROM public.activity WHERE activity_id NOT IN (1, 2)); END; $F$ LANGUAGE plpgsql STABLE; CREATE OR REPLACE FUNCTION

Any way to edit data on MS-Access form using SQL View with two tables

左心房为你撑大大i 提交于 2021-02-05 06:11:26
问题 From what I've read it should be possible to edit data described by a view if the data being modified represents only one table and a unique identifier field is included in the data. According to Microsoft Any modifications must reference columns from only one base table Has anyone had any luck creating an MS-Access form that is editable when the underlying recordset is based on a view or stored procedure merging data from two tables? My form only used the secondary table to join a code table