Query not populated
Posted: Mon 05 Aug 2013 22:36
Hello,
I have a problem in running a query. The following is the code:
a:='Select Array_To_String(Array(( Select Query1.customer_code From (Select tbl_invoices.customer_code, Sum(tbl_invoices.balance_amount * tbl_currencies.exchange_rate) As AROverdue From tbl_invoices Inner Join tbl_currencies On tbl_invoices.currency = tbl_currencies.id Where tbl_invoices.update_date = Current_Date And tbl_invoices.due_date <= Current_Date Group By tbl_invoices.customer_code)Query1 Left Join tbl_customer_master_data On tbl_customer_master_data.customer_code = Query1.customer_code , (Select 100000 as fixedvalue)Query2 Where Query1.AROverdue>Query2.fixedvalue And (tbl_customer_master_data.collection_category = 787 And tbl_customer_master_data.collection_step = 1) Group By Query1.customer_code , tbl_customer_master_data.collection_category,tbl_customer_master_data.collection_step )),''~'') AS customerids'
dummy2:=TPgQuery.Create(nil);
dummy2.Connection:=DM.PgConnection1;
dummy2.Close;
dummy2.SQL.Clear;
dummy2.SQL.Text:=a;
dummy2.Open;
b:=dummy2.FieldByName('customerids').AsString;
after the "Open" instruction the query shows dummy2.recordcount=1 but there is no data in the field "customerids" nor in the variable "b".
If I run the same query in PGAdmin III I have the query correctly populated with the relevant data.
Am I doing anything incorrectly ?
Many thanks
Pio Pio
I have a problem in running a query. The following is the code:
a:='Select Array_To_String(Array(( Select Query1.customer_code From (Select tbl_invoices.customer_code, Sum(tbl_invoices.balance_amount * tbl_currencies.exchange_rate) As AROverdue From tbl_invoices Inner Join tbl_currencies On tbl_invoices.currency = tbl_currencies.id Where tbl_invoices.update_date = Current_Date And tbl_invoices.due_date <= Current_Date Group By tbl_invoices.customer_code)Query1 Left Join tbl_customer_master_data On tbl_customer_master_data.customer_code = Query1.customer_code , (Select 100000 as fixedvalue)Query2 Where Query1.AROverdue>Query2.fixedvalue And (tbl_customer_master_data.collection_category = 787 And tbl_customer_master_data.collection_step = 1) Group By Query1.customer_code , tbl_customer_master_data.collection_category,tbl_customer_master_data.collection_step )),''~'') AS customerids'
dummy2:=TPgQuery.Create(nil);
dummy2.Connection:=DM.PgConnection1;
dummy2.Close;
dummy2.SQL.Clear;
dummy2.SQL.Text:=a;
dummy2.Open;
b:=dummy2.FieldByName('customerids').AsString;
after the "Open" instruction the query shows dummy2.recordcount=1 but there is no data in the field "customerids" nor in the variable "b".
If I run the same query in PGAdmin III I have the query correctly populated with the relevant data.
Am I doing anything incorrectly ?
Many thanks
Pio Pio