Home » Developer & Programmer » Forms » Display All records of my DB in a table (oracle forms 10g, windows xp pack 2)
Display All records of my DB in a table [message #573509] Sat, 29 December 2012 21:12 Go to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
Hi All Smile
i want to display all the records of my database in a table with scrolling
example if i have 3records in my DB so a table must have 3records too !!!
this is my code :
DECLARE
Cursor cur IS
SELECT numb_ph AS phone,
name_emp AS name
FROM emp

BEGIN
GO_BLOCK('emp');
FIRST_RECORD;
FOR s IN cur LOOP
:emp.numb_ph := s.phone;
:emp.name_emp := s.name;

NEXT_RECORD;
END LOOP;
FIRST_RECORD;
END;

but the problem 's all records of my DB are display in one record (to view another record i use the scrolling ..
thank you Smile
Re: Display All records of my DB in a table [message #573514 is a reply to message #573509] Sun, 30 December 2012 00:58 Go to previous messageGo to next message
ranamirfan
Messages: 522
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Dear,
Try this it'll work.
DECLARE
Cursor Cur Is
 SELECT numb_ph AS phone,
  name_emp AS name
 FROM emp;

BEGIN
 Go_Block('EMP');
 First_Record;
FOR S IN Cur LOOP
 :emp.numb_ph := s.phone;
 :emp.name_emp := s.name;
 Create_Record;

END LOOP;

END;




Regards,
Irfan

Re: Display All records of my DB in a table [message #573523 is a reply to message #573514] Sun, 30 December 2012 05:02 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I don't think that CREATE_RECORD makes any difference (as opposed to NEXT_RECORD, used by @goldray).

goldray
the problem 's all records of my DB are display in one record (to view another record i use the scrolling ..

What does that mean, really? Could you post a screenshot so that we could see how your form looks like?

Did you use a data block wizard to create that block? Did you choose the "form" layout? If so, maybe you should have chosen the "tabular" layout which is capable of displaying several records on the screen at a time. Form layout displays only one record (so you have to scroll up/down to view them all).
Re: Display All records of my DB in a table [message #573535 is a reply to message #573523] Sun, 30 December 2012 09:45 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
hi ,
@ranamirfan
with your code nothing appears !!!!!!!!!!!!!
@Littlefoot,
i will capture a video ...
yeah ,i used a data block wizad with only 1 record ,and i chose tabular with scrolling
Re: Display All records of my DB in a table [message #573537 is a reply to message #573535] Sun, 30 December 2012 10:56 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
@Littlefoot:
u can show my video :
http://www.youtube.com/watch?v=9ApSdkaavT4&feature=youtu.be
Re: Display All records of my DB in a table [message #573538 is a reply to message #573537] Sun, 30 December 2012 11:30 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Right; you chose "form" layout, but you should have chosen "tabular" one.

[EDIT]

As this is a very simple form, perhaps the easiest way would be to start over (i.e. delete current form and create a new one). Or, you can set that manually - open data block's Property Palette and set its "Number of records displayed" to a value higher than 1 (which is, I suppose, set now) - for example, set it to 10. Then, select the frame and adjust output if necessary.

[Updated on: Sun, 30 December 2012 11:33]

Report message to a moderator

Re: Display All records of my DB in a table [message #573539 is a reply to message #573538] Sun, 30 December 2012 12:15 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
thank you for the proposition, but it is there's method to remove the blank records (see image) ??
http://nsa30.casimages.com/img/2012/12/30/121230071422805901.png

[EDITED by LF: The image is just too wide to fit the screen so I removed the [img] tags and left the link]

[Updated on: Mon, 31 December 2012 05:52] by Moderator

Report message to a moderator

Re: Display All records of my DB in a table [message #573540 is a reply to message #573539] Sun, 30 December 2012 12:47 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
i think that i must create a trigger when-new-form-instance and i create query which returns the number of records in the table of database ,then i use set_form_property to set a number of records displayed ..
it's possible ????
Re: Display All records of my DB in a table [message #573541 is a reply to message #573539] Sun, 30 December 2012 12:50 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
No, there isn't. At least, a simple one. You can't set number of records in a block during runtime, so just leave it as is.

You could (but I strongly suggest you not to) create multiple form layout blocks, one below the other, populate them one by one so that they look like a tabular block, and then - depending on number of records - hide certain blocks (actually, their items). Another option is to create a stacked canvas; display it and move its position depending on number of records.

Once again: it's not worth it. Empty records are free of charge, you don't have to feed them, they aren't that ugly. Let them be.
Re: Display All records of my DB in a table [message #573542 is a reply to message #573541] Sun, 30 December 2012 13:41 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
thank you again Smile
so I'll keep empty records Smile
i create a new item and i want place in it 2 icones (1. for update ,2. for delete)
it's possible ??
thank you
Re: Display All records of my DB in a table [message #573543 is a reply to message #573542] Mon, 31 December 2012 00:08 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'm not sure I understand what you want, but - it looks like you'd want to create two buttons. If that's so, no problem - you have a Button tool in the toolbar.
Re: Display All records of my DB in a table [message #573548 is a reply to message #573543] Mon, 31 December 2012 05:08 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
hi,
i want to insert two image in the same item ... it's possible ?
question 2:
i want to delete record when i press in the boutton ok from the alert_message but i don't know what i put in the condition :
if [b]//condition[/b] then
   delete-record; 
end if;




thank you Smile
Re: Display All records of my DB in a table [message #573554 is a reply to message #573548] Mon, 31 December 2012 05:21 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I still don't understand that "images" question. Could you illustrate it (using Paint, for example) and attach the image? This time, please, resize the image to display only the important part, not with a huge white background.

As of the "delete" part of the question: here's an example (taken from one of my forms). I hope it'll give you an idea. Generally speaking, alerts have buttons (one (OK), two (Yes, No), three (Yes, No, Cancel)) so - depending on your alert - you have to check which one of them has been pressed and do something.

declare
  alertgumb number;
begin
  if :obrada.zone_id is null
  then
     alertgumb := alertf('AATTENTION', 'Zone ID is empty. Is that OK?;

     if alertgumb = alert_button1     --> this line!
     then 
        prc_do_something;
     else
        prc_do_something_else;
     end if;
  end if;

end;
Re: Display All records of my DB in a table [message #573560 is a reply to message #573554] Mon, 31 December 2012 05:34 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
example for the two image :
http://nsa29.casimages.com/img/2012/12/30/121230060428582953.png

for the delete:
i want also delete the record to the database ,so i must use query like this :
if condition then
  record_delete;
   commit;
    delete from emp where id=[b](the id of the current record)[/b]



but i don't know what i put in the "id of current record" !!!
Re: Display All records of my DB in a table [message #573563 is a reply to message #573560] Mon, 31 December 2012 05:40 Go to previous messageGo to next message
cookiemonster
Messages: 10570
Registered: September 2008
Location: Rainy Manchester
Senior Member
You should not write a delete statement at all. Delete_record deletes the record from the form and the DB.
You need to spend some time reading up on how forms works. It does most of the basic functionality (insert,update,delete,select) for you.

[Updated on: Mon, 31 December 2012 05:40]

Report message to a moderator

Re: Display All records of my DB in a table [message #573565 is a reply to message #573563] Mon, 31 December 2012 05:43 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
but if i use only :
record_delete;
commit;
the record in the database not delete !!!!!
Re: Display All records of my DB in a table [message #573566 is a reply to message #573565] Mon, 31 December 2012 05:51 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
(There's no RECORD_DELETE; it is DELETE_RECORD - unless you wrote your own procedure whose name is RECORD_DELETE. If so, what did you put in there and - why did you do that? As Cookiemonster told you, Forms does all that for you.)

If it is a data block, then "DELETE_RECORD; COMMIT;" really deletes the record from both data block and database. If you claim different, please, prove it.

As of the image issue: as far as I can tell, you can put 1 image in there at a time. If you want to use another image, the first one won't be visible any more (i.e. will be overwritten by the second one). However: I still think that 2 buttons would easily solve your "problem". You can even put icons onto those buttons, if you wish.

Re: Display All records of my DB in a table [message #573572 is a reply to message #573566] Mon, 31 December 2012 06:17 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
you can watch the video :
http://www.youtube.com/watch?v=2Lq7ykPYwpg&feature=youtu.be
Re: Display All records of my DB in a table [message #573590 is a reply to message #573572] Mon, 31 December 2012 09:12 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
Any solutions !!! please
Re: Display All records of my DB in a table [message #573599 is a reply to message #573590] Mon, 31 December 2012 12:06 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, there's something wrong from the beginning. As soon as you run the form, there's the FRM-40102 error (record must be entered or deleted first), and when you tried to delete a record, Forms removed it from a block but was unable to do that in the database because of FRM-40508 (unable to insert record).

So, how do you get these 3 records in there? If it is a database block, you should have performed EXECUTE_QUERY which would fetch records from the database. If you did that in a loop, Forms thinks that you, actually, inserted new values so when your code came to COMMIT, it tried to insert values that already exist and failed for some reason (for example, unique/primary key violation). In order to find out the reason, when you get the error, go to runtime form's Help menu and choose "Display Error" which will provide some more information. If you don't understand it, please, copy/paste the message over here.

Finally, maybe you should really pay attention to the following:
Cookiemonster

You need to spend some time reading up on how forms works


[EDIT]
The simplest option is usually the best: create a new form. Use data block wizard. Base the block on a table. When the wizard finishes, you have a fully operational form which is capable of selecting existing records, modifying them, deleting them, inserting new records. You don't have to code ANYTHING of that. Perhaps you should first make your form work, then make it fancy.

[Updated on: Mon, 31 December 2012 12:10]

Report message to a moderator

Re: Display All records of my DB in a table [message #573607 is a reply to message #573509] Mon, 31 December 2012 15:12 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
you are right ..
but i checked my code of insert :

declare
	i number;
begin



commit_form();
i := show_alert('VALID');

clear_form;
end;

it's work !! and the 3 records are inserted by this code !!!
i don't found the problem Shocked
Re: Display All records of my DB in a table [message #573608 is a reply to message #573607] Mon, 31 December 2012 15:25 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
code of insertion work but it display this error !!!! :
ORA-00001: violation de contrainte unique (SYSTEM.CL_P_GR)
Re: Display All records of my DB in a table [message #573609 is a reply to message #573608] Mon, 31 December 2012 15:28 Go to previous messageGo to next message
Littlefoot
Messages: 18821
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Which, in turn, means that it does not work. Re-read my previous message once again and try to do what I told you.
Re: Display All records of my DB in a table [message #573611 is a reply to message #573609] Mon, 31 December 2012 15:39 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
i created a new block (with wizard) but i receive the same problem !!!!
i will created again !!
Re: Display All records of my DB in a table [message #573613 is a reply to message #573611] Mon, 31 December 2012 15:42 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
i wish for you a good year full of happiness and joy Smile
I'm really sorry for the inconvenience Embarassed


[Updated on: Mon, 31 December 2012 16:24]

Report message to a moderator

Re: Display All records of my DB in a table [message #573616 is a reply to message #573613] Mon, 31 December 2012 16:53 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
Confused

[Updated on: Mon, 31 December 2012 16:58]

Report message to a moderator

Re: Display All records of my DB in a table [message #573617 is a reply to message #573607] Mon, 31 December 2012 17:37 Go to previous messageGo to next message
cookiemonster
Messages: 10570
Registered: September 2008
Location: Rainy Manchester
Senior Member
goldray wrote on Mon, 31 December 2012 21:12
you are right ..
but i checked my code of insert :

declare
	i number;
begin



commit_form();
i := show_alert('VALID');

clear_form;
end;

it's work !! and the 3 records are inserted by this code !!!
i don't found the problem Shocked


What is that code supposed to do? What trigger is it in?


Try this: Create a new form. Create a new datablock using the datablock wizard based on your table. Make sure all the items are on the layout.

Write no code in the form - none, zero. Do not create a single trigger. Do not write a single line of code.

Run the form.

See that you can query records and insert records and update records and delete records from your form despite the fact that you have written no code.

This is forms default behavior.

Try it.

Re: Display All records of my DB in a table [message #573618 is a reply to message #573617] Mon, 31 December 2012 17:49 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
you are right ...
that 's problem from the code insertion ,i deleted it and i put execute_query !! now i can delete record from the forms and from the database ...thanks one again Wink

Now, i want to update record ,what should I do ??
i must create a new form ? help me Shocked

[Updated on: Mon, 31 December 2012 17:51]

Report message to a moderator

Re: Display All records of my DB in a table [message #573619 is a reply to message #573618] Mon, 31 December 2012 17:55 Go to previous messageGo to next message
cookiemonster
Messages: 10570
Registered: September 2008
Location: Rainy Manchester
Senior Member
No. Forms does that for you as well.
Run the form. Query some records.
Change the records.
Press save.
Forms will do the update for you.
Re: Display All records of my DB in a table [message #573620 is a reply to message #573619] Mon, 31 December 2012 18:40 Go to previous messageGo to next message
goldray
Messages: 104
Registered: December 2012
Senior Member
thank you for the answer ..
i created boutton "update" ,i want when i presse it ,the cursor will be in the item 1 then in the item 2 ,and others records will be disabled ..
what should I do ??
Re: Display All records of my DB in a table [message #573621 is a reply to message #573620] Mon, 31 December 2012 18:48 Go to previous messageGo to next message
cookiemonster
Messages: 10570
Registered: September 2008
Location: Rainy Manchester
Senior Member
Use set_item_property to disable items
Re: Display All records of my DB in a table [message #573622 is a reply to message #573617] Mon, 31 December 2012 20:22 Go to previous message
goldray
Messages: 104
Registered: December 2012
Senior Member
cookiemonster wrote on Mon, 31 December 2012 17:37
goldray wrote on Mon, 31 December 2012 21:12
you are right ..
but i checked my code of insert :

declare
	i number;
begin



commit_form();
i := show_alert('VALID');

clear_form;
end;

it's work !! and the 3 records are inserted by this code !!!
i don't found the problem Shocked


Quote:
What is that code supposed to do? What trigger is it in?


Try this: Create a new form. Create a new datablock using the datablock wizard based on your table. Make sure all the items are on the layout.

Write no code in the form - none, zero. Do not create a single trigger. Do not write a single line of code.

Run the form.

See that you can query records and insert records and update records and delete records from your form despite the fact that you have written no code.

This is forms default behavior.

Try it.




i used trigger when-boutton-pressed !!
Previous Topic: How to get ip address in forms 6i
Next Topic: web colors on developer suite
Goto Forum:
  


Current Time: Wed Apr 16 08:27:44 CDT 2014

Total time taken to generate the page: 0.10435 seconds