Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7788681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:04:13+00:00 2026-06-01T21:04:13+00:00

CREATE OR REPLACE FUNCTION addUploader(INTEGER, TEXT, TEXT) RETURNS TEXT AS $$ DECLARE u_id ALIAS

  • 0
CREATE OR REPLACE FUNCTION addUploader(INTEGER, TEXT, TEXT) RETURNS TEXT AS $$

DECLARE

  u_id ALIAS FOR $1 ;
  username ALIAS FOR $2;
  email ALIAS FOR $3; 

BEGIN 

  IF email NOT LIKE '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$' THEN

    RAISE EXCEPTION 'Wrong E-mail format %', email
        USING HINT = 'Please check your E-mail format.';

  END IF ; 

  INSERT INTO uploader VALUES(u_id,username,email);

  IF NOT FOUND THEN
    RETURN 'Error';
  END IF;
  RETURN 'Successfully added' ; 

EXCEPTION WHEN unique_violation THEN
  RAISE NOTICE 'This ID already exists. Specify another one.' ; 
  RETURN 'Error' ; 

END ; $$ LANGUAGE 'plpgsql' ; 

SELECT addUploader(25,'test','steven@gmail.com');

This regex does not accept a correct email address. It should accept steven@gmail.com.It is also rejecting any other string.

stevengmailcom – rejected

Everything is being rejected.

What am i doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:04:13+00:00Added an answer on June 1, 2026 at 9:04 pm

    You don’t use LIKE with regexes in PostgreSQL, you use the ~, ~*, !~, and !~* operators:

    ~
    Matches regular expression, case sensitive

    ~*
    Matches regular expression, case insensitive

    !~
    Does not match regular expression, case sensitive

    !~*
    Does not match regular expression, case insensitive

    So your test should look more like this:

    IF email !~ '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$' THEN
    

    You also might want to hunt down a better regex for email addresses, “a+b@c.com” is a valid email address but your regex doesn’t like it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Something like this: CREATE OR REPLACE FUNCTION get(param_id integer) RETURNS integer AS $BODY$ BEGIN
When i run this function: CREATE OR REPLACE FUNCTION insert_styles(raw_styles text) RETURNS integer AS
I have a PL/pgsql function like so CREATE OR REPLACE FUNCTION foo(colname TEXT, col
I'm not sure how to achieve something like the following: CREATE OR REPLACE FUNCTION
CREATE OR REPLACE FUNCTION _chkLogin(userid varchar, pwd varchar) RETURNS BOOLEAN AS $BODY$ DECLARE passed
CREATE OR REPLACE FUNCTION somefunction(ret refcursor, _id oid, _offset integer, _limit integer) RETURNS refcursor
CREATE OR REPLACE FUNCTION getArticulos(refcursor) RETURNS refcursor AS $BODY$ BEGIN CREATE TEMP TABLE Temporal
I ve created function and trigger as follows: CREATE OR REPLACE FUNCTION New_Ticket() RETURNS
I have function CREATE OR REPLACE FUNCTION public.GetSoilCod ( cod1 integer = 0, cod2
I got some SQL function CREATE OR REPLACE FUNCTION tools.update_company(IN company_id integer, OUT value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.