stored-procedures

Simple Oracle Stored Procedure getting Invalid object error

Hello, I am trying to write a simple Oracle Stored Procedure: CREATE OR REPLACE PROCEDURE act.skeleton IS DECLARE v_rowCount NUMBER; BEGIN SELECT COUNT(1) INTO v_rowCount FROM ex.emp; DBMS_OUTPUT.PUT_LINE(v_rowCount); END; However, when I try & run the procedure by issuing execute act.skeleton in PL/SQL Developer command window...

Insert data into SQL server with best performance

I have an application which intensively uses DB (SQL Server). As it must have high performance I would like to know the fastest way to insert record into DB.Fastest from the standpoint of execution time. What should I use ? As I know the fastest way is to create stored procedure and to call it from code (ADO.NET). Please let me know ...

T-SQL SQL Server - Stored Procedure with parameter

Please, the first TSQL works FINE, the second does not. I guess it must be a simple mistake, since I am not used to T-SQL. Thank you for the answers. R Conte. *** WORKS FINE *********************************** (parm hard-coded) ALTER PROCEDURE rconte.spPesquisasPorStatus AS SET NOCOUNT ON SELECT pesId, RTRIM(pesNome), pesStatus, ...

Drawbacks of Dynamic Query in Sqlserver 2005 ?

I have using the many dynamic Query in my database for the procedures because my filter is not fix so i have taken @filter as parameter and pass in the procedure. Declare @query as varchar(8000) Declare @Filter as varchar(1000) set @query = 'Select * from Person.Address where 1=1 and ' + @Filter exec(@query) Like that my filter cont...

T-SQL: if exists always return true ?

Hello, What do you think , does the Stored Procedure always return 1 ? I am concerned about the if exists(..) BEGIN DECLARE @IsUserExisting bit SET NOCOUNT ON IF Exists ( Select null FROM G_User WHERE SamAccountName = @SamAccountName AND NetBIOSDomainName = @NetBIOSDomainName ) BEGIN SET @IsUserExi...

Postgresql - Edit function signature

POSTGRESQL 8.4.3 - i created a function with this signature CREATE OR REPLACE FUNCTION logcountforlasthour() RETURNS SETOF record AS realised i wanted to change it to this CREATE OR REPLACE FUNCTION logcountforlasthour() RETURNS TABLE(ip bigint, count bigint) record AS but when i apply that change in the query tool it isnt accept...

Can anyone say Stored procedures pros and cons AND Java Stored Procedures pros and con?

Hi! Can anyone say Stored procedures pros and cons AND Java Stored Procedures pros and con? And how to test it. Best regards! ...

In a stored procedure how to run a query and conditionally do something

How would I do this in a stored procedure (SQL 2005): count = select count(*) from table1 where line like '%success%' if count > 0: delete from table1 where not line like '%success%' Thanks for any help. My google skills are really failing me today :-( ...

How to count two fields by using Select statement in SQL Server 2005?

Total records in table are 10. Select count(ID) from table1 where col1 = 1 (Result is 8) Select count(ID) from table1 where col1 = 0 (Result is 2) So its a same table but count is based on different condition. How am i gonna get two results (counts) using one select statement? Also Performance is a big concern here. PS: I am using ...

Stored procedure call in method with OperationBehavior attribute: problems with transactions

I'm using ADO.Net's ExecuteNonQuery to call a stored procedure, works like a charm stand-alone but when implementing it where it should be called I'm running into problems concerning transactions. For example System.Data.SqlClient.SqlException: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statemen...

How to salvage SQL server 2008 query from KILLED/ROLLBACK state?

I have a stored procedure that inserts batches of millions of rows, emerging from a certain query, into an SQL database. It has one parameter selecting the batch; when this parameter is omitted, it will gather a list of batches and recursively call itself, in order to iterate over batches. In (pseudo-)code, it looks something like this: ...

Trouble creating stored procedure

I'm messing around with stored procedures for the first time, but can't even create a simple select! I'm using phpMyAdmin and this is my SQL: DELIMITER // CREATE PROCEDURE test_select() BEGIN SELECT * FROM products LIMIT 10; END // DELIMITER ; After submitting that, my localhost does some thinking for a loooong time and eventuall...

MySQL Stored Procedure: Boolean Logic in IF THEN

I'm looking for the proper syntax (if this is possible in MySQL stored procedures) for using logical operators in an IF THEN statement. Here's something along the lines of what I would like to do, but I'm not certain if I should type "OR" or "||" in the IF ... THEN clause: DELIMITER $$ CREATE PROCEDURE `MyStoredProc` (_id INT) BEGIN ...

Oracle : Getting Notification when table gets new data's

In psql we have PL/Perl to communicate with external program when the new row is inserted into our table. Like that is there any way (procedural language ) to communicate with external program in Oracle . For achieving this things, what should I do.....? Can any one help me out of this problem..... ...

How to use External Procedures in Triggers on Oracle 11g..

Hi, I want to fire a trigger whenever an insert command is fired.. The trigger will access a pl/sql file which can change anytime.. So the query is, if we design the trigger, how can we make sure this dynamic thing happens.. As during the stored procedure, it is not workingg.. I think - it should work for 1) External Procedures 2)...

MYSQL variables - SET @var

I am attempting to create a mysql snippet that will analyse a table and remove duplicate entries (duplicates are based on two fields not entire record) I have the following code that works when I hard code the variables in the queries, but when I take them out and put them as variables I get mysql errors, below is the script SET @tblna...

Reporting Services - SQL query takes 10 times as long, 100% cpu, when in a stored procedure vs inline SQL

I have a SQL query - fairly complex, but not too bad. When I run the SQL query in Management Studio, the query runs in about 10 seconds or less. When I put the SQL query directly into a reporting services report, the query runs in about 10 seconds or less. When I put the exact same SQL query into a stored procedure, and cal...

How to call a stored procedure using HibernateTemplate in spring framework?

Hi Experts, Can anyone help me with calling a stored procedure using HibernateTemplate in spring framework? I'm new to Hibernate, so please help me with this. Thanks in advance, Sinu Mathews ...

Large number of UPDATE queries slowing down page

I am reading and validating large fixed-width text files (range from 10-50K lines) that are submitted via our ASP.net website (coded in VB.Net). I do an initial scan of the file to check for basic issues (line length, etc). Then I import each row into a MS SQL table. Each DB rows basically consists of a record_ID (Primary, auto-increm...

Table-Valued Parameter in Stored Procedure and the Entity Framework 4.0

Hi there, I have a stored procedure in SQL Server 2008 called 'GetPrices' with a Table-Valued Parameter called 'StoreIDs'. This is the type i created for this TVP: CREATE TYPE integer_list_tbltype AS TABLE (n int) I would like to call the SP from my Entity Framework. But when I try to add the Stored Procedure to the EDM, i get the f...