473,396 Members | 1,814 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.

basics on User Defined Functions

Is this the correct way to return values in a record from a UDF in 7.4.+ ?

Is it ok to modify the arguments as in 'arg_int'?

-- return type should be RECORD
--
CREATE OR REPLACE FUNCTION test_function( int )
RETURNS RECORD AS '
DECLARE

arg_int ALIAS FOR $1;

var_record_out record;
var_message_out text;

BEGIN

var_message_out := ''This was successful'';
arg_int := rg_int * 3;

SELECT INTO var_record_out
:arg_int AS intX3,
:var_message_out AS message;
RETURN var_record_out;
END;
' LANGUAGE 'plpgsql';

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #1
1 1040
Dennis Gearon wrote:
Is this the correct way to return values in a record from a UDF in 7.4.+ ?

Is it ok to modify the arguments as in 'arg_int'?

-- return type should be RECORD
--
CREATE OR REPLACE FUNCTION test_function( int )
RETURNS RECORD AS ' DECLARE

arg_int ALIAS FOR $1;

var_record_out record;
var_message_out text;

BEGIN

var_message_out := ''This was successful'';
arg_int := rg_int * 3;

SELECT INTO var_record_out :arg_int AS intX3,
:var_message_out AS message;
RETURN var_record_out;
END;
' LANGUAGE 'plpgsql';


Did you execute it ?

rg_int is not declared, may be is a typo for arg_int; however
you can not modify the argument function.

Is it an homework ?

Regards
Gaetano Mendola

Nov 23 '05 #2

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

Similar topics

8
by: markus | last post by:
This string does not work in php: $sql="UPDATE mytable SET myfield=myuserfunction(myfield)" What I want is my function to evaluate each field and put the new value in the field. For...
0
by: Mike Chirico | last post by:
With mysql-4.1.1-alpha, using any User Defined Function ( UDF) at the query execution stage, on Linux 2.6, gave me the following error: "ERROR 2013 (HY000): Lost connection to MySQL server...
5
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values....
2
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another,...
5
by: Simon Harris | last post by:
Hi All, Being a classic ASP programmer, I'm trying to get to grips with OOP, specifically using classes. I have setup my class with various properties, so far so good. What I dont quite get...
3
by: chreo | last post by:
I have user-defined function in MSSQL which returns Table (with 10 columns) (sorry for Polish names) CREATE FUNCTION PACZKI_Z_AKCJI (@AKCJA_ID int) RETURNS TABLE RETURN SELECT TOP 100...
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
14
by: chitu | last post by:
Hi pals, Hope u all of r intersted in C programming.Let start from d basics.
3
by: Lauren Quantrell | last post by:
I use the code below to generate a text file containing every stored procedure and view in my SQL Server backend database, but I can't figure out how to generate text of the User Defined Functions....
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...
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.