Call A Storedproc In Select From Block

Mar 31, 2006

Hi everyone,

I have a storedproc. This proc send back a value. how can i call this storedproc in select from block. Or what is your advise for other ways....

Select *

, (Exec MyStoredProc MyParam) as Field1

From Table1

View 1 Replies


ADVERTISEMENT

T-SQL (SS2K8) :: Why Block Scope Variables Exist Outside Of Block

Dec 3, 2014

I have the following stored procedure to test scope of variables

alter proc updatePrereq
@pcntr int,
@pmax int
as
begin

[Code] ....

In the above script @i is declare in the if block only when the @pcntr value is 1. Assume the above stored procedure is called 5 times from this script

declare @z int
set @z = 1
declare @max int
set @max = 5
while @z <= @max
begin
exec dbo.updatePrereq @z, @max
set @z = @z + 1
end
go

As i said earlier `@i` variable exists only when `@pcntr` is `1`. Therefore when i call the stored procedure for the second time and so forth the control cannot enter the if block therefore @i variable wouldn't even exist. But the script prints the value in `@i` in each iteration, How comes this is possible should it throw an error saying `@i` variable does not exist when `@pcntr` values is greater than `1`?

View 1 Replies View Related

How To Set User Who Can't Modify Any StoredProc And Data In Tables But Can Read Data In Tables And Any StoredProc ?

Jul 13, 2007

Please give me advise ครับ
 

View 1 Replies View Related

Wrapping A Dynamic Sql Call In A Select

Mar 13, 2008

I'm expecting to revamp some stored procs so that their selects are executed on a dynamic string that always returns the same columns but varies the sources.

I'm concerned that the bread and butter of products like RS and SSIS is the ability to predict what columns, and what column types to expect from a query, but that introducing dynamic sql will complicate using them.

I'm motivated not to use temp tables or table vars if possible. I'm also somewhat motivated to learn of a solution that works equally well in 2000 and 2005.

I've tried wrapping dynamic calls in a select as shown below but to no avail...


After€¦

declare @sqlString nvarchar(4000)
set @sqlString = 'select * from [' + @dbName + '].[dbo].[activity]'

I€™ve already tried things like€¦.
select a.* from exec sp_executesql @sqlString a

and

select * from exec (@sqlString)

View 8 Replies View Related

How Do I Call A Select Statement Properly When The Field Is A Yes/no?

Dec 4, 2006

Hello,
i am pretty new to asp. I am trying to do a select statement for sending an email to everyone who is not an admin. the code is below, i know it must be fairly simple, yet i do not know how to do it. With the code below, I select everyone. I want to know how to do it properly, similar to the second which does not work.
Dim cmd As New OleDbCommand("SELECT Username, Pass, Gender, FirstName, LastName, Email, NickName FROM tblUsers", conn)
DOES NOT WORK:
Dim cmd As New OleDbCommand("SELECT Username, Pass, Gender, FirstName, LastName, Email, NickName FROM tblUsers WHERE Admin = 'N'", conn)
Thanks in advance.

View 3 Replies View Related

Call A Stored Procedure From A SELECT Statement

Nov 28, 2005

Is there a way to call a stored procedure within a SELECT statement?Example;-----------SELECT FirstName,           LastName,           (EXEC UniqueID_KEYGEN @keyval output) AS UniqueIDINTO #tNewEmployeeFROM EmployeeTable-----------SELECT *FROM #tNewEmployeeThe return from the temp table would have a unique ID ready to insert into another table.  Our DBA has this stored procedure to create unique ID's and is to be used on all INSERTS.  I was used to having a Identity field do this for me, I don't know why we have to do it his way.  Except for the reason of sequence and easily get the next record.  But we don't use URL variables, only FORM or SESSION.Thanks for your help in advance.

View 2 Replies View Related

Call Stored Procedure Within SELECT Statement

Apr 17, 2004

Can this be done? I want to call a stored procedure from inside a select statement. Since you can nest select statements, I thought it might be possible but I have no idea how to do it.


USE NORTHWIND
GO

CREATE TABLE tbA (
Item int NOT NULL,
Value int NOT NULL
) ON [PRIMARY]

GO

INSERT INTO tbA (Item, Value)
SELECT 1, 10 UNION ALL
SELECT 2, 5 UNION ALL
SELECT 3, 2
GO

