473,387 Members | 1,515 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,387 software developers and data experts.

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 1784
"Gargamil" <wo****@tpgi.com.au> wrote in message
news:cr**********@otis.netspace.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(strFirstName 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.com.au> wrote in message
ES> news:cr**********@otis.netspace.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(strFirstName 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
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...
38
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...
3
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...
74
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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,...

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.