Skip to Content.
Sympa Menu

freetds - Re: [freetds] parsing T-SQL with flex & yacc (was: segfaultinPerl'sEmail::Store when using freetds)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Зверев Виталий Борисович <VZverev AT genesis.spb.ru>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] parsing T-SQL with flex & yacc (was: segfaultinPerl'sEmail::Store when using freetds)
  • Date: Tue, 21 Feb 2006 15:09:03 +0300

Hello James, Frediano.
I'm still digging of placeholder's parser and begin thinking about
correlations with Pandor's box. Maybe you kindly prompt me how to solve one
puzzle:
There is next T-SQL batch:

select count(1) as cnt ,type into #temp1 from sysobjects group by type ;
select cnt,type from #temp1 where cnt > ?

How to get datatype of placeholder (#temp1.cnt)?
Obviously solution exists (like SQLDescribeParam)

SQLPrepare(hstmt, ( unsigned char * )"select count(1) as cnt ,type into
#temp1 from sysobjects group by type ; select cnt,type from #temp1 where cnt
> ? ", SQL_NTS);
SQLDescribeParam(hstmt,1, &DataType, &ParamSize, &DecimalDigits, &Nullable);

but...
The native MS odbc driver give me an answer ;) :
SET FMTONLY ON select cnt from sysobjects where 1=2 SET FMTONLY OFF
Error :[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name
'cnt'.

Couldn't you check this behavior for another product combinations, say Merant
ODBC across Shiloh, Yukon or ASE?

Sincerely yours.
-------------------------------------------------------
Vitaly Zverev, OCP DBA 8&8i
Oracle E-Business Suite &
Infiniband Linux Cluster Administrator
Genesis Ltd., St.Petersburg, Russia



> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of James
> K. Lowden
> Sent: Wednesday, November 16, 2005 7:29 AM
> To: FreeTDS Development Group
> Subject: Re: [freetds] parsing T-SQL with flex & yacc (was:
> segfaultinPerl'sEmail::Store when using freetds)
>
> ú×ÅÒÅ× ÷ÉÔÁÌÉÊ âÏÒÉÓÏ×ÉÞ wrote:
> > James, Frediano,
> > thanks for comments in friendly atmosphere (I'm not a
> native English
> > writer, so excuse me my ugly essay)
>
> When I can apologize for my Russian, I'll pass judgement on
> your English, Vitaly. :-)
>
> You're undertaking something ambitious and potentially very
> useful. Being friendly is pretty easy by comparison.
>
> I am hoping that you will write a function that will accept
> an SQL string, find the placeholders, and return an array of
> structures. Each structure will contain:
>
> database
> system object name
> system object type (S/U/P/V/TR, per sysobjects)
> column/parameter name
>
> In this query, for example:
>
> select * from systypes where name = ?
>
> The answer would be:
>
> database = NULL
> object name = 'systypes'
> object type = 'S'
> column/parameter name = 'name'
>
> The caller of your function will formulate a query for the
> server about the datatype of each placeholder. To do that it
> may need to know if the placeholder is a parameter to a
> stored procedure or function, or will be compared to a
> column. Not everything can be found in syscolumns.
>
> > BTW, FireBird like a Sybase has open interface to
> parametrised Dinamic
> > SQL parser & ODBC driver (with SQLDescribeParam implementation)
> >
> http://cvs.sourceforge.net/viewcvs.py/*checkout*/firebird/fire
> bird2/src/dsql/parse.y?rev=1.193.
> >
>
> Yep. Firebird has a very different design and SQL. I know a
> little about it. I contributed patches that made sure it
> runs on NetBSD.
>
> Regards,
>
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>



Archive powered by MHonArc 2.6.24.

Top of Page