線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1420
推到 Plurk!
推到 Facebook!

在DATABASE抓到值後 如何傳給DELPHI

答題得分者是:sos_admin
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-08-25 16:37:52 IP:163.29.xxx.xxx 未訂閱
DEAR ALL 請問小弟下了SQL指令 Query1.Close; Query1.SQL.Clear; Query1.SQL.Add('Select* from BGBILP, '); Query1.SQL.Add(' (select max(index_key) max_a from bgbilp) t2 '); Query1.SQL.Add('where bgbilp.index_key = t2.max_a '); Query1.ExecSQL; 接著要如何將值傳給STRING A1 謝謝 發表人 - shiungyi 於 2003/08/25 16:44:53
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-08-25 17:51:06 IP:63.84.xxx.xxx 未訂閱
您好﹗    請問要傳哪個值﹖ Select *... 會回傳的欄位名是什么呢﹖ 另外﹐回傳查詢請使用><>===================== 努力,相信會獲得美麗! 忻晟 發表人 -
------
忻晟
timhuang
尊榮會員


發表:78
回覆:1815
積分:1608
註冊:2002-07-15

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-08-25 17:54:49 IP:203.95.xxx.xxx 未訂閱
hi, 若是有傳回資料的 query 時, 必須使用 Open Method 來傳回, 否則是無法取得資料的, 如下:    
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Select* from BGBILP, ');
Query1.SQL.Add(' (select max(index_key) max_a from bgbilp) t2 ');
Query1.SQL.Add('where bgbilp.index_key = t2.max_a ');
Query1.ExecSQL;
Query1.Open;
A1 := Query1.FieldByName('col_name').AsString;
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-08-26 11:34:15 IP:163.29.xxx.xxx 未訂閱
將 Query1.ExecSQL; 改成 Query1.open;後 出現error message ProjectBIL1.exe raised exception calss EDBEngineError with message '不正確的使用關鍵字' Token:select Link Number:2'.Process stopped 這程式的用意是要在bgbilp table中找出index_key最大的一筆record 取得c_fvh_id,t_rele_time這兩個欄位的值 將資料傳至StoredProcedure
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-08-26 12:14:06 IP:63.84.xxx.xxx 未訂閱
您好﹗    有些不了解您需要的SQL﹐能否描述得具體一些﹒ 因為僅從您以上描述的要求來看﹐似乎><>===================== 努力,相信會獲得美麗! 忻晟 發表人 -
------
忻晟
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-08-26 13:35:27 IP:163.29.xxx.xxx 未訂閱
DEAL cashxin2002 依照您的改法 Query1.Close; Query1.SQL.Add('Select c_fvh_id, t_rele_time From bgbilp' ); Query1.SQL.Add('Where index_key = (Select Max(index_key) from bgbilp)'); Query1.Open; 出現MESSAGE為 ProjectBIL1.exe raised execption calss EDBEngineError with message'沒有支援此功能' Token: NESTED SELECT.Process stopped. 這程式的用意是要在CTC資料庫中的bgbilp table 找出index_key最大的一筆record 取得c_fvh_id,t_rele_time這兩個欄位的值 將資料傳至StoredProcedure 再以c_fvh_id,t_rele_time為key值 而StoredProcedure以此二欄位為key值 至V4Trx的ECLMFV1,ECLMFVH這兩table中搜尋資料 再回傳至DELPHI 謝謝 發表人 - shiungyi 於 2003/08/26 14:17:46
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-08-26 14:08:33 IP:63.84.xxx.xxx 未訂閱
Hi.    I test this SQL in Access Database, It's ok? what's the kind of your Database?    Please add Query1.SQL.Clear; after Query1.Close; and try it again! ===================== 努力,相信會獲得美麗! 忻晟
------
忻晟
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-08-26 14:37:23 IP:163.29.xxx.xxx 未訂閱
SQL Server2000 我在程式中加上Query1.SQL.SaveToFile('c:\insert10.txt'); 然後將此程式置於SQL Query Analyzer去run 結果正常 我想SQL語法應該是沒錯 可是在DELPHI RUN時 出現MESSAGE為 ProjectBIL1.exe raised execption calss EDBEngineError with message'沒有支援此功能' Token: NESTED SELECT.Process stopped.
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-08-26 14:50:55 IP:63.84.xxx.xxx 未訂閱
Hi.    Please split your SQL and test them in Delphi. Then Looking for which SQL have this error message. 1. Query1.SQL.Add('Select c_fvh_id, t_rele_time From bgbilp'); 2. Query1.SQL.Add('Select Max(index_key) from bgbilp');    ===================== 努力,相信會獲得美麗! 忻晟
------
忻晟
sos_admin
版主


