stored-procedures

Stored Procedures on Oracle SQL Developer

Hi all, could you point me to a good place to start with Oracle stored procedures syntax/usage? I can't seem to find any good place there. I'm fairly proficient in (java, C/C++) programming and I do know enough SQL for my needs right now, but I've been suggested to use stored procedures to do my business, which is: Take results from a q...

STORED PROCEDURE Calculations & performance improvements

Hi, I currently have the following stored procedure; CREATE PROCEDURE web.insertNewCampaign ( @tmp_Id BIGINT, @tmp_Title VARCHAR(100), @tmp_Content VARCHAR(8000), @tmp_Pledge DECIMAL(7,2), --@tmp_Recipients BIGINT, @tmp_Date DATETIME, @tmp_Private BIT, @tmp_Template BIGINT, @tmp_AddyBook BIGINT ) AS ...

Is this a logical use of MySQL Stored Procedures?

I have a client with a hosted MySQL database whose developer keeps asking me to add really simple stored procedures. I look at a stored procedure like this, and I don't see any reason why it would be implemented as a stored procedure and not implemented within application code. Am I correct that this is really strange use of stored pro...

SQL Server Stored Procedure store return value

Helo, My question is I have one Stored Procedure in SQL Server that returns counts of a field. I want to store the results of this Stored Procedure in a variable (scalar?) of a different stored procedure. sp_My_Other_SP: CREATE PROCEDURE [dbo].sp_My_Other_SP @variable int OUTPUT -- The returned count AS BEGIN -- SP SET NOCOUNT ON; ...

How do I delete a stored procedure in postgresql?

How do I delete a stored procedure in postgresql? ...

sql server 2000: Short cut for getting stored proc text

Hi, what is the short cut to get entire text of the stored proc in query analyzer. I know that I could highlight table name and hit <alt><f1> and get the entire table structure. ...

How do I write a postgres stored procedure that doesn't return anything?

How do I write a simple stored procedure in postgres that doesn't return a value at all? Even with a void return type when I call the stored procedure I get a single row back. CREATE FUNCTION somefunc(in_id bigint) RETURNS void AS $$ BEGIN DELETE from test_table where id = in_id; END; $$ LANGUAGE plpgsql; ...

VB.NET - SQLCommand.ExecScalar() throws unreferenced exception on Return?

I'm calling Sqlcommand.ExecScalar() - stepping through the stored proc works fine, right under RETURN @RecordNum @RecordNum correctly contains a bigint, as scoped. When I step into the RETURN.. I get an exception thrown, that visual studio does not seem to be able to capture. The stored procedure works fine when executed directly, a...

MySQL Function to return table name to be used in a query

Can I use a MySQL function or procedure to return table names that can be used in a query? Something like SELECT * FROM get_db_table_name(2342352412); where get_db_table_name() is a user defined function which accepts a user_id as a parameter and returns the db.table where that user resides. I have not been able to do this this way be...

Stored Procedures executing twice!

For some reason my stored procedures are all executing twice! I have a static function that runs an SP given its name and the parameters and fills a datatable. Public Shared Function RunSP(ByVal spName As String, ByRef spParams As Dictionary(Of String, String), ByRef pDataTable As DataTable) As Integer Dim cmd As New SqlCommand ...

How to store selection result in to variable in Oracle procedure

I write a simple procedure. I try to store selection result in variable. I use "SELECT INTO" query but I can not doing this. Example: DECLARE v_employeeRecord employee%ROWTYPE; BEGIN SELECT * INTO v_employeeRecord FROM Employee WHERE Salary > 10; END; ...

Checking if a collection element exists in Oracle

I create a simple type: create or replace TYPE SIMPLE_TYPE AS OBJECT (ID NUMBER(38), NAME VARCHAR2(20)); Simple test: DECLARE TYPE ObjectList IS TABLE OF SIMPLE_TYPE; tmp SIMPLE_TYPE := SIMPLE_TYPE(1, 'a'); o ObjectList := new ObjectList(SIMPLE_TYPE(2, 'a'), SIMPLE_TYPE(3, 'a')); BEGIN IF tmp.EXISTS(tmp) THEN dbms_out...

Subsonic 3.0.0.3 not generating parameters for stored procedures

I have a SQL Server 2008 database with a bunch of stored procedures. When I use the ActiveRecord Template provided with Subsonic 3.0.0.3, it generates methods for all of my stored procedures, but they do not have any parameters. I am dbo on the server and can execute the stored procedures with no issue from Management studio. Example St...

Linq or Stored proc - Which should I choose?

An Activity occurs at a location on a specific date, but each activity may be repeated at the same or different locations on different dates. I have created an entity framework model, and wish to populate it with relevant Activities which occur between two dates, ordered by the locations distance from a specified location. I therefore ...

calling a procedure or handling in code behind - which is better?

Hi, I am working on ASP.NET 2.0 application with c# language. Can anyone tell me which is the best way of the following : scenario: I need to get data from the database and bind it to the grid view. case 1: I can use a stored procedure(for iteraing the result which is obtained from the basic query and do operations on this result set)...

Error when comparing values in Oracle

I write simple procedure. DECLARE connection_id LINE.CONNECTION_ID%TYPE := 11009; tmp_integer INTEGER; BEGIN SELECT COUNT(*) INTO tmp_integer FROM LINE WHERE LINE.CONNECTION_ID = 11009; DBMS_OUTPUT.PUT_LINE(connection_id); DBMS_OUTPUT.PUT_LINE(tmp_integer); END; Result of the launch: 11009 3 It is good result. I have only...

Columns into row in custom format

I have a sql table called UsersInAuthentication like ----------------------- | AuthUserId | UserId | | 1 | 4 | | 1 | 5 | | 1 | 8 | ----------------------- I wish to get all users in format "(4,5,8)" as string with a single stored proc and If possible I also wish to insert,update,delete operat...

Table-Valued Parameters to CLR Procedures in SQL Server 2008 - possible?

This page from SQL Server 2008 BOL, talks about CLR Stored Procedures and has a section labelled, "Table-Valued Parameters", which talks about how they can be advantageous. That's great - I'd love to use TVPs in my CLR procs, but unfortunately this seems to be the only reference in the universe to such a possibility, and the section does...

Launch Oracle stored-procedure in Java code.

I wrote a stored-procedure in Oracle and now, I want to launch it in Java code. I will describe a problem. I have a object type: TYPE PERSON_TYPE AS OBJECT (ID NUMBER(38), NAME VARCHAR2(20)); And table type: TYPE PERSON_TYPE_TABLE AS TABLE OF PERSON_TYPE; My procedure looks like this: PROCEDURE EVALUATE_PERSON_PROC(P_PERSON_ID IN ...

Optimizing Stored Procedures so they will be processed properly by Linq2SQL

Where I work it is a requirement for us to go through stored procedures as a mechanism to access our data through code. I am using LINQ2SQL to minimize this pain so that I can work with objects instead of ADO.NET directly. I have a situation Linq2SQL is consuming one of my stored procedures an generating code where the return type from...