Home Posts Topics Members FAQ
Evgeny Gopengauz
For example, I have a table FORMULA_TABLE with the column FORMULA which
contains some function y=f(x) in its symbol description like '@X*2+1'
create table FORMULA_TABLE(
ID int,
FORMULA varchar(100)
)
This is a sample how I'm going to calculate the function f(x) by its
number @ID:
declare @FORMULA varchar(100)
select @FORMULA = FORMULA
from FORMULA_TABLE
where F.ID=@ID
set @FORMULA =
'declare @X int '
+' declare @Y int '
+' set @X='+convert(va rchar(10),x)
+' set @Y='+@FORMULA
exec(@FORMULA)
-- some manipulations with @Y expected to be there
How to retrieve back the value of @Y to the T-SQL context?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
Subscribe Reply
1 10113
Simon Hayes
"Evgeny Gopengauz" <ev***@ucs.ru > wrote in message
news:41******** **************@ news.newsgroups .ws...
For example, I have a table FORMULA_TABLE with the column FORMULA which
contains some function y=f(x) in its symbol description like '@X*2+1'create table FORMULA_TABLE(
ID int,
FORMULA varchar(100)
)This is a sample how I'm going to calculate the function f(x) by its
number @ID:declare @FORMULA varchar(100)
select @FORMULA = FORMULA
from FORMULA_TABLE
where F.ID=@ID
set @FORMULA =
'declare @X int '
+' declare @Y int '
+' set @X='+convert(va rchar(10),x)
+' set @Y='+@FORMULA
exec(@FORMULA)
-- some manipulations with @Y expected to be thereHow to retrieve back the value of @Y to the T-SQL context?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
You can use sp_executesql with an output parameter:
declare @FORMULA nvarchar(100)
declare @sql nvarchar(100)
declare @x int, @y int
set @FORMULA = '@X*2+1'
set @sql = 'select @y = ' + @formula
exec sp_executesql @sql, N'@x int, @y int OUTPUT', @x = 1, @y = @y OUTPUT
select @y
This assumes that all your formulae return an integer, of course. A more
general solution would be difficult, since you don't know in advance what
the data type of the return value will be, but in a limited case it should
work OK. If you have a small number of formulae, it might be worth
converting them to UDFs, although scalar UDFs perform poorly on large data
sets, so this might not be an option anyway.
See here for more details on output parameters:
http://support.microsoft.com/default...;EN-US;q262499
http://www.sommarskog.se/dynamic_sql.html#sp_executesql
Simon
Jul 20 '05 #2
This thread has been closed and replies have been disabled. Please start a new discussion.
Similar topics
5 8944 exec() gives only 127 back by: PeterF |last post by: Hi, I've got the following problem: exec() and shell_exec(), etc. don't give anything back, just the error code 127 (command not found?!) For example, the following script: <?php exec("cat ./test", $lines, $result); PHP |
2 1570 back again with the date question... by: mirza i |last post by: thanks for the previous replies. here is the new question (i'm absolutely sure that this should be VERY easy for a good js coder) ok: from asp i call: <img src="pics/cal.gif" onclick="show_calendar_det('document.invdetdet.dx1', Javascript |
56 5904 Access Back-End Over the Internet? by: Raphi |last post by: Hi, I've been using an Access application I wrote for an office with the front-end stored on all computers and the back-end on one of them serving as an Access file server. Now we're moving to a 2nd office 15 minutes down the road. Only one office will be open at a time, so theoretically it'd be possible to copy the back-end manually... Microsoft Access / VBA |
1028 flexible back-end data handling in .net + sql project by: athos |last post by: Hi guys, Got a problem now :( please help... now we got a project handling records saved in a table in a sql 2000(will upgraded to 2005 soon) server. every month around a million records will be inserted. now user raised a request, that is, once criterios are matched, the project should do some backend handle, for example, if .NET Framework |
4 9407 How to get a SP return value on another SP? by: Cylix |last post by: I have a SP, which will exec other SP depend on the input. the "other SP" need to return a integer back. How to do this? Thanks for give me a hand. Microsoft SQL Server |
5 2556 Assign repeated tasks back to the threadpool? by: =?Utf-8?B?RkxEYXZlTQ==?= |last post by: I'm developing an application that gets data from 100 sources (via telnet connections, but you can think stock quotes from a webservice if you like). I was planning on using the thread pool (25 at a time). I know I would start all 100 at once and as threads finish, a new thread would become available and the next one would start. However,... C# / C Sharp |
2 1787 Getting Return Value From Stored Proccedure (Part 2) by: Mick Walker |last post by: Public Sub CheckProduct(ByVal _ConnString As String, ByVal ProductList As List(Of Import_ImportLines.Lines)) Dim ReturnValue As Integer = 0 ' Our Return Value Dim conn As New SqlConnection Dim cmd As New SqlCommand conn.ConnectionString = _ConnString cmd.Connection = conn cmd.CommandType = Data.CommandType.StoredProcedure cmd.CommandText =... ASP.NET |
1782 how to use DynamicInvoke method to return a value by: flyingchen |last post by: using System; using System.Windows.Forms; using System.Threading; using System.ComponentModel; namespace ProgressControl.Core { public delegate object Execute(params object args); public class ProgressController ASP.NET |
8 14371 Stored procedure with ExecuteNonQuery not returning value by: roundcrisis |last post by: Hi all: I m trying to get the return value of a stored procedure with .... DbCommand command = connection.CreateCommand(); command.CommandText = "Exec some_SP"; command.CommandType = CommandType.StoredProcedure; int temp = command.Parameters.Add(new OdbcParameter("@ReturnValue", C# / C Sharp |
7410
What is ONU? by: marktang |last post by: ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main... General |
7351 Changing the language in Windows 10 by: Hystou |last post by: Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language... Windows Server |
7593
Problem With Comparison Operator <=> in G++ 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ... C / C++ |
7744
Maximizing Business Potential: The Nexus of Website Design and Digital Marketing 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that... Online Marketing |
1 5276
Access Europe - Using VBA to create a class based on a table - Wed 1 May by: isladogs |last post by: The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes... Microsoft Access / VBA |
4896 Couldnt get equations in html when convert word .docx file to html file in C#. by: conductexam |last post by: I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert... C# / C Sharp |
3392 Trying to create a lan-to-lan vpn between two differents networks by: TSSRALBI |last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in... Networking - Hardware / Configuration |
1 973
How to add payments to a PHP MySQL app. by: muto222 |last post by: How can i add a mobile payment intergratation into php mysql website. PHP |
639
Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy by: bsmnconsultancy |last post by: In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating... General |
By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.
To disable or enable advertisem*nts and analytics tracking please visit the page.