473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can I typecast like this while passing a comaseperated string?

63
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


-- =============================================
-- Author: Lokesh Rao V.L
-- Create date: 18 June 2007
-- Description: Adds, updates LogCompliance details.
-- =============================================
ALTER PROCEDURE [dbo].[logLogComplianceAddUpd]
@loginUserId Int,
@logId Int,
@complianceIds Varchar(4000),
@logComplianceAnswers Varchar(4000),
@createdByIp Varchar(50),
@errNumber Int Output

AS
BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SET CONTEXT_INFO @loginUserId;
SET @errNumber = 0

DELETE FROM LogCompliance WHERE LogId = @logId

DECLARE @answer Int, @pos1 Int, @complianceId Int, @pos2 Int
SET @pos1 = CHARINDEX(',' , @logComplianceAnswers , 1)
SET @pos2 = CHARINDEX(',' , @complianceIds , 1)

WHILE @pos1 > 0
BEGIN
SET @answer = Convert(Int,LTRIM(RTRIM(LEFT(@logComplianceAnswers , @pos1 - 1))))
SET @logComplianceAnswers = RIGHT(@logComplianceAnswers, LEN(@logComplianceAnswers) - @pos1)

SET @complianceId = Convert(Int,LTRIM(RTRIM(LEFT(@complianceIds, @pos2 - 1))))
SET @complianceIds = RIGHT(@complianceIds, LEN(@complianceIds) - @pos2)

SET @pos1 = CHARINDEX(',', @logComplianceAnswers, 1)
SET @pos2 = CHARINDEX(',', @complianceIds, 1)

INSERT INTO [LogCompliance]
(
[ComplianceId]
,[LogId]
,[ComplianceAnswer]
,[SortOrder]
,[CreatedDate]
,[LastModifiedDate]
,[CreatedById]
,[LastModifiedById]
,[CreatedByIp]
,[LastModifiedByIp]
,[RecordStatusId]
)
VALUES
(
@complianceId,
@logId,
@answer,
0,
getDate(),
getDate(),
@loginUserId,
@loginUserId,
@createdByIp,
@createdByIp,
1
)
END

END


Can I typecast like this and into database?
Mar 20 '08 #1
0 765

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lars Plessmann | last post by:
I have a problem with typecast methods. Here is a setter of an object: function setKind($kind) { if (is_int((int)$kind) and (strlen($kind)<=6)) { $this->kind = $kind; return true;
9
by: Venkat | last post by:
Hi All, I want to typecast int to std::string how can i do it. Here is the sample code. int NewList; //Fill the NewList with integers values. .......
1
by: masood.iqbal | last post by:
I have a few questions regarding overloaded typecast operators and copy constructors that I would like an answer for. Thanks in advance. Masood (1) In some examples that I have seen...
3
by: nandh_dp | last post by:
When the below program is compiled and executed, #include <stdio.h> #define MASK 0xFFFFFFULL main() { unsigned long long a; unsigned long b, c;
1
by: nsj | last post by:
How to typecast double into ascii or string? Please help me.
8
by: akolsen | last post by:
Hello there. This should be simple, but im having trouble anyway of getting it to work. I have a boxed object that i want to cast to its native type, but I would like to use reflection to do...
5
by: SunnyDrake | last post by:
HI! I wrting some program part of it is XML config parser which contains some commands(for flexibility of engenie). how do i more simple(if it possible not via System.Reflection or...
3
by: ryan.gilfether | last post by:
I have a problem that I have been fighting for a while and haven't found a good solution for. Forgive me, but my C++ is really rusty. I have a custom config file class: class ConfigFileValue...
1
by: niharnayak2003 | last post by:
Hi All, I am facing the problem in Typecast inside the Generic class. I need a function which will take two param 1:-Xpath 2:- XMLDOC and return me what i will need. here is the code for...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.