sqlstr:='select COURSENAME||'' ''||CLASSROOMNAME cc_name '+
' from '+
//课程名 上课教室
' (SELECT a.COURSENAME,c.NAME CLASSROOMNAME,1 ord,a.TEACHINGCLASSID,a.TERMID '+
' FROM CARESULT a,CLASSROOM c '+
' where a.CLASSROOMID=c.CLASSROOMID(+) and WEEKDAYno=''1'' and CLASSNO=''1'' and '+
' a.TERMID='''+termID+''' and TEACHINGCLASSID in '+
' (select TEACHINGCLASSID from Course_Classes where classNO='''+dm.Qry_CaClasses.FieldByName('classNO').AsString+''' ) '+
' GROUP BY a.COURSENAME,c.NAME ,a.TEACHINGCLASSID,a.TERMID '+
' union '+
//上课周次 上课老师
' SELECT Fun_Ca_Getweekno(a.WEEKDAYNO,a.CLASSNO,a.TEACHINGCLASSID) week,b.EMPLOYEENAME,2 ord, '+
' a.TEACHINGCLASSID,a.TERMID '+
' FROM CARESULT a,V_CA_TEACHER b '+
' where a.TEACHINGCLASSID=b.TEAMID(+) and WEEKDAYno=''1'' and CLASSNO=''1'' '+
' and a.TERMID='''+termID+''' and TEACHINGCLASSID in '+
' (select TEACHINGCLASSID from Course_Classes where classNO='''+dm.Qry_CaClasses.FieldByName('classNO').AsString+''' ) '+
' GROUP BY a.WEEKDAYNO,a.CLASSNO,a.COURSENAME,b.EMPLOYEENAME,a.TEACHINGCLASSID,a.TERMID) '+
' ORDER BY TERMID,TEACHINGCLASSID,ord ';
dm.Qry_select.Close;
dm.Qry_select.SQL.Clear;
dm.Qry_select.SQL.Add('sqlstr');
dm.Qry_select.Open ;上面的代码错误提示:无效SQL语句
可是我的SQL在oracle中执行没有问题呀
' from '+
//课程名 上课教室
' (SELECT a.COURSENAME,c.NAME CLASSROOMNAME,1 ord,a.TEACHINGCLASSID,a.TERMID '+
' FROM CARESULT a,CLASSROOM c '+
' where a.CLASSROOMID=c.CLASSROOMID(+) and WEEKDAYno=''1'' and CLASSNO=''1'' and '+
' a.TERMID='''+termID+''' and TEACHINGCLASSID in '+
' (select TEACHINGCLASSID from Course_Classes where classNO='''+dm.Qry_CaClasses.FieldByName('classNO').AsString+''' ) '+
' GROUP BY a.COURSENAME,c.NAME ,a.TEACHINGCLASSID,a.TERMID '+
' union '+
//上课周次 上课老师
' SELECT Fun_Ca_Getweekno(a.WEEKDAYNO,a.CLASSNO,a.TEACHINGCLASSID) week,b.EMPLOYEENAME,2 ord, '+
' a.TEACHINGCLASSID,a.TERMID '+
' FROM CARESULT a,V_CA_TEACHER b '+
' where a.TEACHINGCLASSID=b.TEAMID(+) and WEEKDAYno=''1'' and CLASSNO=''1'' '+
' and a.TERMID='''+termID+''' and TEACHINGCLASSID in '+
' (select TEACHINGCLASSID from Course_Classes where classNO='''+dm.Qry_CaClasses.FieldByName('classNO').AsString+''' ) '+
' GROUP BY a.WEEKDAYNO,a.CLASSNO,a.COURSENAME,b.EMPLOYEENAME,a.TEACHINGCLASSID,a.TERMID) '+
' ORDER BY TERMID,TEACHINGCLASSID,ord ';
dm.Qry_select.Close;
dm.Qry_select.SQL.Clear;
dm.Qry_select.SQL.Add('sqlstr');
dm.Qry_select.Open ;上面的代码错误提示:无效SQL语句
可是我的SQL在oracle中执行没有问题呀
//去掉''引號,sqlstr本來是變量,不是字串
dm.Qry_select.SQL.Add('sqlstr'); //去掉''
dm.Qry_select.SQL.Add('sqlstr');--这个当然有问题了,你把字符窜'sqlstr'传进去了。
dm.Qry_select.SQL.Add(sqlstr);--应该这样。
dm.Qry_select.SQL.Add('sqlstr');这里有问题,有了''就变成引用sqlstr这个字符串了。你去掉引号后再试试。
dm.Qry_select.SQL.Add('sqlstr');
=======〉
dm.Qry_select.SQL.Add(sqlstr);
在外网上就有限制
不过在这错误很明显:
dm.Qry_select.SQL.Add('sqlstr');
换成
dm.Qry_select.SQL.Add(sqlstr);
--
做什么呀
要这么长的SQL??
--
对呀,这么长的SQL为什么不写在后台
SQL.add(......);
SQL.add(......);