Home » Developer & Programmer » Forms » Inserting into a table using data from a text box (forms desinger 9i)
Inserting into a table using data from a text box [message #443592] Tue, 16 February 2010 08:05 Go to next message
rosswelsh
Messages: 42
Registered: February 2010
Location: Sunderland
Member
Hi all,

New to the forum and to PL/SQL and was hoping somebody could help?

I have a form that has one text box in it, and I want this value to be inserted into a table called StaffName, which has only one column, but im unsure as to how I would get my SQL statement to pick up this value.

I tried:

begin
insert into StaffName values ('addstaffmember');
end;

addstaffmember is the name of the text box.

this statement compiled but when I ran the form and tried to click save it would not work.


Any help would be greatly appreciated, im sure it must be quite simple but im a bit lost! Confused
Re: Inserting into a table using data from a text box [message #443601 is a reply to message #443592] Tue, 16 February 2010 08:14 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
Anything in quotes is a text string. You've told it to insert the value addstaffmember rather than the value of the item.

Correct code:
insert into StaffName values (:<block_name>.addstaffmember);


However what you really want is:
<this space left blank deliberately>


As forms handles inserts automatically for you.
Re: Inserting into a table using data from a text box [message #443602 is a reply to message #443592] Tue, 16 February 2010 08:15 Go to previous messageGo to next message
cookiemonster
Messages: 12422
Registered: September 2008
Location: Rainy Manchester
Senior Member
Oh and when coding insert statements you should always specify the column list - I know there is only 1 here but it's a good habit to get into early.
Re: Inserting into a table using data from a text box [message #446939 is a reply to message #443592] Thu, 11 March 2010 00:48 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Sorry that I have been so long in replying. Have you solved your problem?

Just base your block on your table. Key the data into the screen and auto-magically it will appear in the database. This is what ORacle Forms was designed and built to do, you do NOT need to do your own inserts, updates, or deletes. That is VB crap!

David
Re: Inserting into a table using data from a text box [message #447860 is a reply to message #446939] Thu, 18 March 2010 04:45 Go to previous messageGo to next message
rosswelsh
Messages: 42
Registered: February 2010
Location: Sunderland
Member
Thanks for your reply David. Sorry it has taken me so long to get back to you!

I have managed to get it to work now. Thanks very much for your help.
Re: Inserting into a table using data from a text box [message #447941 is a reply to message #443592] Thu, 18 March 2010 10:51 Go to previous message
BS_99
Messages: 34
Registered: March 2010
Member
Hello frnd,
hope my reply could help your problem.

insert into StaffName(Fieldname1)
values(:block_name.addstaffname);
commit;

--in fact the textfield from which you are picking the value is a bindvariable and it should not be written withinn qoutes.

and the bindvariable name should be followed by the block name

as follows

:block1.textitem_name

try this,i hope it wd work.

Regards
Bibek.
Previous Topic: Running Oracle Report Through Form6i and validating between two dates
Next Topic: How to create Browse button in Oracle Form Builder
Goto Forum:
  


Current Time: Fri Dec 09 08:11:13 CST 2016

Total time taken to generate the page: 0.22817 seconds