Home » Developer & Programmer » Forms » Maintain user input's visibility
icon6.gif  Maintain user input's visibility [message #132611] Mon, 15 August 2005 03:17 Go to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi all,

I created a form which allowed user to enter input (eg. 2005) in a field to perform query.
I would like the user input (2005) to remain visible in the field after I execute query.
How should I do that?
Thank you.

Regards,
Aaron
Re: Maintain user input's visibility [message #132712 is a reply to message #132611] Mon, 15 August 2005 18:48 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Aaron,

Are you retrieving any records when you search using 2005?

I don't think it is possible to show the 2005 if no records are retrieved.

David
icon5.gif  Re: Maintain user input's visibility [message #132718 is a reply to message #132712] Mon, 15 August 2005 19:32 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
David,

I'm retrieving records using some parameters including item_z (eg: 2005). How can I enable the user input to be visible after the query is executed?
Thanks a lot.

Regards,
Aaron
Re: Maintain user input's visibility [message #132720 is a reply to message #132718] Mon, 15 August 2005 19:51 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I don't understand your problem. I 'hear' that you have succesfully retrieved some records. Are you saying that the item_z field is empty upon display. If so, I think you may still have an assignment to item_z in your post-query.

David
icon3.gif  Re: Maintain user input's visibility [message #132721 is a reply to message #132720] Mon, 15 August 2005 19:59 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

What I meant is something like below:

User key in year '2005' and executes query. After the query is executed, the records will be displayed. I would like to display the '2005' as well, as everytime the query is executed, the user input (2005) will disappear.

Thank you.

Regards,
Aaron
Re: Maintain user input's visibility [message #132725 is a reply to message #132721] Mon, 15 August 2005 20:42 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay ... item_z is 'empty' on display - correct? Please answer - yes or no.

Please post the contents of the post-query trigger.

Verify the properties for item_z. Are they different to the other fields that are displaying correctly? For example, is query-only set to 'true' for item_z? Please answer this question in your reply.

David
icon5.gif  Re: Maintain user input's visibility [message #132733 is a reply to message #132725] Mon, 15 August 2005 21:25 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
David,

Okay ... item_z is 'empty' on display - correct? Please answer - yes or no.
--YES

Verify the properties for item_z. Are they different to the other fields that are displaying correctly?
--No difference

For example, is query-only set to 'true' for item_z?
--Query-only: NO

Below is the POST-QUERY:
DECLARE
CURSOR lookup_table IS
SELECT c.item_a,
a.item_b,
c.item_f,
FROM table_a,
table_c
WHERE a.item_a = c.item_a
AND c.item_c = :table_b.item_c;
BEGIN
OPEN lookup_table;

FETCH lookup_table
INTO :table_b.item_a,
:table_b.item_b,
:table_b.item_f;

CLOSE lookup_table;

END;

Please refer to attachment, thanks!!!

Regards,
Aaron
Re: Maintain user input's visibility [message #132736 is a reply to message #132733] Mon, 15 August 2005 22:36 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
In your screen layout you have item_z appearing only one time, and the other item appearing multiple times.

Are they in the same block?

David
Re: Maintain user input's visibility [message #132737 is a reply to message #132736] Mon, 15 August 2005 22:40 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

Item_z is for user to input the year.
I put it in the same block (table_b).

Regards,
Aaron
Re: Maintain user input's visibility [message #132740 is a reply to message #132737] Mon, 15 August 2005 22:51 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Does you have any triggers on item_z? Does item_z appear in any of your triggers?

David
icon9.gif  Re: Maintain user input's visibility [message #132741 is a reply to message #132740] Mon, 15 August 2005 22:52 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
No.
Re: Maintain user input's visibility [message #132742 is a reply to message #132741] Mon, 15 August 2005 22:59 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
This makes no sense. The default behaviour for an item in a block is to be displayed and visible. It appears that you have no sophisticated code that would clear it. You have said that item_z does NOT appear in any trigger, and that its field characteristics are the same as the other fields that are displaying successfully. That is, it is not query-only, it does not have a default value.

