develooper Front page | perl.dbi.users | Postings from February 2019

RE: Translate between DBI and SQL

Thread Previous | Thread Next
From:
Fennell, Brian
Date:
February 11, 2019 16:48
Subject:
RE: Translate between DBI and SQL
Message ID:
BN6PR14MB1617679E3D37B93ABD5C50C0A2640@BN6PR14MB1617.namprd14.prod.outlook.com
P.P.S.

My last answer used single-quote for a column with a space in it in PostgreSQL - this is wrong, it should have been a double-quote for the name of the column with a space and a single quote for a quoted string literal in PostgreSQL.

Better example:

(Adapted from answer to question here
    https://dba.stackexchange.com/questions/118059/quoting-columns-with-spaces-in-postgresql
)


$my_perl_sql_string= 'SELECT' . "\n";
$my_perl_sql_string.= '   tab."This IS My Column EXACTLY" AS col' . "\n";
$my_perl_sql_string.= 'FROM "My TabLE Name Contains Spaces Too!" tab' . "\n";
$my_perl_sql_string.= 'WHERE tab."ANOTHER UGLY COLUMN name" = \'MyFilterString\'    '

I don't know if PostgreSQL requires a trailing semi-colon when used in DBI/DBD or not.
I know that Oracle SQL requires a trailing semicolon in sqlplus but not in DBI/DBD.
I don't have a PostgreSQL database to try it out on.

Try it both ways, and the one that works is the one to use.

Brian Fennell




The information contained in this electronic mail transmission is intended only for the use of the individual or entity named in this transmission. If you are not the intended recipient of this transmission, you are hereby notified that any disclosure, copying or distribution of the contents of this transmission is strictly prohibited and that you should delete the contents of this transmission from your system immediately. Any comments or statements contained in this transmission do not necessarily reflect the views or position of Radial or its subsidiaries and/or affiliates.



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About