Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2004, 04:11 PM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default prepopulate an update form

I have a memo type form field that i want to be able to update. HOw do I prepopulate the field with existing data? I don't want to erase existing data so I am assuming I have to prepopulate it otherwise I will overwrite it when adding the new data.

I've been using Cold Fusion and with that they use this:

value="#TRIM(TableName.FieldName)#"

Thanks

Trevor Lyman
 
Old January 20th, 2004, 04:38 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What are you using now?
 
Old January 20th, 2004, 05:33 PM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Im still using CF but but CFInsert doesn't work with memo fields (I'm not sure why) so I have to use straight sql in this case.



Quote:
quote:Originally posted by planoie
 What are you using now?
Trevor Lyman
 
Old January 20th, 2004, 06:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Perhaps you can use the SQL CONVERT or CAST functions to change the source field into a datatype that CF can handle. Of course, you risk truncation with this, but it might be your only hope.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old January 20th, 2004, 06:36 PM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI- thanks- I'm actually looking to do it in sql. THat's why I'm posting to this forum. Is there a way to do it with SQL?

Thanks

Quote:
quote:Originally posted by planoie
 Perhaps you can use the SQL CONVERT or CAST functions to change the source field into a datatype that CF can handle. Of course, you risk truncation with this, but it might be your only hope.

Peter
------------------------------------------------------
Work smarter, not harder.
Trevor Lyman
 
Old January 20th, 2004, 09:28 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Ok, I'm a little confused. Can you explain in more explicit detail exactly what you are doing? You mentioned that you are using cold fusion, so you are obviously building a web application of some sort. However it is not apparent (to me at least) exactly what the problem is. Is the problem getting the data or saving the data?

I don't understand how you intend to "do it in sql". SQL will give you the data, but you need to get it onto the page somehow. What exactly are you trying to accomplish?

After looking back at your posts, perhaps I understand what the problem is....
Are you asking how to insert data into SQL using straight T-SQL syntax versus using the cold fusion object methods? If that's the case then maybe this will help:

INSERT INTO tablename(field, field, ...) VALUES(value, value, ...)

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old January 20th, 2004, 09:50 PM
Registered User
 
Join Date: Jan 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HI- thanks for the help- yes the end of your post is what I am looking to do...except when I call the form up if there is pre-existing data in the dbase for that field I want it to populate that form. This way when I press submit I don't overwrite and erase what is already there with my additional data. Basically it is for a notes section. I want to be able to add to/ edit my notes- so I don't want to erase what is already there. I need to pre populate the form field with the data from the dbase. I know how to do everything else. Thanks!

Quote:
quote:Originally posted by planoie
 Ok, I'm a little confused. Can you explain in more explicit detail exactly what you are doing? You mentioned that you are using cold fusion, so you are obviously building a web application of some sort. However it is not apparent (to me at least) exactly what the problem is. Is the problem getting the data or saving the data?

I don't understand how you intend to "do it in sql". SQL will give you the data, but you need to get it onto the page somehow. What exactly are you trying to accomplish?

After looking back at your posts, perhaps I understand what the problem is....
Are you asking how to insert data into SQL using straight T-SQL syntax versus using the cold fusion object methods? If that's the case then maybe this will help:

INSERT INTO tablename(field, field, ...) VALUES(value, value, ...)

Peter
------------------------------------------------------
Work smarter, not harder.
Trevor Lyman
 
Old January 21st, 2004, 10:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Presumably you will have populated your form with the data that is currently in the database when the page loads. If you cange and/or add to this data then surly you want to write all of the text back to the database.

The only thing I can think of is that the page never gets loaded with the information already in the database, so when you want to add extra information all you have is that extra information and not what is currently in the database.

In this case you will want a query that is something like this:

Code:
UPDATE YourTable
   SET Description = (SELECT Description
                        FROM YourTable
                       WHERE ID = AnID) & 'Some more text'
 WHERE ID = AnID
 I am not sure if that query will actually work though, at least it gives you an idea.

Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
UpDate Records on a Form ManFriday Access 2 September 8th, 2007 04:21 AM
Prfessional Struts Applications - PrePopulate Form Mieber All Other Wrox Books 15 September 6th, 2007 01:36 AM
Update Table From Form ksbrain Access 2 January 9th, 2007 01:49 PM
how to prepopulate a form field sycryc HTML Code Clinic 2 September 29th, 2005 02:37 PM
Update table from form leeloo Access VBA 1 June 28th, 2004 11:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.