stored-procedures

SQL Server UPDATE from SELECT

Thanks in advance guys. Been searching quite a bit for this and I'm either searching badly, or there isn't much out there to explain it. In SQL server you can insert into a table using a select statement. INSERT INTO table(col,col2,col3) SELECT col,col2,col3 FROM other_table (in this case is a temp table) WHERE sql = 'cool' Would be...

MySQL fetch next cursor problem

Hello, I have a problem fetching values from a MySQL cursor. I create a temporary table which is a mere copy of another table (the original table has a variable name, that's passed as the procedure's parameter, and because MySQL doesn't support variable table names, I have to create a copy - can't use the original directly). The temp...

NHibernate + Mappings + Domain Model = Over-engineering?

Background I really like Fluent NHibernate - it's pretty great. I don't have to write those mundane CRUD-based SQL stored procedures and that's great (not that there's anything wrong with that)! I've gone down this path a bit on an application we're working on. And now I'm sitting with a couple dozen domain objects, each with a reposit...

can we return a null from stored procedure.

Can we return null value from stored procedure. i dont want to use collase or isnull. I want to capture NULL at the frontend. Is it possible ? Edit: I am using Sql Server 2005 eg. where i want to use CREATE PROCEDURE [Authentication].[spOnlineTest_CheckLogin] @UserName NVARCHAR(50) AS BEGIN TRY BEGIN TRAN ...

Using parameters in stored procedures where the column may be null

I want to (loosely) have a stored procedure like select * from table where col1 like @var the default value of @var is '%', so if I don't have a value for @var it should return every row. However, the problem is it doesn't return rows where col1 is null. How do I return all rows if @var = '%' and rows that are like @var if it does hav...

list stored procedures that can be called by each user

Hi, i need a query to list every stored procedure that can be executed by a specific user and This for each user of my mssql server 2005. output example: sa: sp_MSrepl_startup sp_MScleanupmergepublisher administrator: xp_foo sp_bar Any help will be appreciated phillipe ...

Can I copy :OLD and :NEW pseudo-records in/to an Oracle stored procedure?

I have an AFTER INSERT OR UPDATE OR DELETE trigger that I'm writing to store every record revision that occurs in a certain table, by copying the INSERT and UPDATE :NEW values into a mirror table, and for DELETE the :OLD values. I could un-clutter my code considerably by conditionally passing either the :NEW or :OLD record into a proced...

SQL Server to MySQL - but what to do with sprocs?

I have been tasked with converting a SQL Server database into a MySQL 5.* database. I feel well-read up about converting between datatypes. However, I read that MySQL does ANSI, not T-SQL, and doesn't support cursors. My question is, what am I supposed to do with all of my SQL Server functions and sprocs (some of which use cursors) ? ...

Stored procedure in SQL Server (order by desc)?

I have a stored procedure that will give the latest records i.e., order by added date this is my procedure.... select distinct top 5 videos.videoid,videos.videotitle,videos.videoname, convert(varchar,videos.posteddate,106) as posteddate,videos.approvedstatus, videos.videoimage,(ISNULL(videos.views,0.0)) as [views],videos.privac...

Reading Long Datatype and wirte it into an other Long Datatype

Hello I got a little Probelem: Im tring, with a SP, to read datas from Table SYSADM.aaTest and put it into MYSCHEMA.aaTest now my Problem is this Table has the Type Long in it. desc aaTest Name Null Typ ------------------------------ -------- ---------------- ID_TEST NOT NULL NUMBER...

Gridview and DbCommand

Hi,i have to fill a gridview with a dbcoommand. The code that i have wrote is: EntityConnection entityConnection = (EntityConnection)db.Connection; DbConnection storeConnection = entityConnection.StoreConnection; storeConnection.Open(); DbCommand command = storeConnection.CreateCommand(); command.CommandType = Comma...

How to schedule a stored procedure?

How do I schedule a stored procedure in Sql Server 2005 that it runs once at the start of every month (and on database startup)? ...

SQL Server - Finding the Highest Priority item using Bitwise operators

The Problem: I want to return all of the rows from the Primary Data table together with the Highest Priority Exception based on the currently assigned Priority in an Exception table. I have created a simplified example of my data set-up below (with creation scripts) so hopefully you can help with what should be a fairly quick T-SQL pr...

Problems calling MySQL stored procedures from C API

Hello, I have a problem calling a stored procedure on my MySQL server using the C API. I use mysql_query(&handle,"CALL myprocedure") but the function fails (returns 1) and error lookup gives the following message "Procedure myprocedure can't return a result set in the given context." I even tried to use mysql_real_query insted, but no ...

How do I get the list of all stored procedures and their parameters starting with a certain prefix?

Is there a way to query the database and retrieve a list of all stored procedures and their parameters? I am using SQL Server 2000. ...

default value, oracle sp call

I have an oralcle SP forced on me that will not accept an empty parameter in an update. So if I wanted to set a value back to the default of ('') it will not let me pass in the empty string. Is there a keyword you can use such as default, null, etc that oracle would interpret back to the default specified for a particular column? ...

sql server 2005 - previously quick executing stored proc run slowly until dropped and recreated

Hi, I've got a stored proc that after a period of weeks will start to run very slowly. It starts its life executing in a few seconds and ends up taking a couple of minutes to execute. We've found that dropping and recreating the procedure results in it executing in a few seconds again. The procedure itself contains a few inner joins an...

Stored procedure, activerecord, and alternatives?

In a PowerBuilder-based project, there are overs three hundred stored procedures on a Microsoft SQL Server. It's a client-server application which relies a lot on PB's DataWindow. Now, there is an feature request from the users which will most likely add several web-based screens to interface with the system. We are evaluating Rails (f...

Linq2SQL using Update StoredProcedure

We use queries generated by Linq for data retrieval but for INSERT and UPDATE we do not allow generated SQL, but restrict to the use of stored procedures. I connected the Update and the Insert behaviour in the DBML to the stored procedures. The procedures are called, the data gets inserted/updated = all if fine, except in the case of o...

SQL Sproc Parameters: Setting Default Date value

I am trying to create a Stored Procedure that will be used for a Report and I want the 2 date parameters to have a DEFAULT value of today's date and 1 month prior. Is the below the proper way to do this? I was reading elsewhere that I should use COALESCE...(SEE HERE)This is a touchy production system so I wanted to double check before ...