Sorry, I am at a loss. I will think about it more. Maybe someone else can think of what is wrong.

Alternative to trying to fix it - create a new form from scratch and build it again. There may be a trigger or procedure that is affecting you but you just can't 'see' it.

David
icon9.gif  Re: Maintain user input's visibility [message #132763 is a reply to message #132742] Tue, 16 August 2005 01:30 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

I have a query button which has the following codes:

WHEN-BUTTON-PRESSED

Begin
execute_query;
end;

and I created a WHEN-NEW-FORM-INSTANSE trigger

Begin
enter_query;
end;

Anyway, I don't think that it affects the display of item_z as item_z doesn't appear in any of the trigger.

Thanks!

Regards,
Aaron
icon12.gif  Re: Maintain user input's visibility [message #132780 is a reply to message #132742] Tue, 16 August 2005 03:20 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

I would also like to add:

WHERE ((table_b.item_e < 0 AND table_a.item_b = 'D')
OR (table_b.item_e > 0 AND table_a.item_b = 'C'))

to my query.

May I know where should I put this? Itried to put it in the 'where' section under table_b block's properties but failed because there were 2 tables involve here: Table_a and Table_b.

Thanks in advance.

PS: Do you have any messenger?

Regards,
Aaron
Re: Maintain user input's visibility [message #132916 is a reply to message #132780] Tue, 16 August 2005 19:01 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Use the 'exists' construct, for example,

I am working from memory, but I am assuming that the primary key of table_b is item_c plus item_d.
WHERE exists (select 'X'
                from table_b b,
                     table_a a
               where ( (b.item_e < 0 AND a.item_b = 'D')
                       OR (b.item_e > 0 AND a.item_b = 'C') )
                 and b.item_c = item_c
                 and b.item_d = item_d)

David

Update: I added more brackets to the logic.

[Updated on: Tue, 16 August 2005 20:13]

Report message to a moderator

icon12.gif  Re: Maintain user input's visibility [message #132922 is a reply to message #132916] Tue, 16 August 2005 19:57 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
David,

Did you mean that I put this in the POST-QUERY? What is 'X'?
Thanks.

Regards,
Aaron
Re: Maintain user input's visibility [message #132923 is a reply to message #132922] Tue, 16 August 2005 20:11 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Not in Post-Query but in the 'default where' clause where you currently have the "WHERE ((table_b.item_e < 0 AND table_a.item_b = 'D') OR (table_b.item_e > 0 AND table_a.item_b = 'C'))" code.

'X' is 'X', just type it as I wrote it. It is 'nothing'. All you want is for the SQL to resolve either a true or false on the linkage by primary key and your other logic. Use 'exists' for 'true' and 'not exists' for selecting the 'false' returns.

David

Update: I added more brackets to the 'where' logic in the posting 2 above.

[Updated on: Tue, 16 August 2005 20:14]

Report message to a moderator

icon4.gif  Re: Maintain user input's visibility [message #132924 is a reply to message #132923] Tue, 16 August 2005 21:12 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

Thanks for your kind guidance.
Well, I put the where clause in the Table_b block's property but it's not working.
Can I put it in the PRE-QUERY? and how should I do it?

Regards,
Aaron
Re: Maintain user input's visibility [message #132926 is a reply to message #132924] Tue, 16 August 2005 21:18 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You could it in the Pre-Query and use it to set the default_where but you can just as easily put it into your block property at build time.

Aaron, what you need to do is test the SQL in either a custom development tool like TOAD or use SQL*Plus to make sure that your table structure and data are correct.

Put the 'where' clause into a standard 'select' statement like 'select * from table_b where ...' and make sure that you are getting records retrieved. Then put the code into your form. Debugging SQL via the form is very difficult and time consuming. Debug it via a direct SQL interface and then put the 'working' code into your form.

David
icon5.gif  DETAIL: Maintain user input's visibility [message #132936 is a reply to message #132926] Tue, 16 August 2005 22:40 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