發表:121
回覆:697
積分:768
註冊:2003-07-23

發送簡訊給我
#10 引用回覆 回覆 發表時間:2003-08-26 15:07:12 IP:61.155.xxx.xxx 未訂閱
select * from bgbilp where index_key in (select max(index_key) from bgbilp) try~~
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#11 引用回覆 回覆 發表時間:2003-08-26 15:08:22 IP:163.29.xxx.xxx 未訂閱
Please split your SQL and test them in Delphi. Then Looking for which SQL have this error message. 1. Query1.SQL.Add('Select c_fvh_id, t_rele_time From bgbilp'); 2. Query1.SQL.Add('Select Max(index_key) from bgbilp'); USE NO1 正常 USE NO2 Error Message '資料表是唯讀的'
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#12 引用回覆 回覆 發表時間:2003-08-26 15:12:59 IP:163.29.xxx.xxx 未訂閱
[quote] select * from bgbilp where index_key in (select max(index_key) from bgbilp) try~~ 依然出現"沒有支援此功能" 謝謝
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#13 引用回覆 回覆 發表時間:2003-08-26 15:17:37 IP:147.8.xxx.xxx 未訂閱
Using BDE? Perhaps ADO is better... anyway I guess you need to use a pass through query... In your alias, set SQLQRYMODE to SERVER.
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#14 引用回覆 回覆 發表時間:2003-08-26 15:21:01 IP:63.84.xxx.xxx 未訂閱
您好﹗    Query1.Close; Query1.Clear; Query1.SQL.Add('Select c_fvh_id, t_rele_time From bgbilp' ); Query1.SQL.Add('Where index_key = (Select Max(index_key) index_key from bgbilp)'); Query1.Open;    參考看看﹗    ===================== 努力,相信會獲得美麗! 忻晟
------
忻晟
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#15 引用回覆 回覆 發表時間:2003-08-26 15:24:29 IP:163.29.xxx.xxx 未訂閱
[quote] Using BDE? Perhaps ADO is better... anyway I guess you need to use a pass through query... In your alias, set SQLQRYMODE to SERVER. 抱歉 我目前用的是DELPHI4.0 而且客戶堅持要用StoredProcedure
cashxin2002
版主


發表:231
回覆:2555
積分:1937
註冊:2003-03-28

發送簡訊給我
#16 引用回覆 回覆 發表時間:2003-08-26 15:29:14 IP:63.84.xxx.xxx 未訂閱
您好﹗    小弟比較贊同William版主的建議﹐使用ADO來得方便許多﹐可以擺脫BDE系統設定中那么多的參數﹒    ===================== 努力,相信會獲得美麗! 忻晟
------
忻晟
sos_admin
版主


發表:121
回覆:697
積分:768
註冊:2003-07-23

發送簡訊給我
#17 引用回覆 回覆 發表時間:2003-08-26 15:30:22 IP:61.155.xxx.xxx 未訂閱
如果您用bde,请确认您的tdatabase已经正常连接数据库。 如果能够正确连接,那么 select * from bgbilp where index_key in (select max(index_key) from bgbilp) 或 select * from bgbilp where index_key =(select max(index_key) from bgbilp) 不会出现错误的,我试验过! 用ado方法也测试过,至少说sql语法肯定没有问题;那么可能出现您的设置方面的不足,建议重新设置;最好能将您的机器重新启动一下哦!
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#18 引用回覆 回覆 發表時間:2003-08-26 15:44:14 IP:147.8.xxx.xxx 未訂閱
I mean setting your DB alias for pass through query mode... I wonder whether you have a live query (i.e. RequestLive=True) or not? I don't think you can get a live query using nested select 
shiungyi
一般會員


發表:14
回覆:33
積分:9
註冊:2003-05-16

發送簡訊給我
#19 引用回覆 回覆 發表時間:2003-08-26 16:06:47 IP:163.29.xxx.xxx 未訂閱
DEAR ALL 遵照sos_admin的指示重新設定後 程式已正常運作 發現是因Query1的RequestLive:=True 才導致錯誤 因為All multi-table queries return read-only result sets 只是小弟不太懂 既然return read-only result 為什麼RequestLive可以自行修改 謝謝
系統時間:2024-09-08 1:08:38
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!