在DATABASE抓到值後 如何傳給DELPHI |
答題得分者是:sos_admin
|
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
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 發送簡訊給我 |
|
timhuang
尊榮會員 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
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 '); |
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
將 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 發送簡訊給我 |
|
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
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 發送簡訊給我 |
|
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
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 發送簡訊給我 |
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 發送簡訊給我 |
|
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
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 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
|
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
|
cashxin2002
版主 發表:231 回覆:2555 積分:1937 註冊:2003-03-28 發送簡訊給我 |
|
sos_admin
版主 發表:121 回覆:697 積分:768 註冊:2003-07-23 發送簡訊給我 |
如果您用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 發送簡訊給我 |
|
shiungyi
一般會員 發表:14 回覆:33 積分:9 註冊:2003-05-16 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |