Skip to main content
deleted 66 characters in body; edited tags
Source Link
user330315
user330315

I want a function which will return concated string. I am getting following error after execute this function in postgresql.

CREATE OR REPLACE FUNCTION getTableName ()

RETURNS text AS $$

DECLAREI want a function which will return concated string. I am getting following error after execute this function in postgresql.

CREATE OR REPLACE FUNCTION getTableName () 
RETURNS text AS $$ 
DECLARE 
    state_short_name text; 
BEGIN 
   state_short_name := (select lower(state_short_name) from mst_state where state_code in (SELECT substr(entity_code,1,2) FROM shg_detail_share WHERE entity_code = '3420006002001'))   
   RETURN (CONCAT(state_short_name, '_shg_detail'));
END;
$$  LANGUAGE plpgsql 

BEGIN

state_short_name := (select lower(state_short_name) from mst_state where state_code in (SELECT substr(entity_code,1,2) FROM shg_detail_share WHERE entity_code = '3420006002001'))

RETURN (CONCAT(state_short_name, '_shg_detail'));

END;

$$ LANGUAGE plpgsql

I expect the output like 'jh_shg_detail' but I am getting error like this

ERROR: syntaxI expect the output like 'jh_shg_detail' but I am getting error at or near "(" LINE 9: RETURN (CONCAT(state_short_name, '_shg_detail'));like this

enter image description here

ERROR:  syntax error at or near "("
LINE 9:    RETURN (CONCAT(state_short_name, '_shg_detail')); 

I want a function which will return concated string. I am getting following error after execute this function in postgresql.

CREATE OR REPLACE FUNCTION getTableName ()

RETURNS text AS $$

DECLARE

state_short_name text; 

BEGIN

state_short_name := (select lower(state_short_name) from mst_state where state_code in (SELECT substr(entity_code,1,2) FROM shg_detail_share WHERE entity_code = '3420006002001'))

RETURN (CONCAT(state_short_name, '_shg_detail'));

END;

$$ LANGUAGE plpgsql

I expect the output like 'jh_shg_detail' but I am getting error like this

ERROR: syntax error at or near "(" LINE 9: RETURN (CONCAT(state_short_name, '_shg_detail'));

enter image description here

I want a function which will return concated string. I am getting following error after execute this function in postgresql.

CREATE OR REPLACE FUNCTION getTableName () 
RETURNS text AS $$ 
DECLARE 
    state_short_name text; 
BEGIN 
   state_short_name := (select lower(state_short_name) from mst_state where state_code in (SELECT substr(entity_code,1,2) FROM shg_detail_share WHERE entity_code = '3420006002001'))   
   RETURN (CONCAT(state_short_name, '_shg_detail'));
END;
$$  LANGUAGE plpgsql 

I expect the output like 'jh_shg_detail' but I am getting error like this

ERROR:  syntax error at or near "("
LINE 9:    RETURN (CONCAT(state_short_name, '_shg_detail')); 
Source Link
Rakesh
  • 45
  • 1
  • 11

How to concat two string in postgresql function?

I want a function which will return concated string. I am getting following error after execute this function in postgresql.

CREATE OR REPLACE FUNCTION getTableName ()

RETURNS text AS $$

DECLARE

state_short_name text; 

BEGIN

state_short_name := (select lower(state_short_name) from mst_state where state_code in (SELECT substr(entity_code,1,2) FROM shg_detail_share WHERE entity_code = '3420006002001'))

RETURN (CONCAT(state_short_name, '_shg_detail'));

END;

$$ LANGUAGE plpgsql

I expect the output like 'jh_shg_detail' but I am getting error like this

ERROR: syntax error at or near "(" LINE 9: RETURN (CONCAT(state_short_name, '_shg_detail'));

enter image description here