From pk_rehan@yahoo.com Sat Mar 24 11:44:15 2012 Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 09B5F173662E for ; Sat, 24 Mar 2012 08:44:15 -0300 (ADT) Received: from nm18-vm3.bullet.mail.ne1.yahoo.com ([98.138.91.148]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SBPOH-0007YF-U8 for pgsql-sql@postgresql.org; Sat, 24 Mar 2012 11:44:15 +0000 Received: from [98.138.90.48] by nm18.bullet.mail.ne1.yahoo.com with NNFMP; 24 Mar 2012 11:43:59 -0000 Received: from [98.138.89.164] by tm1.bullet.mail.ne1.yahoo.com with NNFMP; 24 Mar 2012 11:43:59 -0000 Received: from [127.0.0.1] by omp1020.mail.ne1.yahoo.com with NNFMP; 24 Mar 2012 11:43:59 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 510238.31396.bm@omp1020.mail.ne1.yahoo.com Received: (qmail 95305 invoked by uid 60001); 24 Mar 2012 11:43:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1332589439; bh=wsxpP/Ew7JbAXt/ncoGTWw+e4aS4DLNb3ZFnz3fV5kk=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=at+Ynguvh5a3tUJU5m480voWpa5MOC1m/W1DF+gJGSBihK6oy8U4l3Mz/7zq6DgjE44t6IWrnogwOwcy6GrnQQSIFpHasUs4PYDTOmsTvJO6Vf/MvZLilo/3x2RUp8K8GpJfu+ra9+GxsAF/anjLo6KjbHjnqJo/KpnjKZ2P5EY= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=xG55apYPMSSf968BJ6vS9VDYqjLWUPNt9XfyDNVJlJj6OtPvE2zaBEzmcS4LSzKWIUgJWbmojPMRJTFQv1f6ElbEmufY8cn/tnnkZ1SvFqauiqbtABSBk7OZn8eCdDbqN2gB2pP3iWGITirnKvmaqPubzb74RF6OWiOBSaB7SIg=; X-YMail-OSG: KRetxVEVM1ljVi7DKn6GXsHVkBKgRZzSwlvbJedPCrKHF.l AJFOmmw.ncBYLIzCPQHCitppurjTCgeGnpOCHFdX5C6j_IDEB01Xdrb7YnC. fjgxF1oDvgTq0qQMWgHoC9XkLX3cIyJNkTx8Zfd.BPbe6dYjhYZ2zVH_5Crr 4aiPoTboFxdarONNfjQXAueKy1ak3wLFv8vM9c69BHjt4fgRlh5G9yvizc81 acejbfpc5vPgFhbkgR596PCg4AwBzviFwXjJvdQ7.98PfrvtOcXyDpj_UUmy XlPjWg4WAEFwkkQ3gcvUpaY5TwxxNKYXMxvnYbkHQGMxws3sN5d2HHoD7ULn Cm61OBLM1x5Kwy.r7gQFhxftEe4epZyxWk8ZZMaIY7qQNRvNSpLRE8s0OPSK 4cVbGFozhsHQTKsvphUScMpT2xAdF67ymyN5qrT.aS.dLT0HGxApVqxCU2AU 55xvf Received: from [182.177.128.211] by web121601.mail.ne1.yahoo.com via HTTP; Sat, 24 Mar 2012 04:43:59 PDT X-Mailer: YahooMailWebService/0.8.117.340979 Message-ID: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> Date: Sat, 24 Mar 2012 04:43:59 -0700 (PDT) From: Rehan Saleem Reply-To: Rehan Saleem Subject: how to concatenate in PostgreSQL To: "pgsql-sql@postgresql.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1977980688-1218263531-1332589439=:54415" X-Pg-Spam-Score: 2.4 (++) X-Archive-Number: 201203/71 X-Sequence-Number: 36466 ---1977980688-1218263531-1332589439=:54415 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable hi ,=0Ahow can we concatinate these lines and execute sql command=0A=A0=0A= =A0 =A0 =A0 =A0setsql =3D'select user,username,=0Afirstname '=0A=A0=A0=A0= =A0=A0 set sql +=3D' lastname, cardno from table1where userid=3D'+ 5 =0A=A0= =A0=A0=A0=A0 exec(sqi) =0A=A0 =A0 =A0where 5 is the userid from table1=0Ath= anks ---1977980688-1218263531-1332589439=:54415 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
hi ,<= /div>
<= span style=3D"font-size: 10pt; font-family: 'Courier New'; ">how can we con= catinate these lines and execute sql command
 
       set sql =3D = 'select user,username,=0Afirstname '
=0A=0A &nbs= p;    set sql +=3D ' lastname, cardno from table1 where user= id=3D' + 5
=0A=0A
      exec(sqi) <= o:p>
=0A=0A
     where 5 is the userid from table1<= /span>
thanks
=0A=0A
&= nbsp;
=0A=0A

=0A=0A 
---1977980688-1218263531-1332589439=:54415-- From akretschmer@spamfence.net Sat Mar 24 11:57:34 2012 Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 89C86173662D for ; Sat, 24 Mar 2012 08:57:34 -0300 (ADT) Received: from mailout04.ims-firmen.de ([213.174.32.250]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SBPb7-0008Fd-Qj for pgsql-sql@postgresql.org; Sat, 24 Mar 2012 11:57:34 +0000 Received: from mailin01.ims-firmen.de ([192.168.1.141]) by mailout02.ims-firmen.de with esmtp (envelope-from ) id 1SBPat-0007le-9G for pgsql-sql@postgresql.org; Sat, 24 Mar 2012 12:57:15 +0100 Received: from [87.170.212.51] (helo=a-kretschmer.de) by mailin01.ims-firmen.de with esmtpsa (TLSv1:AES256-SHA:256) (envelope-from ) id 1SBPaO-0008HC-0o for pgsql-sql@postgresql.org; Sat, 24 Mar 2012 12:56:44 +0100 Received: from kretschmer by a-kretschmer.de with local (Exim 4.69) (envelope-from ) id 1SBPas-0006gw-8E for pgsql-sql@postgresql.org; Sat, 24 Mar 2012 12:57:14 +0100 Date: Sat, 24 Mar 2012 12:57:14 +0100 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: how to concatenate in PostgreSQL Message-ID: <20120324115714.GA25468@tux> References: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: Mutt/1.5.18 (2008-05-17) X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/72 X-Sequence-Number: 36467 Rehan Saleem wrote: > hi , > how can we concatinate these lines and execute sql command > > set sql = 'select user,username, firstname ' > set sql += ' lastname, cardno from table1 where userid=' + 5 sql = sql || ' bla fasel'; || is the concat - Operator. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was god, I would recompile penguin with --enable-fly." (unknown) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889° From kamauallan@gmail.com Sat Mar 24 13:43:14 2012 Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id AD7FD173662F for ; Sat, 24 Mar 2012 10:43:14 -0300 (ADT) Received: from mail-qc0-f174.google.com ([209.85.216.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SBRFR-0001NC-6p for pgsql-sql@postgresql.org; Sat, 24 Mar 2012 13:43:14 +0000 Received: by qcqw6 with SMTP id w6so2538255qcq.19 for ; Sat, 24 Mar 2012 06:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=/1qTLQi7cR43RznBuFK+CKfi2CB7dzSlyRtV0guWWXo=; b=urJZ4EuTErTmzWnhxyuUBSSY+nAC08rANKTmd6GKoqog1x5BLc7Y1u27mwIUTb/FDZ VFPROX/IaUqVeMlWtDyGf3/l76WdTWZWr8zubpSrJsKiEfXpQHtUcrvZ41yo3Zk445Pm VtFbliT634T/VNvGnh4mWVClM3jrlmrS6pwkyZE+5fc4t7Q5+aD8A77xE+egAwgG/fUd IrUq1fPjJO+zawAyhscR3M3LBNGDrs1kbXNKhS9sKas8ydAietlMLq2BgcuCihYYfYs0 hPKzzj0zGOnHvQhik7gXq+CDXjHZu6QdtYa8LY2p0fWhVXCoaV+unBw7o2g5AHyZKDYb wYcg== MIME-Version: 1.0 Received: by 10.229.137.6 with SMTP id u6mr6003120qct.112.1332596579965; Sat, 24 Mar 2012 06:42:59 -0700 (PDT) Received: by 10.229.118.203 with HTTP; Sat, 24 Mar 2012 06:42:59 -0700 (PDT) In-Reply-To: <20120324115714.GA25468@tux> References: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> <20120324115714.GA25468@tux> Date: Sat, 24 Mar 2012 16:42:59 +0300 Message-ID: Subject: Re: how to concatenate in PostgreSQL From: Allan Kamau To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201203/73 X-Sequence-Number: 36468 On 3/24/12, Andreas Kretschmer wrote: > Rehan Saleem wrote: > >> hi , >> how can we concatinate these lines and execute sql command >> >> set sql =3D 'select user,username, firstname ' >> set sql +=3D ' lastname, cardno from table1 where userid=3D' + 5 > > sql =3D sql || ' bla fasel'; > > || is the concat - Operator. > > > > Andreas > -- > Really, I'm not out to destroy Microsoft. That will just be a completely > unintentional side effect. (Linus Torvalds) > "If I was god, I would recompile penguin with --enable-fly." (unknown) > Kaufbach, Saxony, Germany, Europe. N 51.05082=B0, E 13.56889= =B0 > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > You may want to ensure that none of variables to be concatenated is NULL, else the end result will be NULL. "coalesce" function provides means to provide an substitute value for a variable that may be NULL. Allan. From robins.tharakan@comodo.com Mon Mar 26 10:15:36 2012 Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 16AD91DB08BA for ; Mon, 26 Mar 2012 07:15:36 -0300 (ADT) Received: from mdfw.comodoca.net ([91.209.196.68] helo=mmmail1.mcr.colo.comodoca.net) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SC6xa-00049Y-96 for pgsql-sql@postgresql.org; Mon, 26 Mar 2012 10:15:35 +0000 Received: (qmail 32315 invoked by uid 1009); 26 Mar 2012 10:15:21 -0000 Received: from Unknown (HELO cssw050615.comodo.net) (192.168.199.43) (smtp-auth username robinst, mechanism plain) by mmmail1.mcr.colo.comodoca.net (qpsmtpd/0.40) with (AES256-SHA encrypted) ESMTPSA; Mon, 26 Mar 2012 11:15:21 +0100 Message-ID: <4F7041B7.2040108@comodo.com> Date: Mon, 26 Mar 2012 15:45:19 +0530 From: Robins Tharakan User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.3) Gecko/20120314 Thunderbird/10.0.3 MIME-Version: 1.0 To: "pgsql-sql@postgresql.org" Subject: Re: how to concatenate in PostgreSQL References: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> In-Reply-To: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms010905040502030008000709" X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/77 X-Sequence-Number: 36472 This is a cryptographically signed message in MIME format. --------------ms010905040502030008000709 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Hi, Probably you're looking for these set of articles. http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_Postgr= eSQL#Microsoft_SQL_Server The second article (by Ethan) has good small hints for things such as=20 the query that you ask in this thread, when migrating from MSSQL to=20 PostgreSQL. -- Robins On 03/24/2012 05:13 PM, Rehan Saleem wrote: > hi , > how can we concatinate these lines and execute sql command > setsql =3D 'select user,username, firstname ' > set sql +=3D ' lastname, cardno from table1 where userid=3D' + 5 > exec(sqi) > where 5 is the userid from table1 > thanks > --------------ms010905040502030008000709 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIPkTCC BIowggNyoAMCAQICECf06hH0eobEbp27bqkXBwcwDQYJKoZIhvcNAQEFBQAwbzELMAkGA1UE BhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9vdDAeFw0w NTA2MDcwODA5MTBaFw0yMDA1MzAxMDQ4MzhaMIGuMQswCQYDVQQGEwJVUzELMAkGA1UECBMC VVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5l dHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTE2MDQGA1UEAxMtVVRO LVVTRVJGaXJzdC1DbGllbnQgQXV0aGVudGljYXRpb24gYW5kIEVtYWlsMIIBIjANBgkqhkiG 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsjmFpPJ9q0E7YkY3rs3BYHW8OWX5ShpHornMSMxqmNVN NRm5pELlzkniii8efNIxB8dOtINknS4p1aJkxIW9h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c3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQx OTA3BgNVBAMTMENPTU9ETyBDbGllbnQgQXV0aGVudGljYXRpb24gYW5kIFNlY3VyZSBFbWFp bCBDQQIQX3nJ/gUX0cLAaAavZDzGLzCBuwYLKoZIhvcNAQkQAgsxgauggagwgZMxCzAJBgNV BAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQx GjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTkwNwYDVQQDEzBDT01PRE8gQ2xpZW50IEF1 dGhlbnRpY2F0aW9uIGFuZCBTZWN1cmUgRW1haWwgQ0ECEF95yf4FF9HCwGgGr2Q8xi8wDQYJ KoZIhvcNAQEBBQAEggEAYvy1gfdL3jZoRWlWWvVx2Y6+1Lo4w07Lilz5/rWdMjI1ANy0dRnA Z176hFAxIFHBg0xWndm2Halfw+NZdSnFWZh5oyt2wj30THlAJZDuh8PwrfjIMxUw/C81WlNw m0hst20kkEilR/RZpkzIQomdF/yV59Rue8GAe2DkGIkmKBX+Moru74nhfYgrpcnEpODe7TuS EAmGgq5qvx1eIWOecriFYTUMx3DMCFzHYwmFBc5DD8G6jc1aHFPOsa429NUxfDfUKY5N7AH/ 26AKG66zenPO076vgxMMvaCBzxdmv2/KGep+jxvIReEt8PF8bxfH2mjMjpFGqBaFSmdc3e0Q IgAAAAAAAA== --------------ms010905040502030008000709-- From scrawford@pinpointresearch.com Mon Mar 26 16:09:05 2012 Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 833311B2D9D4 for ; Mon, 26 Mar 2012 13:09:05 -0300 (ADT) Received: from cerberus.pinpointresearch.com ([66.7.238.130] helo=polaris.pinpointresearch.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SCCTO-0004hr-VB for pgsql-sql@postgresql.org; Mon, 26 Mar 2012 16:09:04 +0000 Received: from betelgeuse.pinpointresearch.com (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id 70DB0E00EC84 for ; Mon, 26 Mar 2012 09:08:33 -0700 (PDT) Message-ID: <4F709481.30503@pinpointresearch.com> Date: Mon, 26 Mar 2012 09:08:33 -0700 From: Steve Crawford User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.27) Gecko/20120216 Lightning/1.0b2 Thunderbird/3.1.19 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: how to concatenate in PostgreSQL References: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> In-Reply-To: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> Content-Type: multipart/alternative; boundary="------------060803010809080300070109" X-Pg-Spam-Score: -0.9 (/) X-Archive-Number: 201203/79 X-Sequence-Number: 36474 This is a multi-part message in MIME format. --------------060803010809080300070109 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 > exec(sqi) > where 5 is the userid from table1 > thanks > Cheers, Steve --------------060803010809080300070109 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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?
 
       set sql = 'select user,username, firstname '
      set sql += ' lastname, cardno from table1 where userid=' + 5
      exec(sqi)
     where 5 is the userid from table1
thanks
 

 
Cheers,
Steve
--------------060803010809080300070109-- From scrawford@pinpointresearch.com Tue Mar 27 16:13:04 2012 Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 5745616D90F8 for ; Tue, 27 Mar 2012 13:13:04 -0300 (ADT) Received: from cerberus.pinpointresearch.com ([66.7.238.130] helo=polaris.pinpointresearch.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SCZ13-00034y-7f for pgsql-sql@postgresql.org; Tue, 27 Mar 2012 16:13:02 +0000 Received: from betelgeuse.pinpointresearch.com (betelgeuse.pinpointresearch.com [192.168.1.179]) by polaris.pinpointresearch.com (Postfix) with ESMTP id 2FADCE00EC83; Tue, 27 Mar 2012 09:12:47 -0700 (PDT) Message-ID: <4F71E6FF.6060204@pinpointresearch.com> Date: Tue, 27 Mar 2012 09:12:47 -0700 From: Steve Crawford User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.27) Gecko/20120216 Lightning/1.0b2 Thunderbird/3.1.19 MIME-Version: 1.0 To: Rehan Saleem CC: sql pgsql Subject: Re: how to concatenate in PostgreSQL References: <1332589439.54415.YahooMailNeo@web121601.mail.ne1.yahoo.com> <4F709481.30503@pinpointresearch.com> <1332859717.73799.YahooMailNeo@web121606.mail.ne1.yahoo.com> In-Reply-To: <1332859717.73799.YahooMailNeo@web121606.mail.ne1.yahoo.com> Content-Type: multipart/alternative; boundary="------------030904060800040606020005" X-Pg-Spam-Score: -0.9 (/) X-Archive-Number: 201203/80 X-Sequence-Number: 36475 This is a multi-part message in MIME format. --------------030904060800040606020005 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 > *To:* pgsql-sql@postgresql.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 >> exec(sqi) >> where 5 is the userid from table1 >> thanks >> > Cheers, > Steve > > 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 advice nonetheless. 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: http://www.postgresql.org/docs/current/static/plpgsql.html As to the topic of executing the command including many examples see: http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN 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. Cheers, Steve --------------030904060800040606020005 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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@pinpointresearch.com>
To: pgsql-sql@postgresql.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?
 
       set sql = 'select user,username, firstname '
      set sql += ' lastname, cardno from table1 where userid=' + 5
      exec(sqi)
     where 5 is the userid from table1
thanks
 

 
Cheers,
Steve


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 advice nonetheless.

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:
http://www.postgresql.org/docs/current/static/plpgsql.html

As to the topic of executing the command including many examples see:
http://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

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.

Cheers,
Steve

--------------030904060800040606020005--