Most effective way of coding (1 Viewer)

giedrius

Registered User.
Local time
Today, 20:09
Joined
Dec 14, 2003
Messages
80
Hello,

I am using simple INSERT INTO query a lot of times in different forms. What would be more effective - to put INSERT INTO once in a procedure and call it every time it is needed or simply use INSERT INTO a number of times as needed?

Thanks,
giedrius
 

dcx693

Registered User.
Local time
Today, 14:09
Joined
Apr 30, 2003
Messages
3,265
If you call a piece of code more than once, it's best to reference that piece of code using a call rather than having the same code in your program twice. If you need to alter the code, you'll just change it once.
 

giedrius

Registered User.
Local time
Today, 20:09
Joined
Dec 14, 2003
Messages
80
Yes, I take your point that is is more convenient for coding. But is it faster in execution? I have no clue how many lines of low level code A2K adds for a simple INSERT INTO sql statement. If it is hundreds of lines, than probably it is more efficient to have INSERT once in a subroutine and call it every time it is needed.

On the other hand if you use exactly the same INSERT or any other sql statement in your code you can easily change it with Visual Basic's Ctrl-H (Replace).

giedrius
 

Mile-O

Back once again...
Local time
Today, 19:09
Joined
Dec 10, 2002
Messages
11,316
I'm guessing that your queries are in no way dynamic which means that you don't need code at all. Just create a stored query - this is fastest.
 

giedrius

Registered User.
Local time
Today, 20:09
Joined
Dec 14, 2003
Messages
80
I presume stored queries are only possible while working with SQL Server. I have a simple peer-to-peer configuration and I use DAO.

giedrius
 

Mile-O

Back once again...
Local time
Today, 19:09
Joined
Dec 10, 2002
Messages
11,316
No, a stored query is just a query object in Access. I say 'stored' because I'm guessing you are creating them on the fly when it's probably not necessary.
 

giedrius

Registered User.
Local time
Today, 20:09
Joined
Dec 14, 2003
Messages
80
Mile-O-Phile said:
No, a stored query is just a query object in Access. I say 'stored' because I'm guessing you are creating them on the fly when it's probably not necessary.

Yes, you are right. I made simple things complicated.

Thanks.
giedrius
 

Users who are viewing this thread

Top Bottom