ADODB текст запроса из файла #610858


#0 by vbh
можно ли исполнить sql запрос из файла, например "c:zapros.sql" т.е. не использовать а что-нибудь типа задача исполнить запрос из файла c:zapros.sql и загрузить его в ТЗ
#1 by shuhard
нет
#2 by Wobland
Опен(ТекстДок.ПолучитьТекст) тогда уж
#3 by vbh
работает но 1ска вылетает (
#4 by shuhard
текст запроса  в студию
#5 by vbh
AI.ANAME AS ADVCOMMENT,    AI.POSTDISPACH,    (select t.SFNUM from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCNUM,    (select t.tdate from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCDATE  from    Accounts A, Accountsinfo AI, Servicetypes ST,      (select distinct S.ID,S.SRVTYPEID from services S) S,(select '' AS "UNAME",1 AS "SRVTYPEID" from dual /*union select '????. ?????: ',-1 from dual*/) SS  where  A.ID=AI.ID AND S.ID=A.ID AND    AI.ANAME AS ADVCOMMENT,    AI.CONTRACTNUM,    P.SUMM as SUMM,    AI.SFNEED,    P.QUANTITY as AMOUTH,    AI.POSTDISPACH,    (select t.SFNUM from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCNUM,    (select t.tdate from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCDATE  from    Accounts A, Accountsinfo AI, Servicetypes ST, services SS, payments P      --(select distinct S.ID,S.SRVTYPEID from ) S,(/*select '' AS "UNAME",1 AS "SRVTYPEID" from dual union*/ select '????. ?????: ' AS "UNAME",-1 AS "SRVTYPEID" from dual) SS  where  AND P.PDATE between :SD AND :ED)
#6 by vbh
в жабе запрос исполняется на ура
#7 by Wobland
явно не текст запроса
#8 by vbh
да, там на русском, скопировалось коряво, сейчас подправлю
#9 by vbh
AI.ANAME AS ADVCOMMENT,    AI.POSTDISPACH,    (select t.SFNUM from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCNUM,    (select t.tdate from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCDATE  from    Accounts A, Accountsinfo AI, Servicetypes ST,      (select distinct S.ID,S.SRVTYPEID from services S) S,(select '' AS "UNAME",1 AS "SRVTYPEID" from dual /*union select 'Абон. плата: ',-1 from dual*/) SS  where  A.ID=AI.ID AND S.ID=A.ID AND    AI.ANAME AS ADVCOMMENT,    AI.CONTRACTNUM,    P.SUMM as SUMM,    AI.SFNEED,    P.QUANTITY as AMOUTH,    AI.POSTDISPACH,    (select t.SFNUM from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCNUM,    (select t.tdate from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCDATE  from    Accounts A, Accountsinfo AI, Servicetypes ST, services SS, payments P      --(select distinct S.ID,S.SRVTYPEID from ) S,(/*select '' AS "UNAME",1 AS "SRVTYPEID" from dual union*/ select 'Абон. плата: ' AS "UNAME",-1 AS "SRVTYPEID" from dual) SS  where  AND P.PDATE between :SD AND :ED)
#10 by Wobland
AS "UNAME" что за кавычки в запросе?
#11 by vbh
согласен для 1с-ки они не приемлимы, но оракл их глотает на ура. Сейчас попробую без кавычек
#12 by vbh
не помогло, 1с-ка по-прежнему вылетает запрос без кавычек SELECT * from  (select    SS.SRVTYPEID*ST.SRVTYPEID AS SRVTYPEID,    SS.UNAME||ST.UNAME AS UNAME,    A.ID,      AI.ANAME AS ADVCOMMENT,    AI.POSTDISPACH,    (select t.SFNUM from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCNUM,    (select t.tdate from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCDATE  from    Accounts A, Accountsinfo AI, Servicetypes ST,      (select distinct S.ID,S.SRVTYPEID from services S) S,(select '' AS UNAME,1 AS SRVTYPEID from dual /*union select 'Абон. плата: ',-1 from dual*/) SS  where  A.ID=AI.ID AND S.ID=A.ID AND  select    -1*ST.SRVTYPEID AS SRVTYPEID,    'Абон. плата: '||ST.UNAME AS UNAME,    A.ID,      AI.ANAME AS ADVCOMMENT,    AI.CONTRACTNUM,    P.SUMM as SUMM, --    0 as DUR, --    'шт' as DUR_UNIT,    AI.SFNEED,    P.QUANTITY as AMOUTH,    AI.POSTDISPACH,    (select t.SFNUM from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCNUM,    (select t.tdate from transactions t where t.id = a.id and t.tdate = (select max(t.tdate) from transactions t where t.id = a.id) and t.SFNUM is not null and rownum=1) as DOCDATE  from    Accounts A, Accountsinfo AI, Servicetypes ST, services SS, payments P      --(select distinct S.ID,S.SRVTYPEID from ) S,(/*select '' AS UNAME,1 AS SRVTYPEID from dual union*/ select 'Абон. плата: ' AS UNAME,-1 AS SRVTYPEID from dual) SS  where  A.ID=AI.ID  AND P.PDATE between :SD AND :ED)
#13 by vbh
видимо на параметрах даты глючит between :SD AND :ED
#14 by vbh
переделал параметры всё заработало на может кому пригодится...
#15 by vbh
Wobland,shuhard - Спасибо!
#16 by Wobland
двоеточия мешались? ну я всё не глядел, больно страшно. мог бы после кавычек сразу догадаться ;)
#17 by vbh
вот я и догадался после кавычек )))
#18 by shuhard
Если НЕ Recordset.EOF Тогда может  Если НЕ Recordset.BOF Тогда
#19 by vbh
да вроде верно "current record position is after the last record"
#20 by vbh
блин...опять не туда смотрю верно. если не 1я запись то на первую.   shuhard спасибо.
#21 by Wobland
я вижу тут люди знают больше меня.. скажите уж по пути, что не так? после открытия base.eof сразу истина.
#22 by vbh
не буду спорить, не силён в ADODB задача исполнить запрос из файла c:zapros.sql и загрузить его в ТЗ как то так получилось
Тэги: 1С 8
Ответить:
Комментарии доступны только авторизированным пользователям

В этой группе 1С