473,651 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Results from Functions


I've written a function to calculate a seriies of parameters based upon some
variables. I'd like to be able to return all the parameters to a query.
Now all the parameters are interrelated and cannot be calculated seperately.
I suppose the question is, can I return multiple results from a function to
a query? Or am I limited to duplicating the query multiple times and
returnig one parameter each time?

g

Nov 13 '05 #1
3 1807
"Gargamil" <wo****@tpgi.co m.au> wrote in message
news:cr******** **@otis.netspac e.net.au...

I've written a function to calculate a seriies of parameters based upon
some variables. I'd like to be able to return all the parameters to a
query. Now all the parameters are interrelated and cannot be calculated
seperately.
I suppose the question is, can I return multiple results from a function
to a query? Or am I limited to duplicating the query multiple times and
returnig one parameter each time?

g


Functions are normally used to return a single value of a particular type
(string, integer, boolean, etc) but you could write a function which returns
no value at all. However, this doesn't prevent you doing something like
passing 3 variables, changing their values and returning either true or
false to indicate whether the function changed them all as expected or not.
E.g.
Public Function GetMyValues(str FirstName As String, _
strLastName As String, _
dteDOB As Date) As Boolean
strFirstName = "Fred"
strLastName = "Bloggs"
dteDOB = DateSerial(1955 , 12, 25)

GetMyValues = True

End Function

But this might not be so helpful with a query. Instead, you could calculate
one column and then pass that calculated value to a function to calculate
the next column, if that's the sort of thing you need. However, although
queries are great for many things, there are times when it might be better
to write a routine which creates a brand new table showing you the results
you need - you read one or more values from a table and use them to create a
single row in the results table.
Perhaps post more specific details of the values you need calculated.

Nov 13 '05 #2
Hello, Eric!

Thanks for the response. I won't bore you with the details of the
calculated numbers. Suffice to say I need to calculate one to get the next
and then combine those to get the third, all the while other calculations
are feeding these results. I guess it's time to take a step back and try to
break this down a little more.
Anyway you've opened my eye. Many thanks

g

You wrote on Tue, 11 Jan 2005 00:19:09 +0000 (UTC):

ES> "Gargamil" <wo****@tpgi.co m.au> wrote in message
ES> news:cr******** **@otis.netspac e.net.au...
??>>
??>> I've written a function to calculate a seriies of parameters based
??>> upon some variables. I'd like to be able to return all the parameters
??>> to a query. Now all the parameters are interrelated and cannot be
??>> calculated seperately. I suppose the question is, can I return
??>> multiple results from a function to a query? Or am I limited to
??>> duplicating the query multiple times and returnig one parameter each
??>> time? g

ES> Functions are normally used to return a single value of a particular
ES> type (string, integer, boolean, etc) but you could write a function
ES> which returns no value at all. However, this doesn't prevent you doing
ES> something like passing 3 variables, changing their values and returning
ES> either true or false to indicate whether the function changed them all
ES> as expected or not. E.g.
ES> Public Function GetMyValues(str FirstName As String, _
ES> strLastName As String, _
ES> dteDOB As Date) As Boolean
ES> strFirstName = "Fred"
ES> strLastName = "Bloggs"
ES> dteDOB = DateSerial(1955 , 12, 25)

ES> GetMyValues = True

ES> End Function


Nov 13 '05 #3

Gargamil wrote:
Hello, Eric!

Thanks for the response. I won't bore you with the details of the
calculated numbers. Suffice to say I need to calculate one to get the next and then combine those to get the third, all the while other calculations are feeding these results. I guess it's time to take a step back and try to break this down a little more.
Anyway you've opened my eye. Many thanks

g


FWIW, I would recommend starting *small*. If what you're doing is
complex, you can have one function call other functions and pass
results around. At least then you won't drive yourself nuts trying to
debug the thing. I like to build and mark the new stuff each time I do
something, because then I can tell what's breaking my code. Then at
least I have a fighting chance of finding my errors. Especially
helpful if you are creating something very large.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3035
by: Karin Jensen | last post by:
Hi I am running a PHP program that connects to an Access 2000 database via ODBC: $results = odbc_exec($connection_id, $sql_select); Is it possible to sort the contents of $results? I wish to use a regex-based sort order that you can't do in Access 2000* SQL with "ORDER BY".
38
2756
by: Lasse Vågsæther Karlsen | last post by:
After working through a fair number of the challenges at www.mathschallenge.net, I noticed that some long-running functions can be helped *a lot* by caching their function results and retrieving from cache instead of calculating again. This means that often I can use a natural recursive implementation instead of unwinding the recursive calls to avoid big exponential running-times. Ok, so I thought, how about creating a decorator that...
3
1548
by: Eli Criffield | last post by:
I'm getting odd results from my fuction that takes variable aguments. What i want to do is take a printf like format and pass that to mysql_query then i do some processing of the results and return a pointer to an array of the results. Everything works if i guess at the length of the query and malloc that amount. The problem comes when i try to figure out the size of the varible arguments.
74
4547
by: aruna.mysore | last post by:
Hi all, I have a simple definitioin in a C file something like this. main() { char a; ....... int k; }
0
8361
marktang
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
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, 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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7299
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5615
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4144
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.