CREATE PROCEDURE usp_SquareIt

@iItem int

AS

declare @iValue int
SELECT @iValue = Value FROM tbA
SELECT @iValue * @iValue AS Result

GO

SELECT Item,
EXECUTE usp_SquareIt Item AS Squared ---- can this be done
FROM tbA
GO

DROP TABLE tbA
GO

DROP PROCEDURE usp_SquareIt
GO


Any thoughts?

Mike B

View 1 Replies View Related

Call A Stored Procedure In The Select Statement

Feb 21, 2007

Is it possible to call a stored procedure in a select statement?

For example:
SELECT Buyer, Country, (exec the sp_test*) as ItemList.....

*sp_test is a stored procedure with buyer and country as the input parameters and output a concatenated item numbers (example: F12345,A1023,C40165).

View 20 Replies View Related

Transact SQL :: Call Stored Procedure In Select Query?

Nov 9, 2015

I have a SELECT query that also needs to call a sproc with a column name passed in as a parameter.

Unfortunately I cannot use a TVF, as the sproc code references a TVF on a linked server.

What is the best option?

SELECT
u.UserID,
u.Username,
u.Address,
EXEC dbo.[GetResult] u.UserID AS 'Result'
FROM dbo.UserTests u

View 3 Replies View Related

SQL Server 2014 :: How To Call Dynamic Query Stored Procedure In Select Statement

Jul 23, 2014

I have created a stored procedure with dynamic query and using sp_executesql . stored procedure is work fine.

Now i want to call stored procedure in select statement because stored procedure return a single value.

I search on google and i find openrowset but this generate a meta data error

So how i can resolve it ???

View 7 Replies View Related

Storedproc (again Sorry)

Feb 4, 2007

