Re: Problem mit Umlaute und DBI
Michael Neumann <[email protected]>
| Newsgroups | gmane.comp.lang.ruby.german |
|---|---|
| Message-ID | <[email protected]> |
Oliver Mensinger wrote:
> Hallo Michael,
>
> die Ausgabe sieht dann so aus:
>
> p prep_sql:
> #<DBI::SQL::PreparedStatement:0x40285d38
> @sql="SELECT * FROM customer WHERE name='ö'",
> @quoter=#<DBI::DBD::Pg::Statement:0x40285d60
> @db=#<DBI::DBD::Pg::Database:0x402caa28 @autocommit=true,
> @coerce=#<DBI::SQL::BasicQuote::Coerce:0x402ca424>,
> @connection=#<PGconn:0x402ca474>,
> @in_transaction=false, @type_map={1083=>:as_str, 27=>:as_str, 16=>:as_bool,
> 1562=>:as_str, 869=>:as_str, 704=>:as_str, 22=>:as_str, 0=>:as_str,
> 1700=>:as_str,
> 28=>:as_str, 17=>:as_str, 600=>:as_str, 1266=>:as_str, 650=>:as_str,
> 23=>:as_int,
> 628=>:as_str, 1184=>:as_timestamp, 700=>:as_float, 601=>:as_str, 29=>:as_str,
> 18=>:as_str, 24=>:as_str, 602=>:as_str, 1042=>:as_str, 30=>:as_str, 19=>:as_str,
> 701=>:as_float, 25=>:as_str, 718=>:as_str, 1560=>:as_str, 1186=>:as_str,
> 702=>:as_str,
> 603=>:as_str, 20=>:as_int, 1043=>:as_str, 790=>:as_str, 1082=>:as_date,
> 829=>:as_str,
> 26=>:as_str, 1033=>:as_str, 604=>:as_str, 703=>:as_str, 21=>:as_int},
> @attr={"AutoCommit"=>true}, @debug_level=0>, @bindvars=[], @result=nil,
> @prep_sql=#<DBI::SQL::PreparedStatement:0x40285d38 ...>>, @unbound={},
> @result=["SELECT * FROM customer WHERE name=ö'"], @arg_index=0>
>
> p bindvars:
> []
>
> p boundsql:
> "SELECT * FROM customer WHERE name=ö'"
>
> Skript:
> /usr/local/lib/ruby/site_ruby/1.6/DBD/Pg/Pg.rb:410:
> in `execute': ERROR: Unterminated quoted string (DBI::ProgrammingError)
>
> Ich hoffe das bringt Dich weiter. Es ist ein Bug, oder?!
Hmm, ich kann den Fehler auf meiner Postgres-DB (7.2.1_1/FreeBSD) nicht reproduzieren.
Folgendes Skript läuft problemlos:
require "dbi"
DBI.connect("dbi:Pg:mneumann", "user", "passwd") do |dbh|
dbh.do "CREATE TABLE artikel ( artikelnr VARCHAR(30) )"
dbh.do "INSERT INTO artikel VALUES ('test')"
dbh.do "INSERT INTO artikel VALUES ('test2')"
dbh.do "INSERT INTO artikel VALUES ('ö')"
p dbh.select_one("SELECT * FROM artikel WHERE artikelnr = 'ö'") # => ['\366']
dbh.do("DROP TABLE artikel")
end
Probier mal in "psql" die Query, die bei dir nicht funktioniert, abzusetzen.
MfG,
Michael