Failed to start SQL Shell (psql) of PostgreSQL 9.3 - postgresql

I'm new to this program and I found a problem when try to log in to start my programming. I get an error as shown in the figure below and stuck here for quite some time and I wonder it was came out with such strange characters. Hopefully could receive some recommendations and solutions over here.

You most likely have an encoding problem.
As you said in chat, your database encoding is UTF-8, while your shell encoding is CP-1252 ("Latin-1").
You need to switch your Terminal to UTF-8 (if thats possible on windows).
But most likely you want to use pgAdmin for your work. As long as you don't have a very specific reason to use the shell, its by far more convenient to use pgAdmin.

Related

Can you write Perl 6 scripts using an encoding that is not utf8?

Perl 5 has the encoding pragma or the Filter::Encoding module, however, I have not found anything similar in Perl 6. I guess eventually source filters will be created, but for the time being, can you use other encodings in Perl 6 scripts?
You cannot write your Perl 6 script in anything except utf8. I don't think there will ever be any other encoding you will be allowed to write your script in, as utf8 is basically the universal standard. Benefits like not having endianess and being back compatible with ASCII are some reasons it has become the standard and not things like utf16 or utf32.
Maybe there was a time before when such a thing may have been useful, but today I do not see that being the case. All text editors in common usage I know of default to utf8, and having files in multiple formats makes it more difficult to share your Perl 6 programs with others. There are plenty of reasons to want to use other encodings external to Perl 6 (writing to files, reading files etc.) but I don't see adding filters as smart move.
Rakudo currently supports an --encoding= option, so you might in theory be able to write a script in a different character encoding, and call it with perl6 --encoding=utf16 yourscript.p6. But in my experiments, I haven't managed to get it working with anything except utf8, and even if it worked, specifying --encoding on the command line would be a big no go for me.
So the operational answer is: currently no.
(And I don't think anybody else has asked for it yet...)

Aginity SQL error message shows wrong character

When I make a query in Aginity with an error in it, it gives a notification like
ERROR: '[My SQL here]'
error
^ found "INSERT" (at char 2292) expecting `SELECT' or `'(''
If I click on the location of that error in my SQL, it's actually at Position: 3934. I think Aginity is disregarding the whitespace when it tries to say where the error is. Is there a way to make it show the position in the builder?
It's not Aginity that does this, it's somewhere up the software stack (I suspect it's on the actual Netezza itself).
What I do (and this is a POOR solution) is to remove the whitespace myself.
Since I use Unix (mostly) and Vim this is a little easier than in Aginity.
It really is a PITA, and IBM should proved a better solution (one would be to kick back the SQL statement as run with all the whitespace removed).

Execute Commands in the Linux Commandline [Lazarus / Free Pascal]

I have a problem. I want to execute some commands in the Commandline of linux. I tested TProcess (So i am using Lazarus) but now when i am starting the programm, there is nothing, wich the Program do.
Here is my Code:
uses [...], unix, process;
[...]
var LE_Path: TLabeledEdit;
[...]
Pro1:=TProcess.Create(nil);
Pro1.CommandLine:=(('sudo open'+LE_Path.Text));
Pro1.Options := Pro1.Options; //Here i used Options before
Pro1.Execute;
With this Program, i want to open Files with sudo (The Programm is running on the User Interface)
->Sorry for my Bad English; Sorry for fails in the Question: I am using StackOverflow the first time.
I guess the solution was a missing space char?
Change
Pro1.CommandLine:=(('sudo open'+LE_Path.Text));
to
Pro1.CommandLine:=(('sudo open '+LE_Path.Text));
# ----------------------------^--- added this space char.
But if you're a beginner programmer, my other comments are still worth considering:
trying to use sudo in your first bit of code may be adding a whole extra set of problems. SO... Get something easier to work first, maybe
/bin/ls -l /path/to/some/dir/that/has/only/a/few/files.
find out how to print a statement that will be executed. This is the most basic form of debugging and any language should support that.
Your english communicated your problem well enough, and by including sample code and reasonable (not perfect) problem description "we" were able to help you. In general, a good question contains the fewest number of steps to re-create the problem. OR, if you're trying to manipulate data,
a. small sample input,
b. sample output from that same input
c. your "best" code you have tried
d. your current output
e. your thoughts about why it is not working
AND comments to indicate generally other things you have tried.

customize emacs sql-mode to execute sql-blocks

REPL in EMACS is really a great feature I love so much.
but under sql-mode, I encountered quite a few issues.
like:
I would like to use db3( a wrapper of db2 which can recoginze alias ), can I start a db3 shell buffer and make the sql-mode recognize it as the default evaluation buffer?
this is actually more important, when I send a region to the eval buffer, the eval buffer will execute the region by line break, which make my sql-code barely executable. so How would I customize the sql-mode, so that it can execute by block instead of line-break ?
==========I have find solution myself==================
for question 1: customize the sql-db2 is definitely more difficult , which I am still digging out, that envolves more work like writing plugins for emacs
==> the temporary solution is I can still connect to db2 use alias
for question 2: it turns out that db2 do have an option -t to set the termination character , which perfectly solves my question.
==========I have find solution myself==================
for question 1: customize the sql-db2 is definitely more difficult , which I am still digging out, that envolves more work like writing plugins for emacs ==> the temporary solution is I can still connect to db2 use alias
for question 2: it turns out that db2 do have an option -t to set the termination character , which perfectly solves my question.

Hitting ORA-01461 when inserting multibyte characters from perl into oracle

I have a perl script that is inserting records from a text file into our database. Whenever the record has a multibyte character like "RODR_Í_GUEZ". I receive the error ORA-01461, however i'm nowhere near the 4000 characters to switch from varchar2 to long
setting:
$ENV{NLS_CHARACTERSET} = 'AL32UTF8';
before connecting doesn't seem to help.
Using a java client (SQuirreL SQL) and manually writing the INSERT INTO statement inserts the record just fine, so i'm sure it's not how the database is configured.
Any thoughts?
You probably want to set the NLS_LANG environment variable. For Unix-ish systems, there is a script supplied in $ORACLE_HOME/server/bin called nls_lang.sh to output a reasonable value for your system, based on the LANG environment variable.
e.g. for my system (LANG=en_GB.UTF-8) the equivalent Oracle setting is
NLS_LANG=ENGLISH_UNITED KINGDOM.AL32UTF8
More info: http://forums.oracle.com/forums/thread.jspa?threadID=381531
Sergiusz's post there says practically all you need to know: I'll just add that the Perl DBD::Oracle driver is OCI-based, and the pure-Java JDBC driver isn't, hence they work differently in the same environment.