RE: SQL::Statement cannot parse valid Postgresql statement

> From: Terrence Brannon [mailto:metaperl@mac.com]
> 
> On Monday, December 10, 2001, at 09:16 AM, Jeff Zucker wrote:
> 
> > Terrence Brannon wrote:
> >>
> >> The following SQL is not parseable by SQL::Statement:
> >>
> >> INSERT
> >>    INTO   thot_log (thot_fk,thot_type_fk,thot_temporality_fk,date)
> >>    VALUES (?,?,?,CURRENT_TIMESTAMP)
> 
> What I have is a program which reads a SQL statement from a file. 
> It parses it with SQL::Statement, then it prepares this 
> statement, then does an execute against it with @ARGV. I tried 
> your quoting suggestion. In fact, I put the following 3 different 
> things in the file:
> 

Prepares it and executes it against what database? If its Postgres, then
Postgres should be parsing it, not SQL::Statement. CURRENT_TIMESTAMP is
special to Postgres, and since its not ANSI standard, most other
databases will and should choke on it. SQL::Statement will choke on
it because it is not standard SQL, which is all SQL::Statement
will parse. If you quote it, then it'll be a valid sql statement, but
then obviously you'll be inserting a literal string which is probably
not what you want. You can't expect SQL::Statement to handle every
special thing that every database might include in its featureset/syntax.

Cheers,
Douglas Wilson
0
Doug_Wilson
12/10/2001 6:30:00 PM
perl.dbi.users 11098 articles. 1 followers. Follow

1 Replies
564 Views

Similar Articles

[PageSpeed] 8

On Monday, December 10, 2001, at 10:30 AM, Wilson, Doug wrote:

>
>> From: Terrence Brannon [mailto:metaperl@mac.com]
>>
>> On Monday, December 10, 2001, at 09:16 AM, Jeff Zucker wrote:
>>
>>> Terrence Brannon wrote:
>>>>
>>>> The following SQL is not parseable by SQL::Statement:
>>>>
>>>> INSERT
>>>>    INTO   thot_log (thot_fk,thot_type_fk,thot_temporality_fk,date)
>>>>    VALUES (?,?,?,CURRENT_TIMESTAMP)
>>
>> What I have is a program which reads a SQL statement from a file.
>> It parses it with SQL::Statement, then it prepares this
>> statement, then does an execute against it with @ARGV. I tried
>> your quoting suggestion. In fact, I put the following 3 different
>> things in the file:
>>
>
> Prepares it and executes it against what database? If its 
> Postgres, then
> Postgres should be parsing it, not SQL::Statement. CURRENT_TIMESTAMP is

if you looked at sub SQL::Catalog::test and the associated 
commentary I made, the answer to this would be clear: the 
above-mentioned subroutine parses the statement with 
SQL::Statement so that it can store statistics about the query. 
Then it prepares and executes it via a routine which returns a 
valid $dbh


>  You can't expect SQL::Statement to handle every
> special thing that every database might include in its 
> featureset/syntax.
>

Is Jeff redoing SQL::Statement with Parse::RecDescent? If so, we 
would conceivably  subclass it with SQL::Statement::Postgres and 
I could add the appropriate new grammar items as I needed them.

0
metaperl
12/10/2001 7:22:21 PM
Reply:

Similar Artilces:

SQL statement and If statement
I've problem, it's in sqlcommand it's in "where" condition, which if it's exist in sql the "ELSE" not work, and if the condition not in sqlcommand the "ELSE" appear, could someone help  it's in selectcommand.CommandText = "SELECT Weekno FROM Weeks where Weekno='" + Weekno.Text + "'" if i delete the condition the " ELSE " appear. otherwise it's not appear whole code Dim myconnection As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\football.mdf;Integrated S...

If Statement combined with SQL statement.
Hi  This is going to sound like quite  a strange question. Basically what I am trying to do is use Membership.GetUser().UserName to get the current user who is logged in and I want to see if that user exists in a table on my database before adding some data to the labels. I figured it should go in the page load part. The name of the table is userteams. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Membership.GetUser().UserName exists in Userteams Then goallie.Text = Select player FROM Userteams Where Username = Membership.getUser().Use...

Adding an IF Statement to the SQL Statement
I have the following tables and SQL statment which works out a league table for me from the given results. I am now trying to add a bit more to this: If the Walkover column = 1 then that row will be a home walkover meaning that the score will be 0(Home Score) - 0(Away Score) but the home team will recieve 3 points, and away team recieves 0 points, win column will be 1 and the played colum will be 1 as well.If the Walkover column = 2 then that row will be a home walkover meaning that the score will be 0(Home Score) - 0(Away Score) but the away team will recieve 3 po...

SQL::Statement v2, consequences to Meta-DBD's (and DBI) and the future of DBI::SQL::Nano
Hi Tim, regarding to our short discussion in #dbi about the future of SQL::Statement and the implications to DBI::SQL::Nano here the open discussion for all. I've want to improve SQL::Statement by design, that means I want to design it from the basics using Design Patterns (especially the Command Pattern and the Factory Pattern - and surely some more). The goal should be, to reduce the amount of conditionals in the code and move them into polymorphism. I want to start with a BNF based parser, which should be more extensible and should allow translations into other dialects by d...

