delphi + oracle database query

Category: Delphi -> Database Author: long289331082 Date: 2007-01-21 16:15:28
 
long289331082
2007-01-21 16:15:28
I now want to query shd relevant data in the table, where hy (industry) field can be empty, how will empty also check out.
SQL statement that I now will not only check out empty
SQL statement is as follows:
select city_num, b_year, qymc, suizhong.class_name as shuizhong, oper_def.oper_name as sgy
, swjg.jg_name as swjgname , bmhy.hy_name as hy, frxm, hyxm,
0 as total, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12
from shd
inner join suizhong on shd.class_code = suizhong.class_code
inner join oper_def on shd.sgy = oper_def . oper_num
inner join swjg on shd.swjg = swjg.jg_code and shd.city_num = swjg.city_num
inner join bmhy on shd.hy = bmhy.hy_code
where b_year = '2007 'and qzdflag = 0 and sgy = '054033'

trouble to help help!!
urgent!!!!!!!!
Thank you!!!!!

n162189187
2007-01-21 16:29:13
where asked to SQL version. There are many experts
c550499579
2007-01-21 16:40:11
SELECT shd.city_num, shd.b_year, shd.qymc,
suizhong . class_name as shuizhong,
oper_def.oper_name as sgy,
; swjg.jg_name as swjgname,
bmhy.hy_name as hy ,
shd.frxm, shd.hyxm,
0 as ; total,
shd.s1, shd.s2, shd.s3, shd.s4, shd.s5, ; shd.
shd.s6, shd.s7, shd.s8, shd.s9, shd.s10, ; shd.s11, shd.s12
FROM shd, suizhong, oper_def, swjg, bmhy
WHERE ; shd.class_code = suizhong.class_code
AND shd.sgy = oper_def.oper_num ;
AND shd.swjg = swjg.jg_code
AND shd. city_num = swjg.city_num
AND shd.hy (+) = bmhy.hy_code / / used left outer join, it can keep shd table corresponding empty value field; right outer join with this symmetry
AND shd.b_year = '2007 '
AND shd.qzdflag = 0
and shd.sgy = '054033 '
guomaria
2007-01-21 16:46:24

SELECT shd.city_num, shd.b_year , shd.qymc,
suizhong.class_name as shuizhong ,
oper_def.oper_name as sgy,
; swjg.jg_name as swjgname,
; bmhy.hy_name as hy,
; shd.frxm, shd.hyxm,
0 ; as total,
shd.s1, shd.s2, shd . s3, shd.s4, shd.s5, shd.
; shd.s6, shd.s7, shd.s8, shd.s9, shd.s10, ; shd.s11, shd.s12
FROM shd, suizhong, oper_def, swjg, bmhy ;
WHERE shd.class_code = suizhong.class_code
AND shd. sgy = oper_def.oper_num
AND shd.swjg = swjg.jg_code
AND shd.city_num = swjg.city_num
AND shd . hy (+) = bmhy.hy_code / / with a left outer join, it can keep shd table corresponding null value fields; right outer join with this symmetry
AND shd.b_year = '2007 '
AND shd.qzdflag = 0 ;
AND shd.sgy = '054033 '
linqiuzhen1963
2007-01-21 16:58:59
 SELECT shd.city_num, shd.b_year, shd.qymc,
suizhong.class_name as shuizhong,
oper_def.oper_name as sgy,
swjg.jg_name as swjgname,
bmhy.hy_name as hy,
shd.frxm, shd.hyxm,
0 as total,
shd.s1, shd.s2, shd.s3, shd.s4, shd.s5, shd.s6,
shd.s7, shd.s8, shd.s9, shd.s10, shd.s11, shd.s12
FROM shd, suizhong, oper_def, swjg, bmhy
WHERE shd.class_code = suizhong.class_code ;
AND shd.sgy = oper_def.oper_num
AND shd.swjg = swjg.jg_code ;
AND shd.city_num = swjg.city_num
AND shd.hy (+) = bmhy.hy_code / / with a left outer join, it can keep shd table null value in the corresponding field; right outer join with this symmetry
AND shd.b_year = '2007 ' ;
AND shd.qzdflag = 0
AND shd.sgy = '054033 '
huazai110
2007-01-21 17:06:20
 SQL  ?
sanni_dl
2007-01-21 17:19:33

//
SELECT shd.city_num, shd.b_year, shd.qymc,       
              suizhong.class_name as shuizhong,   
              oper_def.oper_name as sgy,   
              swjg.jg_name as swjgname,   
              bmhy.hy_name as hy,   
              shd.frxm, shd.hyxm,   
              0 as total,   
              shd.s1, shd.s2, shd.s3, shd.s4, shd.s5, shd.s6,
              shd.s7, shd.s8, shd.s9, shd.s10, shd.s11, shd.s12           
FROM  shd, suizhong, oper_def, swjg, bmhy               
WHERE shd.class_code = suizhong.class_code           
  AND   shd.sgy      = oper_def.oper_num           
  AND   shd.swjg     = swjg.jg_code               
  AND   shd.city_num = swjg.city_num   
  AND   shd.hy(+)    = bmhy.hy_code   // , shd ;    
  AND   shd.b_year   = '2007'   
  AND   shd.qzdflag  = 0               
  AND   shd.sgy      = '054033'
