help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] SQL query as input table - MathProg


From: glpk xypron
Subject: Re: [Help-glpk] SQL query as input table - MathProg
Date: Sat, 18 Sep 2010 00:46:52 +0200

Hello Andrew,

I suggest to apply the patch below to glpmpl01.c. This allows the
column names in the table statement to be enclosed in apostrophes
if they contain special characters, e.g.

set R;
param area{R};
table tab IN "ODBC" 'DSN=glpk,UID=glpk,PWD=gnu'
'SELECT * FROM tbl' :
R <- ['région de production'], area ~ 'surface irriguée';

Best regards

Xypron

--- ../src/glpk-4.44/src/glpmpl01.c     2010-06-03 08:00:00.000000000 +0000
+++ glpmpl01.c  2010-09-17 22:28:30.000000000 +0000
@@ -4077,6 +4077,10 @@
          /* parse field name */
          if (mpl->token == T_NAME)
             ;
+#if 1 /* 17/IX-2010, allow field name with space or special character */
+            else if (mpl->token == T_STRING)
+                ;
+#endif
          else if (is_reserved(mpl))
             error(mpl,
                "invalid use of reserved keyword %s", mpl->image);
@@ -4139,6 +4143,10 @@
             /* parse field name */
             if (mpl->token == T_NAME)
                ;
+#if 1 /* 17/IX-2010, allow field name with space or special character */
+            else if (mpl->token == T_STRING)
+                ;
+#endif
             else if (is_reserved(mpl))
                error(mpl,
                   "invalid use of reserved keyword %s", mpl->image);
@@ -4187,6 +4195,10 @@
             /* parse field name */
             if (mpl->token == T_NAME)
                ;
+#if 1 /* 17/IX-2010, allow field name with space or special character */
+            else if (mpl->token == T_STRING)
+                ;
+#endif
             else if (is_reserved(mpl))
                error(mpl,
                   "invalid use of reserved keyword %s", mpl->image);


-------- Original-Nachricht --------
> Datum: Thu, 16 Sep 2010 20:37:35 +0200
> Betreff: Re: [Help-glpk] SQL query as input table - MathProg

> Hello Noli,
> 
> > what is wrong with this script.
> > 
> > set S2, dimen 2;
> > 
> > table tab IN "ODBC" 'Driver=SQLITE3;Database=Otago_p.sqlite;'
> > 'SELECT tblCroptype.Croptype, tblData.Age tblData.Area'
> > 'FROM tblCroptype JOIN tblData ON tblData.Croptype =
> > tblCroptype.Croptype':
> > S2 <- [tblCroptype.Croptype, tblData.Age], Area ~ tblData.Area
> The operator '.' is only supported for outputing properties of
> variables and constraints.
> 
> In many database systems column names may contain spaces and other
> special characters, e.g. in MySQL I can write:
> CREATE TABLE tblCroptype (
>   `Crop Type` TEXT(40),
>   PRIMARY KEY( `Crop Type`(40) )
>   );
> 
> I suggest Andrew should change the coding to allow fieldnames to be
> enclosed in apostrophes, e.g.
> S2 <- ['tblCroptype.Crop Type', 'tblData.Age'], Area ~ 'tblData.Area'
> 
> As workaround you can use alias names for the columns, see below.
> 
> A bug for multiline SQL statements in GLPK 4.44 has been reported,
> please apply the corresponding patch which has been posted to this
> list and is included in WinGLPK 4.44-1.
> 
> Best regards
> 
> Xypron

-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail



reply via email to

[Prev in Thread] Current Thread [Next in Thread]