Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: Database: MS Access
 Multiple Inserts
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

Podge
Support Moderator

Ireland
3775 Posts

Posted - 30 August 2007 :  10:53:09  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
In SQL 2000 I can write an SP which takes a number of parameters. In MySql I can use this syntax
INSERT INTO beautiful (name, age) VALUES   ('Helen', 24),('Katrina', 21),('Samia', 22),('Hui Ling', 25),  ('Yumie', 29)";


Is there a neat way of doing multiple inserts into the same table in Access (as opposed to looping through a few hundred insert statements) ?

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.

AnonJr
Moderator

United States
5768 Posts

Posted - 30 August 2007 :  11:03:36  Show Profile  Visit AnonJr's Homepage
Doesn't that work in Access? I could have sworn that I've seen something similar in one of my other apps...
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 30 August 2007 :  11:13:52  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
It don't I'm afraid. It looks for a missing semicolon after the first set of values i.e. ('Helen', 24).

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.

Edited by - Podge on 30 August 2007 11:14:09
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 August 2007 :  11:21:59  Show Profile  Send ruirib a Yahoo! Message
I don't think you can do that in Access. You're limited to one statement at a time, AFAIK.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 30 August 2007 :  11:27:29  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
It even complains if you concatenate them i.e.

INSERT INTO beautiful (name, age) VALUES ('Helen', 24); INSERT INTO beautiful (name, age) VALUES ('Katrina', 21);

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 30 August 2007 :  11:32:29  Show Profile  Visit AnonJr's Homepage
I was apparently mistaken.

http://msdn2.microsoft.com/en-us/library/bb208861.aspx
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 30 August 2007 :  12:24:17  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
Bummer. Its going to be pretty slow then if I have to do few hundred insert queries. Can't believe no-one ever came up with a work-around.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 August 2007 :  12:43:46  Show Profile  Send ruirib a Yahoo! Message
There is a better way, although through a trick...

Create a similar MySQL or SQL Server DB. Add the records to that DB. Define an ODBC data source for that DB and then import the table or tables from Access. Even if the table structure is not the one you want, you can then use an append query to move the data from the "incorrect" access table to the good table.

Of course, this only makes sense if you want to do this offline.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 30 August 2007 :  12:48:36  Show Profile  Send pdrg a Yahoo! Message
Do it as a loop? What interface are you using? Could you use DTS, or is it ADO/DAO/RDO/etc?
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 30 August 2007 :  12:55:15  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
I saw somewhere that you could access the mdb file via a MySql odbc driver which supported the MySql syntax. Not really an option if its for a Snitz mod.

Instead I think I can have the queries run in the admin area once every so often instead of after each post. It might be better that way anyway.

Quick question: Whats F_STATUS used for in the FORUM_FORUM table ? Is it safe to assign a status to it like this ?

Status 2 for Recycle Bin
Status 3 for SPAM
Status 4 for whatever

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  06:47:18  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
F_STATUS is used to lock forums. F_TYPE is what I should be using.
quote:
F_TYPE
Long Name: Forum Type

Data Type [Access, MS SQL, MySQL]: Small Integer [SMALLINT, SMALLINT, SMALLINT(6)]

Default Value: 0

Allow Nulls: Yes

Description: Holds the type of forum.

Possible Values:
0 - Regular forum. Users may make posts or replies to this type of forum.
1 - URL forum. A forum containing a url. No posts or replies can be made to this type of forum.


Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  06:57:46  Show Profile  Send ruirib a Yahoo! Message
quote:
Originally posted by Podge

I saw somewhere that you could access the mdb file via a MySql odbc driver which supported the MySql syntax. Not really an option if its for a Snitz mod.

Instead I think I can have the queries run in the admin area once every so often instead of after each post. It might be better that way anyway.


I guess you could chang a bit of code to execute a dbs file whenever you wanted...


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Podge
Support Moderator

Ireland
3775 Posts

Posted - 31 August 2007 :  08:02:15  Show Profile  Send Podge an ICQ Message  Send Podge a Yahoo! Message
After thinking about it for a while there is no other option. I'm going to need to do a select first anyway to see if a row already exists and if it does get a value from one of the columns. If it doesn't already exist I can just insert it. One other thing which I'm sure is easy for you (my sql sucks) is how to write this query;

Select T_MESSAGE from FORUM_TOPICS and R_MESSAGE from FORUM_REPLY where FORUM_FORUM.F_TYPE = 2

I don't need topic id's or anything else just one column of all the topics and replies in forums with an F_TYPE of 2. I just can't get it right.

Podge.

The Hunger Site - Click to donate free food | My Blog | Snitz 3.4.05 AutoInstall (Beta!)

My Mods: CAPTCHA Mod | GateKeeper Mod
Tutorial: Enable subscriptions on your board

Warning: The post above or below may contain nuts.
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  08:51:14  Show Profile  Send ruirib a Yahoo! Message
This should handle it, as long as you are running at MySQL 4.x+

Select T_MESSAGE from FORUM_TOPICS T INNER JOIN FORUM_FORUM F ON T.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2
UNION 
SELECT R_MESSAGE from FORUM_REPLY R INNER JOIN FORUM_FORUM F ON R.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2


Do you need the message or do you just need to know if there is such a topic in such a forum?


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 31 August 2007 :  08:59:19  Show Profile  Send ruirib a Yahoo! Message
Here is a much more efficient version, if you just interested in finding if a record exists:


SELECT 1 FROM FORUM_TOPICS WHERE EXISTS 
  (Select TOPIC_ID from FORUM_TOPICS T INNER JOIN FORUM_FORUM F ON T.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2
   UNION 
   SELECT REPLY_ID from FORUM_REPLY R INNER JOIN FORUM_FORUM F ON R.FORUM_ID=F.FORUM_ID where F.F_TYPE = 2)

Not sure why you're testing for a reply, cause there can be no replies if there aren't topics...


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 31 August 2007 :  09:01:23  Show Profile  Visit AnonJr's Homepage
I would guess its because a reply may be bad in a good topic. Likewise a topic could be bad from the get-go.
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.18 seconds. Powered By: Snitz Forums 2000 Version 3.4.07