Reputation:
I am new with plpgsql. I create new function
CREATE OR REPLACE FUNCTION createObj(number integer)
RETURNS INTEGER AS
$$
BEGIN
END;
$$
I have problem that if I want to make query in the body of the function and use in the query the the number variable while in the table their is a number the boolean is always true.
something like:
Select * from objects O, where O.number=number...
so number is not the number of the function but the filed in the table. Their is a way to implement this and dont change the variable name?
Upvotes: 0
Views: 1259
Reputation: 1269503
Define your parameters with a prefix to distinguish them from columns:
CREATE OR REPLACE FUNCTION createObj(in_number integer)
RETURNS INTEGER AS
$$
BEGIN
Select * from
objects O
where O.number = in_number...
END;
$$
Upvotes: 1