On 03/27/2012 07:48 AM, Rehan Saleem wrote:
> well i am quite sure its PostgreSQL forum and it is obvious, i am
> asking this to concatenate in plpgsql.
> *From:* Steve Crawford <scrawford(at)pinpointresearch(dot)com>
> *To:* pgsql-sql(at)postgresql(dot)org
> *Sent:* Monday, March 26, 2012 9:08 PM
> *Subject:* Re: [SQL] how to concatenate in PostgreSQL
> On 03/24/2012 04:43 AM, Rehan Saleem wrote:
>> hi ,
>> how can we concatinate these lines and execute sql command
> In what? Psql? A PL/pgSQL function. C/Java/PHP/Python/Perl/Erlang/Lua?
>> setsql = 'select user,username, firstname '
>> set sql += ' lastname, cardno from table1 where userid=' + 5
>> where 5 is the userid from table1
Yes, after about a decade of PostgreSQL use and forum participation I
think I know which forum this is. Sarcasm and biting at people who want
to help you is not a good way to make friends and get help on the forums.
If you meant PL/pgSQL then say it. It is not the same as SQL though the
syntax is generally similar. Look at DECLARE and BEGIN for starters.
I've seen too many threads get reset back to the start once some
incorrect assumptions get corrected to feel that up-front clarification
is a waste of time.
http://wiki.postgresql.org/wiki/Guide_to_reporting_problems is more
oriented to problem reporting than general questions but has helpful
Back to the issue at hand...others have pointed out the || operator and
the issue with NULL. It appears you are doing a lot of conversion
requiring writing of PL/pgSQL functions. Spend a few minutes skimming:
As to the topic of executing the command including many examples see:
If you are writing functions that must use dynamically generated table
and column names, become familiar with the quote_ident, quote_literal
and quote_nullable functions.
In response to
pgsql-sql by date
|Next:||From: Gary Stainburn||Date: 2012-03-28 14:01:38|
|Subject: Wrong output from union|
|Previous:||From: Steve Crawford||Date: 2012-03-26 16:08:33|
|Subject: Re: how to concatenate in PostgreSQL|