Hi friends,
I was wondering if we can write a method which takes an arraylist object(Column name,column values) and sql table name to build a sql query.... I have not used Arraylist as of now and i need your help to do this please...
Thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 25, 2012, 10:19 AM EDT
Here's something I've quickly thrown together on these lines. As it's possible that the table and column names could be reserved words in whatever RDMS you're using the only safe thing to do is to wrap all names in square brackets:
The output of this program is:
INSERT INTO [Person] ([Name], [ID], [Status]) VALUES ('Rani', 1, null)
rani m mk47 reputationPosted Jul 25, 2012, 9:03 PM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 26, 2012, 12:12 AM EDT