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

Can I RETURN SET OF typeX or typeY in a function depending of a parameter ?

1
That I want to ask is if I can return type A or B in the function depending of a parameter. For example



CREATE or replace FUNCTION public.getDataFromSearch(
searchString VARCHAR,
typeOperation INTEGER)
RETURNS SETOF typeA OR typeB AS ...

If typeOperation is 'A' can I return a query with the structure or typeA and if is 'B' the second type ?
Oct 23 '18 #1
1 1839
Use Record as function output type


FUNCTION public.getDataFromSearch(
searchString VARCHAR,
typeOperation INTEGER)
RETURNS SETOF record


If you call the function, you know which type will return

Select * from FUNCTION public.getDataFromSearch('text',1) as (RETURN_field bigint);
Select * from FUNCTION public.getDataFromSearch('text',2) as (RETURN_field varchar);
Dec 27 '18 #2

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

Similar topics

14
by: deanbrown3d | last post by:
Hi there! Suppose I have a function void ShowMessage(string s); (that has a void return type.) In my other function F, also with a void return type, can I do this?
2
by: David Rose | last post by:
I have a DLL (not .NET) that takes a function pointer argument and calls that function with an integer argument. The DLL is being called from C#. So far, it is partially working, but the...
2
by: kathy | last post by:
how to return array from function?
4
by: msolem | last post by:
I have some code where there are a set of functions that return pointers to each other. I'm having a bit of a hard time figuring out the correct type to use to do that. The code below works but...
2
by: Amadeus W. M. | last post by:
I have a bunch of templated functions: template <class Type_t> double f2(Type_t x) { return 2*x; } template <class Type_t> double f3(Type_t x) { return 3*x; }
6
by: many_years_after | last post by:
Hi, cppers: I am studying cpp recently. As is said, member funciton can be as one parameter of stl algorithm. BUT when I pass member function whose parameter is instance of the class, it doesn't...
12
by: aaragon | last post by:
I have this scenario: several arrays for which I have their fixed values at compilation time. Now, at runtime I need to access a specific array depending on an integer but I want to avoid if and...
2
by: Franck | last post by:
I am looking for a way to pass a function as parameter, NOT A DELEGATE. what i am trying to do is a worker process as for example of what i want to do : public static void...
12
by: hectorchu | last post by:
Why doesn't my compiler (g++) flag something like this as an error: int main() { } ?
1
by: siva125 | last post by:
function populatedropdown(dayfield, monthfield, yearfield) { var today=new Date() var dayfield=document.getElementById(dayfield) var monthfield=document.getElementById(monthfield) var...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.