Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Function syntax

Status
Not open for further replies.

newbiepg

Programmer
Nov 6, 2002
181
IN
I am having a problem declaring a char variable in a function. I am getting a syntax error near ' where I declare cat_num_pass.
This is the function

create function get_scripts3(int4) returns int4 as'

DECLARE

num_scripts alias for $1;

cat_id int4;

cat_num_pass char ''T''

BEGIN

select into cat_id count(*) from d_articles where cat_id = num_scripts and app_flg = cat_num_pass;

return cat_id;

END;

'language 'plpgsql;


I am using postgresql 7.2.2
Secondly I need to get a sample function that can return a table
Thanks for the help
 
Hi newbiepg,

You might try:

DECLARE

num_scripts alias for $1;

cat_id int4;

cat_num_pass char(1);

BEGIN

select into cat_id count(*) from d_articles where cat_id = num_scripts and app_flg = cat_num_pass;

return cat_id;

END;

'language 'plpgsql;

If that doesn't work, you might take a look at the following link. There are 16 example function under the "string manipulation function" category that should give you a goood idea of how to declare and work with strings.


LelandJ
Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top