stored-procedures

Spring JDBC versus Derby Stored Procedure ...

Derby documents syscs_util.syscs_backup_database. I made the following trivial class: public class DerbyMemoryDatabaseDumpDao extends JdbcDaoSupport { private SimpleJdbcCall caller; @PostConstruct public void initialize() { caller = new SimpleJdbcCall(getDataSource()).withCatalogName("SYSCS_UTIL") .with...

Why do my results not stay consistent?

I have the following stored procedure that I working on. I have noticed that every 5th or 6th time I refresh my results there are new values in there. Which considering that the data is in a static environment and no one is making any changes to the data at this time I really can't understand. Can someone please enlighten me as to why I ...

SQL select print out results of stored procedue

My businesses application supports only reporting with selected data from SQL server.In one business process I have very complicated stored procedure which using others stored procs and it was designed to print out results as log of job done. What I want to catch that print out and select it as varchar(max) so my app can handle that data...

Bypass last INNER JOIN in query

I have the following stored procedure which takes a user ID, a starting date, an end date, and a list of codes in a comma-delimited list, and it returns all activity records between those two dates which match one of the codes in the list. ALTER PROCEDURE [dbo].[ActivitiesSummary] @UserID varchar(30), @StartDate datetime, @EndDate dat...

postgres (8.3), useing query result in function

I am trying to create a function to populate 2 tables, the second query containing the new id from the first insert. an example of some of my tables: CREATE TABLE message ( message_id bigserial NOT NULL, member_id bigint NOT NULL, message character varying(8192) NOT NULL, ... ) CREATE TABLE feed_message ( feed_id bigint NOT ...

Debug stored procedure from Visual Studio 2005

Hello, i'm missing the "Step Into Stored Procedure" option when i rightclick a Stored Procedure in Server Explorer/Data Connections. This is neither a problem under Windows XP(development pc) nor with Windows Server 2003/64 bit(old productive Server). But under Windows Server 2008/64bit there is not an option to debug a stored procedure...

how can I use loop 'for' through a table in SQL to check if a column is 0?

how can I use loop 'for' through a table in SQL to check if a column is 0? I need to do like this in a stored procedure: for each record in tablex if table.column1=0 then insert into table1; Else insert into table2; End for; ...

How to read image from specific path in Sqlserver 2005 storeprocedure ?

I need to read the image from the specific path. I pass only path as parameter and that image will return by the procedures in image or byte format. ...

user default column value in INSERT stored procedure

From my ASP.NET application I am calling an INSERT stored procedure, there is a default value for one of the columns in the table that the INSERT procedure places the data into. How do I specify that I want the default value to be used instead? (Or do I have to specify the actual default value in my parameters) SITUATIONAL TABLE: Colum...

How to handle multiple ResultSets, each with multiple Rows? IDataReader.NextResult() ending Read()

How to handle multiple ResultSets, each with multiple Rows? The call to NextResult() breaks the while loop. Some of my SPs return multiple ResultSets. I'm handling these with NextResult() but when I do and my SP only has a single ResultSet, I see the while loop with Read() finishes leaving me with only the first Row. Without the call t...

Do stored procedures lock tables/rows?

Quite a simple question. In SQL 2008 if I have a stored procedure (see below) do I run the risk of a race condition between the first two statements or does the stored procedure put a lock on the things it touches like transactions do? ALTER PROCEDURE [dbo].[usp_SetAssignedTo] -- Add the parameters for the stored procedure here ...

UPDATE with a stored procedure on SQL Server 2005

Hello. I want to say UPDATE users SET field = my_sp() in SQL Server 2005. Apparently I can't do this and have to use some form of EXEC. Can anyone help me out and let me know how to do this? This should be some easy rep. ...

In which scenarios JPA becomes interesting/useful ?

I'm developing a JEE application (JSF + Richfaces + Oracle 10g), and i wanted to use JPA. But in the end, i didn't see any advantages of using it, because it's going to complexify my code. I found that calling my procedures (stored procedures in my orale DB) is better than using JPA (because i can, for example, change some lines in tho...

SQL server-declare local variable: "there is already an object named '' in the database"

hello, I wrote the following stored procedure, in which I use a local variable 'syncParam': declare @syncParam bit select isSync into syncParam from MyTable where id=@id if (@syncParam='True')... else ... return @syncParam When I executed this stored procedure at the first time it worked, but after that I get the following error:...

How to use Alias in Where clause?

I have this procedure: PROCEDURE P_LOAD_EXPIRED_ACCOUNT ( pDayDiff IN NUMBER, ExpiredCur OUT MEGAGREEN_CUR ) IS BEGIN OPEN ExpiredCur FOR SELECT ACCOUNT_NAME, SERVICE_TYPE, CASE WHEN SERVICE_TYPE = 1 THEN ADD_MONTHS(ACTIVATED_DATE,3) WHEN SERVICE_TYPE = 2 THEN ADD_MONTHS(ACTIVATED_DATE,6) WH...

Why can't use INSERT EXEC statement within a stored procedure called by another stored procedure?

Hi, First I try to explain the circumstances. I store the the filter expression in one column separated by line breaks. The base idea was this: SELECT 'SELECT ''' + REPLACE(topic_filter,CHAR(10),''' UNION ALL SELECT ''') + '''' FROM dbo.topic_filter T WHERE T.id = @id FOR XML PATH('') After this I simply execute this string to ...

Java: Read metadata from procedure

I am looking for a way to get metadata from an Oracle store procedure, such as input/output parameters and their types. I did try DESC but it is not working: stmt = conn.createStatement(); ResultSet rs1 = stmt.executeQuery("desc pack.procname"); while ( rs1.next() ) { System.out.println(rs1.getString(1)); } Any ideas on what approac...

MySql stored procedures, delete record logically or phisically depending on existing table references

Hi, I have to write a Stored Procedure to delete record from a table. I have a memory table "tableids" where I store all the ids to delete from another table, say "addresses". CREATE TABLE `tempids` ( `id` INT(11) NULL DEFAULT NULL ) COLLATE='latin1_swedish_ci' ENGINE=MEMORY ROW_FORMAT=DEFAULT I could do this: DELETE FROM addr...

How can data vary pending how I view them

I have an odd case where when I look at the data through my SQL scripts I have one value, but if I look at the data directly SELECT * FROM table I get another value. My first thought was parameter sniffing, but that didn't fix the issue. I'm not doing anything with the value at hand, except getting it with a stored procedure. Example o...

sql recursive function - to find managers

Lets say I have the following table User_ID Manager_ID --------------------- Linda Jacob Mark Linda Kevin Linda Steve Mark John Kevin Basically the requirement is to pull all the managers under the user_id you are searching for. So for instance if I send in 'Linda' then it should retur...