Sorry to take up your time. Well, I'm using TOAD to test my sql statement. Below is the steps I gone through:

Table A
item_a (PK)
item_b

Table B
item_c(PK)
item_d(PK)
item_e
item_z (year: eg: 2005)

Table C
item_c(PK)
item_a(FK)
item_f

This is my EXACT QUERY in TOAD that I need to put it in form:

SELECT c.item_f, a.item_b, b.item_e
FROM table_a a, table_b b, table_c c
WHERE b.item_z BETWEEN :p_itemz1 AND :p_itemz2
AND b.item_c = c.item_c
AND c.item_a = a.item_a
AND ((b.item_e < 0 AND a.item_b = 'D') OR (b.item_e > 0 AND a.item_b = 'C'))

My steps are:

1. Create Table_B data block with item: c and e (database item) and item: a, f, b (non-database)
2. Create canvas to display the query and create p_itemz1 and p_itemz2 (non database) for user input.
3. Create a query button with WHEN-BUTTON-PRESS trigger as below:

begin
execute_query;
end;

4. Create New-Form-Instanse trigger as below:

begin
enter_query;
end;

5. Create POST-QUERY as below:

DECLARE
CURSOR lookup_table IS
SELECT c.item_a,
a.item_b,
c.item_f,
FROM table_a a,
table_b b,
table_c c
WHERE a.item_a = c.item_a
AND c.item_c = :table_b.item_c;

BEGIN
OPEN lookup_table;

FETCH lookup_table
INTO :table_b.item_a
:table_b.item_b
:table_b.item_f
CLOSE lookup_table;
END;

6. Insert ====

exists (select 'X' from table_b b, table_a a
WHERE ((b.item_e < 0 AND a.item_b = 'D') OR (b.item_e > 0 AND a.item_b = 'C'))
AND b.item_c = item_c
AND b.item_d = item_d
AND b.item_z BETWEEN :table_b.p_itemz1 AND :table_b.p_itemz2)

== into WHERE clause in Table_B data block's property.

Can you please highlight me where did I go wrong? If need to use PRE-QUERY, how do I create it?
Thanks a lot!

Regards,
Aaron
Re: DETAIL: Maintain user input's visibility [message #132941 is a reply to message #132936] Tue, 16 August 2005 23:11 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
No you don't necessarily need to create Pre-Query.

You have TOAD - good. Open a SQL Editor window and place the suggested test SQL in it. That is,
select * 
  from table_b 
 where exists (select 'X'
                from table_b b,
                     table_a a
               where ( (b.item_e < 0 AND a.item_b = 'D')
                       OR (b.item_e > 0 AND a.item_b = 'C') )
                 and b.item_c = item_c
                 and b.item_d = item_d)
now you have to tie in the relationship you defined "AND b.item_c = c.item_c AND c.item_a = a.item_a".

Your items :p_itemz1 and :p_itemz2? On which block are they defined? Create a 'ctrl' block and place :p_itemz1 and :p_itemz2 on it. Always refer to items by both their block and item identifier.

Okay, there are two things for you to try - one is the query in SQl in TOAD, and the other is to define your 'parameters' in your form.

Get back to me when the SQL is giving you the reocrds you expect.

David

[Updated on: Tue, 16 August 2005 23:26]

Report message to a moderator

Re: DETAIL: Maintain user input's visibility [message #132943 is a reply to message #132941] Tue, 16 August 2005 23:25 Go to previous messageGo to next message
aarontan78
Messages: 63
Registered: August 2005
Member
Hi David,

I tried it in TOAD and it's not the record that I want.
Do you use messenger?

Thanks!

Regards,
Aaron
Re: DETAIL: Maintain user input's visibility [message #132945 is a reply to message #132943] Tue, 16 August 2005 23:40 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Sorry but 'messaging' is not permitted at my facility.

David
Previous Topic: How to create a Status bar?
Next Topic: reg locking mode in forms
Goto Forum:
  


Current Time: Thu Sep 19 22:46:54 CDT 2024