473,473 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

calling functions which are stored as values in a table

27 New Member
hi... i have this problem... consider the following code... create or replace function sam(in j int) returns int
as
$$
declare
i int;
begin
i := 4;
i= i*j;
return i;
end;
$$
language plpgsql;

create table sam1
(
i varchar
)
insert into sam1 values('sam(j)');


how can i call the function sam which is in the table sam1.. please help
Jul 14 '08 #1
3 1937
rski
700 Recognized Expert Contributor
you can create a plpgsql function
Expand|Select|Wrap|Line Numbers
  1. create or replace function execute2(varchar) returns integer as $$
  2. declare
  3. i integer;
  4. begin
  5.         execute $1 into i;
  6.         return i;
  7. end;
  8. $$ language 'plpgsql';
  9.  
and use it
Expand|Select|Wrap|Line Numbers
  1. select execute2('select '||i) from sam1;
  2.  
Jul 14 '08 #2
ravysters
27 New Member
i am still getting this error...

column "j" does not exist
LINE 1: select sam(j)
Jul 14 '08 #3
rski
700 Recognized Expert Contributor
i am still getting this error...

column "j" does not exist
LINE 1: select sam(j)
you wrote
Expand|Select|Wrap|Line Numbers
  1. create table sam1
  2. (
  3. i varchar
  4. )
  5.  
you should use 'i' not 'j'.
Jul 14 '08 #4

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

Similar topics

2
by: June Moore | last post by:
Hi all, I have a stored procedure that return a resultset e.g. stored proc: get_employee_details select emp_id, emp_name, emp_salary, emp_position from empoloyee I would like to write...
7
by: BlueDragon | last post by:
The place where I work is moving to MS SQL Server from Lotus Notes. I have done a lot of coding in Lotus Notes, and have, I suppose, intermediate skills in basic SQL -- queries, insert, updates,...
7
by: Norbert Munkel | last post by:
Hi, If I try the new table functions get_dbm_cfg or get_db_cfg on a 8.2 (upgraded from 8.1.6) I always get the following Error: DB21034E The command was processed as an SQL statement because...
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....
5
by: Zlatko Matić | last post by:
Hello. How can I call some functions on MSDE when working in .mdb ? Especially in-line functions which are similar to stored procedures. How can I use MSDE in-line functions as recordsource for...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
2
by: Roger | last post by:
I put this in the microsoft.public.dotnet.langueages.vb.data newsgroup, but noticed there aren't alot of people there frequently like this newsgroup. So I thought I would try here. I get an...
15
by: Jaraba | last post by:
I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am...
5
by: wpellett | last post by:
I can not get the SQL compiler to rewrite my SQL UPDATE statement to include columns being SET in a Stored Procedure being called from a BEFORE UPDATE trigger. Example: create table...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
1
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...
0
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...
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,...
1
isladogs
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.