andy8766
2007-01-21 17:37:30
or not, is empty or check out.
net777
2007-01-21 17:47:20
/ / Thus, even shd table hy field is null, then null value field contains the record will also be displayed; if it is a right outer join, because shd the hy field can not be found in the reference table bmhy value, shd table this record will not be returned.
proposal to deepen understanding inside and outside, left and right to connect the meaning :)
chenglong180
2007-01-21 18:05:36
Do I engage in counter? Change in the past look

SELECT shd.city_num, shd.b_year, shd.qymc,       
              suizhong.class_name as shuizhong,   
              oper_def.oper_name as sgy,   
              swjg.jg_name as swjgname,   
              bmhy.hy_name as hy,   
              shd.frxm, shd.hyxm,   
              0 as total,   
              shd.s1, shd.s2, shd.s3, shd.s4, shd.s5, shd.s6,
              shd.s7, shd.s8, shd.s9, shd.s10, shd.s11, shd.s12           
FROM  shd, suizhong, oper_def, swjg, bmhy               
WHERE shd.class_code = suizhong.class_code           
  AND   shd.sgy      = oper_def.oper_num           
  AND   shd.swjg     = swjg.jg_code               
  AND   shd.city_num = swjg.city_num   
  AND   shd.hy       = bmhy.hy_code(+)      
  AND   shd.b_year   = '2007'   
  AND   shd.qzdflag  = 0               
  AND   shd.sgy      = '054033'
swordmandan
2007-01-21 18:13:48
Your empty record is to filter out other conditions
yangguanglou
2007-01-21 18:25:34
Well, you can now the
Thank!
trouble you help me see another question
I had a query form,
more query conditions: states and cities, units, tax authorities, tax management staff, taxes, trade, industry breakdown
these conditions are using the drop down combo box (combobox) to display The.
requirement is now:
when I use the "Chengdu City" User When logged into the system, the form of the state and city was selected as the "Chengdu" corresponding combo box on the back of the unit can only display "Chengdu unit"
when I used the "Sichuan provincial" when the user login system, the form of the state and city was selected as the "Sichuan" corresponding combo box on the back of the unit can only display the "Sichuan units"
well behind the combo box. State and municipal joint units; units cascade tax authorities; tax authorities cascade tax management staff.

I do not know how to achieve. Please also Gaoshoubangbangmang!

Thank you!

Urgent! ! ! ! ! ! ! ! !

Thank you! ! !

wangshasha1107
2007-01-21 18:32:54
procedure TForm2.FormShow (Sender: TObject);
var s1, s2, s3, s4, s5, s6, z1, z2: string;
regisname: Tregistry;
Y, M , D: Word;
begin
/ / Form_xz.Top: = 100000;
DecodeDate (Date, Y, M, D) ;
spinedit1.Value: = Y;
spinedit2.Value: = M;
; spinedit3.Value: = M;
Regisname: = Tregistry.create;
Regisname.openkey ('hxsoft \ czy', true);
z1: = regisname.readstring ('dm') ;
z2: = regisname.readstring ('Jg');

/ / state and city
LJClientDataSet2.Close;
LJClientDataSet2.Provider.DataRequest (
'select zds_code, zds_name ; from dsbm.bmzds '+
' where zds_code in (select ; substr (city_num, 1,4) from dsbm.oper_def where oper_num = '+ z1 +') / ');
LJClientDataSet2.Open;
while not LJClientDataSet2.Eof do
begin
combobox1.Items.Add (LJClientDataSet2.fieldbyname ('zds_code'). asstring + '[' + LJClientDataSet2.fieldByName ('zds_name'). asstring + ']');
LJClientDataSet2 . Next;
end;

This is my code, but it will go wrong.
trouble pointing.
Thank you! !

error message is:
project project1.exe raised exception class EOLeException with message 'General SQL error. ORA-01722: invalid ; number '. Precess stopped Use Step or Run to continue.

I do not know why I

inside the database using SQL: select * from bmzds where zds_code in (select substr (city_num, 1,4) from ; dsbm.oper_def where oper_num = '054033 ')
can check out the results
z1 = '054033'
fgfdf
2007-01-21 18:36:26
use the drop-down list box OnChange event binding database implementation:
when the first drop-down box is "Chengdu", the OnChange event of the drop-down box to query the appropriate subordinate unit display to the second drop-down box.
/ / reference to the following code

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  with ComboBox2, TADOQuery.Create(nil) do
  try
    Connection := ADOConnection1; //ADO
    Close;
    SQl.Text := ' SELECT   FROM   ' +
                ' WHERE   = ' + QuotedStr('ChengDu');
                // ' WHERE   = ' + QuotedStr(' ');
    Open;

    ComboBox2.Clear;
    while not Eof do
    begin
      ComboBox2.Items.Add(FieldByName(' ').AsString);
      Next;
    end;
    Close;
  finally
    Free;
  end;
end;
xiaoliyi1984
2007-01-21 18:52:11
'General SQL ; error. ORA-01722: invalid number '
This error occurs because: a table involved in the query field is defined as the value type - according to my observation, it may be oper_num, but behind you with the SQL statement is a string (where oper_num = '+ z1 +' ...), check
shanxinbb
2007-01-21 19:09:58
learn some top