Re: RE: Oracle @name.sql Statements
Here is part of the code that i have previously used to execute SQL scripts. I have just copied part of it here so dont try to run it as it is. But it should give u a good idea. use strict; use DBI; use IPC::Open3; use IO::Select; use POSIX ":sys_wait_h"; my $sqlplus = $ENV{ORACLE_HOME}.'/bin/sqlplus'; my $job_file='xyz.sql'; #Sql Script to execute my @par_list=('abc','4','i'); #list of parameters to be passed to the script my $connect='user@db'; #Database to connect to my $password; #password for the user if (...

Error in statement:Statement is not valid in a namespace.
I am trying to build a webservice which return a dataset and i am getting this error Statement is not valid in a namespace on this line Function GetOrders() As System.Data.DataSet i am pasting my code for your refrence Function GetOrders() As System.Data.DataSet Dim connectionString As String = "server='localhost'; trusted_connection=true; Database='MeMatrixOrders'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT ...

sql statement parsing
hi guys, how can i parse the where clause in an SQL::Statement object instance? $statement = SQL::Statement->new("select 1,2,3 from table where x=y"); now when i do this: $where = $stmt->where(); it gives me error: Can't locate object method "where" via package "SQL::Statement" (perhaps you for got to load "SQL::Statement"?) at blah line 34. any idea? thanks -- Hytham Shehab At 07:34 PM 8/10/02 +0300, Hytham Shehab wrote: > how can i parse the where clause in an SQL::Statement object instance? >$statement = S...

Parsing SQL Statements
Has anyone run across any code or utilities for getting information from complex SQL statements? I want to be able to collect the table names and column names from SQL statements with complex sub-queries. Any help or pointers would be appreciated. joe white joe@lemma.net Joe -- Check out n_cst_sql in the PFC. It has a function that will break up a sql command into individual components (select,from,where,order,...) and another that will recombine the components into a single command. One caveat about this. When I used the 5.0.3 version, it had problems where nested sele...

parsing SQL statement
Anyone having suggestion parsing SQL statement? It should able to parse: BLA BALA BALA... VALUES( 'abcd efg',,999, 'some \"STRING\" and \'STR2\' STR3',,,, 'abcd, def, fghi' ) I'm using tr and then split by "," but it will fall when seeing comma inside the single quote. Thanks. --budhi On Fri, 2008-05-30 at 19:24 +0700, beast wrote: > Anyone having suggestion parsing SQL statement? > > It should able to parse: > > BLA BALA BALA... > > VALUES( > 'abcd efg',,999, 'so...

DBI::Statement parsing
Heya DBI-Users Can anyone help a DBI::Statement newbie with the following problems: 1. When parsing a SQL string, is there a preferred way for initially testing whether the statement did or did not parse successfully? I am currently testing the $stmt->{original_string} element in the return hash from creating the statement object; this element seems to only be instantiated when the parsing succeeds. Would this be considered a valid way to test? Personally, I would prefer a method that could return a (documented) success indication (like $stmt->isOK() == TRUE, or summit ....

Viewing a SPIDs last SQL statement using sqltext()...though sometimes only partial SQL statements are shown
The dbcc sqltext() command seems to allow you to view the last SQL statement issued by an active SPID on the server. However I've noticed that sometimes only part of the SQL statement is returned - does anyone know why this might be, and if so whether it's due to a server configuration. Anyway, here's my notes on how to view the last SQL statement processed: ** How to see the last SQL a SPID has processed -- dbcc traceon(3604) Directs trace output to the client, rather than to the error log 1> dbcc traceon(3604) 2> go DBCC execution completed. If DBCC pr...

sql statement datename and not in equivalent to linq statement
Hi,     How can I translate this sql syntax statement to a linq to sql codes?? I like to separate records that are in first group, monday to saturday but date not in holidays table, and in second group, either sunday or date in holidays table...  /*Sql statement */ /*Mon to Sat group and not a holiday*/ Select * From Deliveries where DateName(dw,DeliveryDate) != 'Sunday' and DeliveryDate Not In (Select Date From Holidays) /*Sun & holiday group*/ Select * From Deliveries where DateName(dw,DeliveryDate) = 'Sunday' or DeliveryDat...

RE: prepare(\$statement) => prepare_cached($statement)
> > I'm pondering deprecating prepare_cached() in favor of requesting a > > cached prepare() by passing the $statement as a reference > to a string. > > > > A big plus from this would be that $dbh->do(\$statement) would then > > also be defined to do a prepare_cached(). > > > > Any comments? > > The use of a string ref doesn't seem very intuitive; just an arbitrary > way of overloading a function in a way that has no intuitive > connotations to its function. I agree. As the user has to consider what he'...

[perl5-dbi/DBI-Test] 471857: merge *.bak pattern from SQL::Statement
----==_mimepart_51fabf251b56b_1d099afd586404f Date: Thu, 01 Aug 2013 13:03:49 -0700 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-ID: <51fabf2524dcd_1d099afd5864130@hookshot-fe4-pe1-prd.aws.github.net.mail> Branch: refs/heads/master Home: https://github.com/perl5-dbi/DBI-Test Commit: 4718570be270e1a88269b7e94dc1ec8e9abdee3c https://github.com/perl5-dbi/DBI-Test/commit/4718570be270e1a88269b7e94dc1ec8e9abdee3c Author: Jens Rehsack <sno@netbsd.org> Date: 2013-08-01 (Thu, 01 Aug 2013) Changed pa...

Web resources about - RE: SQL::Statement cannot parse valid Postgresql statement - perl.dbi.users

Resources last updated: 12/13/2015 9:08:34 AM