|
|
Question : INSERTS IN STORED PROCEDURE
|
|
1) We have a application where from front end, 30 values are input then together with current date & timestamp, 30 rows should be inserted in a table.
2) This can be 30, 60, 200 etc. i.e. any number of inputs & hence any number of records to be inserted in table.
3) char & varchar datatypes is max 255 characters. text is big & okay for us but cannot be passed as a stored procedure parameter.
4) We are trying to send a concatenated string including values of all these 30 etc. inputs from frontend. This we will tokenize in stored proc & carry out the inserts. Is this possible?
4) Are there any array type datatypes in Sybase. Is there any other way of doing this in a stored procedure.
|
Answer : INSERTS IN STORED PROCEDURE
|
|
If i understand what you are saying correctly, you just want to do multiple inserts from user-defined values. Why are you trying to force a single stored proc to do this. You should use a loop within your application language to do the inserts one at a time. This is the most clean implementation
Using string concatenation to pass the values into a stored proc as a single input, then parse it out within the sp, and loop through them for insertion is a complete nightmare. Not to mention there is a size limitation on input parameters for the sp. This should be done on the application level, not database.
The only array datatype structure i am aware of is cursor which is not applicable here. The only way i know that allows you to do mass inserts in sybase is: insert into TableOne select Cols.. from TableTwo. This is very useful but only if the data already exist in db table somewhere. If it is passed to you from frontend gui/forms, there is no way around it. Just loop through multiple insert statements.
|
|
|
|
|