Thread: CONCAT function equivalent

CONCAT function equivalent

From
Fabian Santiago
Date:
Hello,

Is there an equivalent command (string) for this example:

UPDATE domain SET settings=CONCAT(settings, 'default_language:', defaultlanguage, ';');

that works and accomplishes the same thing in postgresql v8.4? Thanks.

--
Sincerely,

Fabian S.

Re: CONCAT function equivalent

From
Joe Conway
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/17/2014 08:03 AM, Fabian Santiago wrote:
> Hello,
>
> Is there an equivalent command (string) for this example:
>
> UPDATE domain SET settings=CONCAT(settings, 'default_language:',
> defaultlanguage, ';');
>
> that works and accomplishes the same thing in postgresql v8.4?
> Thanks.

You mean like this?

select version();
                                                     version

-
-----------------------------------------------------------------------------------------------------------------
 PostgreSQL 8.4.19 on x86_64-unknown-linux-gnu, compiled by GCC gcc
(Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3, 64-bit
(1 row)

select settings || 'default_language:' || default_language || ';'
from (values ('default_foo:foo;','English'))
as t(settings, default_language);
                 ?column?
- -------------------------------------------
 default_foo:foo;default_language:English;
(1 row)

HTH,

Joe

- --
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTd39OAAoJEDfy90M199hlit0P/iLoEPe98ktCk1HDJchGzEeK
iKtMZHPIjJ4VNaxellPHrkY2yravd06ejKL+eHrytPmm+l1UCka2FzC8Gavvhbam
cbjsm1My+q22J6wCpt2b8tVgl3RibLCol8k/rMwQFVMk1WRMFSAJtQOeVASxI9Ms
9xmV82w+zGbCrHPzxINo3EHpNuoDdz1SKqVPCP93CMeQc6qqTqolPL4w+B9405/V
qPyCHoAfCBw3CGh/cmJ2iu7qCGhdHydGTzzYeTf48N5hXq7903yUF/jd1Nm3IbRJ
TdB7mbUFCExv7R/7FQ5oRj4ELMv5nz9S92qlRcj0qEpuBtSfHtM+72h7Wl4jq66e
JKLyOfakszbb59VDZCIsgofGGiF2Vf7eiMwi+doWsSVvogVukOF/dnL5Py1LG4n4
2XyxKzyM+ddinWAT5qLv9zFUQ6KQZo64dRyxdFscWJneQ6nOmyMMBA743U6JN+wQ
/VivlVQJOxlf2V7DffRvV6BsZBgyeD6ri98YnVeO0lz+mKIe3PSxylPSaBljYTRz
pXYEOYAAXxYxkw6V047vYY3/2050jOzYBMPsmzvWxLN6Bgl1IHhk/8mUbQjqVpQq
CVFgRXgBb0AJeDKbmUEcpWS+qd9UO0mDYGs0cvHbcn89LYIPvENs6IIgxM1gXRUM
BmRUwP0M15lfckjAd2fX
=H/vF
-----END PGP SIGNATURE-----


Re: CONCAT function equivalent

From
Fabian Santiago
Date:
Ok,

Here's another request, based on my first;

instead of looking for a while to CONCAT my values into said table column, I tried this:

UPDATE domain SET settings = ('default_language:en_US;default_user_quota:10240;default_groups:;min_passwd_length:0;max_passwd_length:0;disabled_domain_profiles:;disabled_user_profiles:;');

this created 1 line in my column with all the listed values. How can create those same values in my column but in separate lines, one for each value? thanks for your help.

- Fabian S.

P.S. sorry about missing the reply all to the list; gmail only shows me the senders actual address, not the list address so i had to manually re-add the list address each time i reply i realized. thanks. 


On Sat, May 17, 2014 at 12:10 PM, Joe Conway <mail@joeconway.com> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/17/2014 08:43 AM, Fabian Santiago wrote:
> will your example literally take care of this task? i assume yours
> is only an example because you used 'foo' in there and I'm not sure
> where that comes into play. Excuse my naivety...I don't know
> postgresql too well (or at all) but need to use it for one server
> of mine. Thanks.

You didn't post the definition of the table "domain" nor any sample
data, so the best I could do was a contrived example. When posting to
the lists it is best to post *complete* information in a form that can
be easily cut-and-pasted into a terminal to duplicate your problem.

When you do this you make it easy for people to help you, therefore
you are more likely to get an answer, and the ones you do get will be
a more accurate reflection of your actual problem.

Also, please keep replies on the list so others can learn from the
conversation later.

Joe

- --
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.14 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTd4oEAAoJEDfy90M199hlIzwP/1RDogj62BypJyDuFp0oBlZZ
blic6vQlj8SBOz9b3cZ9DYqPE4Ue/sOaT5++hcJARLXBgT8MXq6I6VpcdWHindTs
j35be12MSukWO0ClDtwaYMG8syVph56LyPHdsz9QDql3T6GpNVz0vWreP7t9Y1oj
/psdYPSFyLfuvqGONhYVqNY8/K1866TF0crGuaYu43I5mdpHBxkZLhxZFw3pXX1O
ceShZaCz4x85beRwcZRUqpw5dqPwq8omeskFypRzOOG76GJohPikdYK9TM84xAUw
j00SCNStJsp9+TljtCtPP6sSnt+v0X6Kc/yF1z/AP7muKXRVkt+21iY6joP++muf
8Y2LdbdVSNDIBDu3sui68dooOA8InmPmqzwXBcyqK6QrMJ8RMogsAFQvIvlMTNhZ
Wzr3S2hLznSzPEjo6tYcXvtr45/wjMga/KtyleSpTSI8rACY9bI42F6XtBk4lC9v
iJwfyhNuB0h0jdvSqdbmB/7f1On5zfMbRSp+hUtSAW727nwNZUX2uN6BYdCiDOh7
vzsycr2GYHc3SaK/teCI/MEjw11LjRxpMYDZPG/AtWuPL4egsUOZ9BlRHWuj4/if
LkmUZKbEl3VLNzrGWqjAdAGJrfDmQQaTGiCdMKdfiAVlPITE+uYvZ89coJ2G4sMK
AEtKoqMayFqychfNPc9z
=CTkC
-----END PGP SIGNATURE-----



--
Sincerely,

Fabian S.
862-432-2373

Re: CONCAT function equivalent

From
David G Johnston
Date:
Fabian Santiago wrote
> Ok,
>
> Here's another request, based on my first;
>
> instead of looking for a while to CONCAT my values into said table column,
> I tried this:
>
> UPDATE domain SET settings =
>
('default_language:en_US;default_user_quota:10240;default_groups:;min_passwd_length:0;max_passwd_length:0;disabled_domain_profiles:;disabled_user_profiles:;');
>
> this created 1 line in my column with all the listed values. How can
> create
> those same values in my column but in separate lines, one for each value?
> thanks for your help.
>
> - Fabian S.
>
> P.S. sorry about missing the reply all to the list; gmail only shows me
> the
> senders actual address, not the list address so i had to manually re-add
> the list address each time i reply i realized. thanks.
>
>
> On Sat, May 17, 2014 at 12:10 PM, Joe Conway <

> mail@

> > wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 05/17/2014 08:43 AM, Fabian Santiago wrote:
>> > will your example literally take care of this task? i assume yours
>> > is only an example because you used 'foo' in there and I'm not sure
>> > where that comes into play. Excuse my naivety...I don't know
>> > postgresql too well (or at all) but need to use it for one server
>> > of mine. Thanks.
>>
>> You didn't post the definition of the table "domain" nor any sample
>> data, so the best I could do was a contrived example. When posting to
>> the lists it is best to post *complete* information in a form that can
>> be easily cut-and-pasted into a terminal to duplicate your problem.
>>
>> When you do this you make it easy for people to help you, therefore
>> you are more likely to get an answer, and the ones you do get will be
>> a more accurate reflection of your actual problem.
>>
>> Also, please keep replies on the list so others can learn from the
>> conversation later.
>>
>> Joe
>>
>> - --
>> Joe Conway
>> credativ LLC: http://www.credativ.us
>> Linux, PostgreSQL, and general Open Source
>> Training, Service, Consulting, & 24x7 Support
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.14 (GNU/Linux)
>> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
>>
>> iQIcBAEBAgAGBQJTd4oEAAoJEDfy90M199hlIzwP/1RDogj62BypJyDuFp0oBlZZ
>> blic6vQlj8SBOz9b3cZ9DYqPE4Ue/sOaT5++hcJARLXBgT8MXq6I6VpcdWHindTs
>> j35be12MSukWO0ClDtwaYMG8syVph56LyPHdsz9QDql3T6GpNVz0vWreP7t9Y1oj
>> /psdYPSFyLfuvqGONhYVqNY8/K1866TF0crGuaYu43I5mdpHBxkZLhxZFw3pXX1O
>> ceShZaCz4x85beRwcZRUqpw5dqPwq8omeskFypRzOOG76GJohPikdYK9TM84xAUw
>> j00SCNStJsp9+TljtCtPP6sSnt+v0X6Kc/yF1z/AP7muKXRVkt+21iY6joP++muf
>> 8Y2LdbdVSNDIBDu3sui68dooOA8InmPmqzwXBcyqK6QrMJ8RMogsAFQvIvlMTNhZ
>> Wzr3S2hLznSzPEjo6tYcXvtr45/wjMga/KtyleSpTSI8rACY9bI42F6XtBk4lC9v
>> iJwfyhNuB0h0jdvSqdbmB/7f1On5zfMbRSp+hUtSAW727nwNZUX2uN6BYdCiDOh7
>> vzsycr2GYHc3SaK/teCI/MEjw11LjRxpMYDZPG/AtWuPL4egsUOZ9BlRHWuj4/if
>> LkmUZKbEl3VLNzrGWqjAdAGJrfDmQQaTGiCdMKdfiAVlPITE+uYvZ89coJ2G4sMK
>> AEtKoqMayFqychfNPc9z
>> =CTkC
>> -----END PGP SIGNATURE-----
>>
>
>
>
> --
> Sincerely,
>
> Fabian S.
> 862-432-2373

Sometimes the answers you get will be generic and you will need to adapt
them to your specific situation.  Like this one:

E'value1\nvalue2'

The E'' denotes that the supplied literal has escapes that need interpeting.
The "\n" is the escape for a newline.

David J.






--
View this message in context: http://postgresql.1045698.n5.nabble.com/CONCAT-function-equivalent-tp5804328p5804343.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.