I get a execption when i run my code i dont know how to debug sql statements so ya could any one give me adive heres the code  public static int CreateMember(string username, string aspApplicationName)
{
int returnvalue = 0;
DateTime dateCreated = DateTime.Now;

// All users are added to users role upon registration.
Roles.AddUserToRole(username, "Users");

String connectionString = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString;
SqlConnection conn = new SqlConnection(connectionString);
SqlCommand command = null;
try
{
conn.Open();
command = new SqlCommand("InsertMember", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@AspNetUsername", username));
command.Parameters.Add(new SqlParameter("@AspNetApplicationName", aspApplicationName));
command.Parameters.Add(new SqlParameter("@DateCreated", dateCreated));
SqlParameter sqlParam = command.Parameters.Add("@Id", SqlDbType.Int);
sqlParam.Direction = ParameterDirection.ReturnValue;
command.ExecuteNonQuery();
returnvalue = (int)command.Parameters["@id"].Value;
conn.Close();

}
catch (Exception ex)
{

}
finally
{
if (command != null)
command.Dispose();
if (conn != null)
conn.Dispose();
}
return returnvalue;
}  i get a exception at command.ExecuteNonQuery(); and if i dont do int returnvalue = 0; it says i cant use it cause it hasnt be initialized or something like that ALTER PROCEDURE [dbo].[InsertMember]    @AspNetUsername nvarchar(256),    @AspNetApplicationName nvarchar(256),    @DateCreated smalldatetime = getdateASDECLARE @Id int;SET NOCOUNT ON;INSERTINTO [Members] ([AspNetUsername], [AspNetApplicationName],[DateCreated]) VALUES (@AspNetUsername, @AspNetApplicationName,@DateCreated);SET @Id = @@IDENTITYSELECT  @Id  AS [Id] theres my stored proc any ideas?

View 5 Replies View Related

.net StoredProc

Nov 28, 2005

Hi,

View 7 Replies View Related

Insert Should Aquire Only Exclusive Rowlock. Why Does Insert Block Select With ( Updlock, Rowlock )?

Mar 12, 2007

Here is the situation i am stuck with, see the example first and below explained the problem:

-- 'SESSION A

create table foo (

id integer,

pid integer,

data varchar(10)

);

begin transaction

insert into foo values ( 1, 1, 'foo' )

insert into foo values ( 2, 1, 'bar' )

insert into foo values ( 3, 1, 'bozo' )

insert into foo values ( 4, 2, 'snafu' )

insert into foo values ( 5, 2, 'rimrom' )

insert into foo values ( 6, 2, 'blark' )

insert into foo values ( 7, 3, 'smeg' )

commit transaction

create index foo_id_idx on foo ( id )

create index foo_pid_idx on foo ( pid )

begin transaction

insert into foo values ( 9, 3, 'blamo' )

-- 'SESSION B

begin transaction

select id, data from foo with ( updlock, rowlock ) where id = 5;



-- Problem:

-- Uncommitted transaction in session A, with insert into table FOO, aquires lock on index foo_pid_idx which BLOCKS select with ( updlock, rowlock ) in session B.

-- Insert should aquire only exclusive rowlock. Why does insert block select with ( updlock, rowlock )?



Appreciate your help,

Rajesh.

View 5 Replies View Related

Return XML From SQL StoredProc

Apr 21, 2005

Hallo

I have a normal "Select * from Table" SP that have OUTPUT parameters as well.

Is it possible to obtain the result into a XML format and ALSO obtain the OUTPUT parameters in .Net1.1

Thank you

View 6 Replies View Related

Tool For Generating StoredProc

Jul 9, 2001

Hi,

I'm using SQL Server 2000 as our back end. I'm finding it bit difficult to write StoredProcs manually to be called from my front end. Is there any good Stored Proc generator tool available?

Thanks,
Harish

View 1 Replies View Related

Execute Xp_cmdshell And Other SA Storedproc

Mar 8, 2004

Hi all,

I have to execute stored procedures containing
xp_cmdshell and certain system storedprocedures in msdb and master
with a user who is not SA.
(i.e iam able to execute stored procedures when i log as sa,
but any other user cannot run them)

Pls tell how to do this, it is quite urgent.

View 1 Replies View Related

Storedproc For Wildcard Search

Mar 24, 2008

Hi someone please help me.

i have a serach page which have 4 textboxes.
passing this textboxes as parameters to storedproc iam searching the value.
filling atleast one textbox should fetch the value.

i have stored proc for searching it using normal column values but i want it do using wildcard search also.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



ALTER PROCEDURE [dbo].[search1]
(@val1 varchar(225),
@val2 varchar(50),
@val3 varchar(50),
@val4 varchar(50))
AS
BEGIN

DECLARE @MyTable table (CNo varchar(255))



INSERT @MyTable

Select CNo From customer where
((@val1 IS NULL) or (CNo = @val1)) AND
((@val2 IS NULL) or(LastName = @val2)) AND
((@val3 IS NULL) or(FirstName = @val3)) AND
((@val4 IS NULL) or(PhoneNumber = @val4))



--Now do your two selects

SELECT c.*
FROM customer c
INNER JOIN @MyTable T ON c.CNo = T.CNo
Select r.*
From refunds r
INNER JOIN @MyTable t ON r.CNo = t.CNo
END

I WANT THE SEARCH TO BE DONE FOR WILD CARD CHARACTERS ALSO.

if the user enters lastname s*

using same storedproc can i insert wildcard search.

how can i do that please some one help me.

thanks

renu

View 1 Replies View Related

Problem With Sql2005 Query/storedproc

Oct 2, 2006

I am working on the login portion of my app and am using my own setup for the moment so that I can learn more about how things work.  I have 1 user setup in the db and am using a stored procedure to do the checking for me, here is the stored procedure code:ALTER PROCEDURE dbo.MemberLogin(@MemberName nchar(20),@MemberPassword nchar(15),@BoolLogin bit OUTPUT)ASselect MemberPassword from members where membername = @MemberName and memberpassword = @MemberPassword if @@Rowcount = 0beginselect BoolLogin = 0returnendselect BoolLogin=1/* SET NOCOUNT ON */ RETURNWhen I run my app, I continue to get login failed but no error messages.  Can anybody help?  Here is my vb code:Dim MemberName As StringDim MemberPassword As StringDim BoolLogin As BooleanDim DBConnection As New Data.SqlClient.SqlConnection(MyCONNECTIONSTRING)Dim SelectMembers As New Data.SqlClient.SqlCommand("MemberLogin", DBConnection)SelectMembers.CommandType = Data.CommandType.StoredProcedureMemberName = txtLogin.TextMemberPassword = txtPassword.TextDim SelectMembersParameter As Data.SqlClient.SqlParameter = SelectMembers.CreateParameter'NameSelectMembersParameter.ParameterName = "@MemberName"SelectMembersParameter.Value = MemberNameSelectMembers.Parameters.Add(SelectMembersParameter)'PasswordDim SelectPasswordParameter As Data.SqlClient.SqlParameter = SelectMembers.CreateParameterSelectPasswordParameter.ParameterName = "@MemberPassword"SelectPasswordParameter.Value = MemberPasswordSelectMembers.Parameters.Add(SelectPasswordParameter)Dim SelectReturnParameter As Data.SqlClient.SqlParameter = SelectMembers.CreateParameterSelectReturnParameter.ParameterName = "@BoolLogin"SelectReturnParameter.Value = BoolLoginSelectReturnParameter.Direction = Data.ParameterDirection.OutputSelectMembers.Parameters.Add(SelectReturnParameter)If BoolLogin = False ThenMsgBox("Login Failed")ElseIf BoolLogin = True ThenMsgBox("Login Successful")End IfEnd SubThank you!!!

View 3 Replies View Related

StoredProc Insert Into Composite Key Table

Dec 23, 2005

I have three tables that are important here, a 'Plant' table a 'Spindle' table and a 'PlantSpindle' table. The 'PlantSpindle' is comprised of a PlantID and a SpindleID acting as the Primary Key for the table with no other fields.

I have an aspx page that captures the appropriate data to create an entry in the Spindle table. Depending on the user, I will know which plantID they are associated with via a querystring. In my storedproc I insert the data from the webform into the Spindle table but get stuck when I try to also insert the record into the PlantSpindle table with the PlantID I have retrieved via the querystring and the SpindleID of the spindle record the user just created. Basically, I am having trouble retrieving that SpindleID.

Here is what I have in my storedProc (truncated for brevity).

CREATE PROCEDURE [dbo].[InsertSpindle]
@plantID int,
@spindleID int,
@plantHWG varchar(50),
@spindleNumber varchar(50),
@spindleDateInstalled varchar(50),
@spindleDateRemoved varchar(50),
@spindleDurationMonths float(8),
@spindleBearingDesignNumber int,
@spindleArbor varchar(50),
@spindleFrontSealDesign varchar(50),
@spindleFrontBearing varchar(50),
@spindleRearBearing varchar(50),
@spindleRearSealDesign varchar(50),
@spindleNotes varchar(160)

AS
SET NOCOUNT ON
INSERT INTO Spindle
(plantHWG, spindleNumber, spindleDateInstalled, spindleDateRemoved, spindleDurationMonths,
spindleBearingDesignNumber, spindleArbor, spindleFrontSealDesign, spindleFrontBearing,
spindleRearBearing, spindleRearSealDesign, spindleNotes)
VALUES
(@plantHWG, @spindleNumber, @spindleDateInstalled, @spindleDateRemoved, @spindleDurationMonths,
@spindleBearingDesignNumber, @spindleArbor, @spindleFrontSealDesign, @spindleFrontBearing,
@spindleRearBearing, @spindleRearSealDesign, @spindleNotes)

SET @spindleID = (SELECT @@Identity
FROM Spindle)

INSERT INTO PlantSpindle
(plantID, SpindleID)

VALUES
(@plantID, @SpindleID)

I have guessed at a few different solutions but still come up with Procedure 'InsertSpindle' expects parameter '@spindleID', which was not supplied when I execute the procedure.

Any help would be appreciated! thanks!

View 8 Replies View Related

Aaargh! Storedproc Vs SQL In Gridview Update

Jan 26, 2006

When I attempt to update using a stored procedure I get the error 'Incorrect syntax near sp_upd_Track_1'. The stored procedure looks like the following when modified in SQLServer:
ALTER PROCEDURE [dbo].[sp_upd_CDTrack_1]
(@CDTrackName nvarchar(50),
@CDArtistKey smallint,
@CDTitleKey smallint,
@CDTrackKey smallint)
AS
BEGIN

SET NOCOUNT ON;
UPDATE [Demo1].[dbo].[CDTrack]
SET [CDTrack].[CDTrackName] = @CDTrackName
WHERE [CDTrack].[CDArtistKey] = @CDArtistKey
AND [CDTrack].[CDTitleKey] = @CDTitleKey
AND [CDTrack].[CDTrackKey] = @CDTrackKey
END
But when I use the following SQL coded in the gridview updatecommand it works:
        "UPDATE [Demo1].[dbo].[CDTrack]
   SET [CDTrack].[CDTrackName] = @CDTrackName
 WHERE [CDTrack].[CDArtistKey] = @CDArtistKey
   AND [CDTrack].[CDTitleKey]  = @CDTitleKey
   AND [CDTrack].[CDTrackKey]  = @CDTrackKey"
Whats the difference? The storedproc executes ok in sql server and I guess that as the SQL version works all of my databinds are correct. Any ideas, thanks, James.
 

View 2 Replies View Related

How To Get A Recordset In ASP From StoredProc Using Temp Tables ?

Mar 2, 2000

Hi!

The problem that I'm dealing with is that I can't get recordset from SP, where I first create a temporary table, then fill this table and return recordset from this temporary table. My StoredProcedure looks like:

CREATE PROCEDURE MySP
AS
CREATE TABLE #TABLE_TEMP ([BLA] [char] (50) NOT NULL)
INSERT INTO #TABLE_TEMP SELECT bla FROM ……
SELECT * FROM #TABLE_TEMP


When I call this SP from my ASP page, the recordset is CLOSED (!!!!) after I open it using the below statements:

Set Conn = Server.CreateObject("ADODB.Connection")
Baza.CursorLocation = 3
Baza.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=IGOR;Data Source=POP"


Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "MySP", Conn, , ,adCmdStoredProc

if rs.State = adStateClosed then
response.Write "RecordSet is closed !!!! " ‘I ALLWAY GET THIS !!!!
else
if not(rs.EOF) then
rs.MoveFirst
while not(rs.EOF)
Response.Write rs ("BLA") & " 1 <br>"
rs.MoveNext
wend
end if

end if

Conn.Close


Do you have any idea how to keep this recordset from closing?
Thanks Igor

View 2 Replies View Related

Oracle StoredProc/Job Running At SQL Server?

Feb 5, 2003

Hi,
Is it possible Oracle Stored Proc or Jobs able to schedule in sql job?.
Thanks,
Ravi

View 3 Replies View Related

Testing StoredProc With GUID Parameter

Apr 11, 2002

I am working revising a number of stored procs on a system which has suffered some schema changes.

Sometimes I can test my SP code passing in a guid without a problem. Example below:

Test Command:

EXEC usp_Unit_INSERT
'{74A1BABA-0B76-4436-B6AA-01716B686044}', --unitguid
'36', --91', --UnitNumber (varchar)
10, -- xxHospitalNumber
'testUnknown' --UnitName

Above works fine.

I am testing another similar stored proc and am getting this error:

Server: Msg 8152, Level 16, State 9, Procedure usp_Patient_Info_INSERT, Line 24
String or binary data would be truncated.
The statement has been terminated.

(Line 24 performs an insert to a GUID)

Pertient code portions below.
Can anybody shed any light. I am essentially doing nearly identical things to another Stored Proc which works just fine.

Code below fails with above error, but is virtually identical in how it treats all GUID fields to another which does work fine.

-------------------------------------------------
CREATE PROCEDURE [usp_Patient_Info_INSERT]
@PatientGUID varchar(40),--uniqueidentifier,
@PersonGUIDvarchar(40),--uniqueidentifier ,
@CaseNumberdecimal(10,0),
<< and so forth >>

AS
IF @PatientGUID Is Null
SET @PatientGUID =cast( (newid()) as varchar(40))

INSERT INTO [Patient_Info] (
PatientGUID,
PersonGUID,
CaseNumber,
<< and so forth >>

Values (
cast( @PatientGUID as uniqueidentifier),
cast( @PersonGUID as uniqueidentifier),
@CaseNumber,

<< and so forth >>

View 1 Replies View Related

E-Mail User When StoredProc Fails

Jun 8, 2004

Hi,

I want to e-mail a user when a Stored Proc fails, what is the best way to do this? I was going to create a DTS package or is this too complicated?

Also, the Stored Proc inserts data from one table to another, I would like to use Transactions so that if this fails it rolls back to where it was, I'm not sure of the best way to go about this. Could anyone possibly point me in the right direction? Here's a copy of some of the stored procedure to give an idea of what I am doing:

-- insert data into proper tables with extract date added
INSERT INTO tbl_Surgery
SELECT
SurgeryKey,
GETDATE(),
ClinicianCode,
StartTime,
SessionGroup,
[Description],
SurgeryName,
Deleted,
PremisesKey,
@practiceCode--SUBSTRING(SurgeryKey,PATINDEX('%.%',SurgeryKey)+1, 5)
FROM tbl_SurgeryIn

INSERT INTO tbl_SurgerySlot
SELECT
SurgerySlotKey,
GETDATE(),
SurgeryKey,
Length,
Deleted,
StartTime,
RestrictionDays,
Label,
IsRestricted,
@practiceCode
FROM tbl_SurgerySlotIn

INSERT INTO tbl_Appointment
SELECT
AppointmentKey,
GETDATE(),
SurgerySlotKey,
PatientKey,
Cancelled,
Continuation,
Deleted,
Reason,
DateMade
FROM tbl_AppointmentIn

-- empty input tables
DELETE FROM tbl_SurgeryIn
DELETE FROM tbl_SurgerySlotIn
DELETE FROM tbl_AppointmentIn

Any help would me very much appreciated,

Thanks

View 3 Replies View Related

Storedproc For Parent Child Gridview

Mar 19, 2008

Hi

I have a search page which contains 4 fields.Giving input to anyone of the field should display the result in
Parent Gridview.Parent Gridview has button in it .when i click on the button child Gridview should display related
refund details of customer in parent Gridview.

let us think i have two tables like Customer and refunddetails.

Parent Gridview should display Customer details,Child should display corresponding customers refund details.

I need two storedprocs for binding to both Gridviews.

i have first stored proc for Gridview1


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER PROCEDURE [dbo].[MyProc]
(@val1 varchar(255),
@val2 varchar(50),
@val3 varchar(50),
@val4 varchar(50))
--@out smallint OUTPUT
AS
select * from customer where
((@val1 IS NULL) or (name = @val1)) AND
((@val2 IS NULL) or(ssn = @val2)) AND
((@val3 IS NULL) or(accountnumber = @val3)) AND
((@val4 IS NULL) or(phonenumber = @val4))


now i need to capture the @val1 from storedproc1 and using that value retrieve the remaining values in refund table.
name is common in both the tables.

i need this because user can search the value using ssn or accountnumber or phonenumber or name.it is not required that user serches using name.Name textbox can be null.

so please someone help me.

View 3 Replies View Related

Bind Message Of Storedproc To Lable Control

Mar 23, 2008

 Hi can anyone tell meHow to bind messages in storedproc to lable control in the front end.I have a stored proc which updates the data table.in certain condition update should not take place and a message should be generated that update did not take place.Can anyone tell me how that message can be shown in front endmy taught was to bind it using lable control. But how the messages can come from storedproc to front endcan we do it using dataset binding.Is there any other way please lemme know immediately .Thankyousiri 

View 4 Replies View Related

StoredProc For Checking For Duplicates And Then Updating The Data.

Mar 22, 2008

Hi

I have a question i hope someone here will solve my problem.

I need a storedproc for checking the duplicates before updating the data.

here i need to pass four parameters to storedprocedure which must be updated with existing row.

but before updating the values. Storedproc should check for 2 colum values in all rows.

if same combination of colum values is present in any other row then the present rows which we tring to update should not be

updated. Can anyone help me with this.

Thankyou verymuch.

View 8 Replies View Related

I Just Want One Entry For Each Call, With SLA Status 'Breach' If Any Of The Stages For The Call Were Out Of SLA.

Mar 19, 2008

Hi,

I am producing a php report using SQL queries to show the SLA status of our calls. Each call has response, fix & completion targets. If any of these targets are breached, the whole SLA status is set as 'Breach'.

The results table should look like the one below:





CallRef.

Description

Severity



ProblemRef

Logged
Date

Call
Status

SLA Status



C0001

Approval for PO€™s not received

2



DGE0014

05-01-06 14:48

Resolved

Breach


C0002

PO€™s not published

2



DGE0014

06-01-06 10:21

Resolved

OK


C0003

Approval for PO€™s not received from Siebel.

2



n/a

05-01-06 14:48

Investigating

OK



















Whereas I can pick the results for the first 6 columns from my Select query, the 'SLA Status' column requires the following calculation:

if (due_date < completed_date)
{ sla_status = 'OK';
}
else sla_status = 'Breach';

The Select statement in my query is looking like this...

Select Distinct CallRef, Description, Severity, ProblemRef, Logdate, Status, Due_date, Completed_date;

The problem is that my query is returning multiple entries for each stage of the call (see below), whereas I just want one entry for each call, with SLA status 'Breach' if any of the stages for the call were out of SLA.






CallRef.

Description

Severity



ProblemRef

Logged
Date

Call
Status

SLA Status



C0001

Approval for PO€™s not received

2



DGE0014

05-01-06 14:48

Resolved

Breach


C0001

Approval for PO€™s not received

2



DGE0014

05-01-06 14:48

Resolved

OK


C0001

Approval for PO€™s not received

2



DGE0014

05-01-06 14:48

Resolved

Breach



















Any help will be much much appreciated, this issue has been bothering me for some time now!!!




View 7 Replies View Related

Using StoredProc With Multiple Result(or Datatable) In Server Reports

Sep 17, 2007

Hi guys,

I've been doing some LOCAL reports on my current application until recently there's has been a case that I really need to do SERVER reports.

Usually when I design my local reports, I create a XSD file, so I usually have one dataset with multiple tables in it. I just pass the dataset to report with a single procedure call that returns multiple result sets or data table.

From what I understood server reports are binded to database objects only, like stored procedures. Now I used the same stored procedure that I used in my local report to my server report. But the thing is only the first result set in the stored procedure is recognized. Are there anyway that I can bind the server report to a single stored procedure that return multiple result sets?

Thanks.

View 2 Replies View Related

How To Conditionally Or Programmatically Run A Stored Procedure With Command Type Set To Storedproc?

May 21, 2008

I'm using SQL RS 2005 and have a report where we want the report to run a different stored procedure depending on if a condition is true. I've set my 'command type' to stored proc and can type in the name of a stored procedure. If I type in just one stored procedure's name, it runs fine. But if I try to use a =IIF(check condition, if true run stored proc 1, if false run storedproc 2) then the exclamation (run) button is greyed out. Does anyone know how I can do this? Thanks.

View 3 Replies View Related

Sniffing StoredProc Input Parameters For General Error Handling

Dec 10, 2007

Hi,

id beg for a hint if our idea of a general dynamic CATCH handler for SPs is possible somehow. We search for a way to dynamically figure out which input parameters where set to which value to be used in a catch block within a SP, so that in an error case we could buld a logging statement that nicely creates a sql statement that executes the SP in the same way it was called in the error case. Problem is that we currently cant do that dynamically.

What we currently do is that after a SP is finished, a piece of C# code scans the SP and adds a general TRY/CATCH bloack around it. This script scans the currently defined input parameters of the SP and generates the logging statement accordingly. This works fine, but the problem is that if the SP is altered the general TRY/CATCH block has to be rebuildt as well, which could lead to inconstencies if not done carefully all the time. As well, if anyone modifies an input param somewhere in the SP we wouldnt get the original value, so to get it right we would have to scan the code and if a input param gets altered within the SP we would have to save it at the very beginning.

So the nicer solution would be if we could sniff the input param values dynamically on run time somehow, but i havent found a hint to do the trick.....

Any tipps would be appreciated...

cheers,
Stefan

View 1 Replies View Related

Pl/Sql Block?

Apr 8, 2008

I've written a couple blocks but I have no idea when it comes to this one.
Create a PL/SQL block to retrieve the last name and department ID if each employee from the EMPLOYEES table
for those employees whose EMPLOYEE_ID is less than 114. From the values retreived from the employees table, populate two PL/SQL tables,
one to store the records of the employee last names and the other to store the records of their department IDs.
Using a loop, retreive the employee name information and salary infromation from the PL/SQL tables and doisplay it in the window,
using DBMS_OUTPUT.PUT_LINE. Display these details for the first 15 employees in the PL/SQL tables.
Any help helps

View 1 Replies View Related

AES (128 Bit Block) : Can I Use It?

May 18, 2006

If I've got a 64-bit OS such as Windows XP Professional x64 Edition running and I have the SQL Server 2005 Express Edition, is AES permittable or does TRIPLEDES still need to be used?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved