Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Two tables sharing same field name?
Two tables sharing same field name? [message #26836] Tue, 01 June 2010 19:28 Go to next message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
I have this simple schema:


TABLE_(MODES)
	STRING_ (NAME, 40) UNIQUE
END_TABLE

TABLE_(BANDS)
	STRING  (NAME, 8) UNIQUE
	DOUBLE_ (FREQ_BEGIN)
	DOUBLE_ (FREQ_END)
END_TABLE


This works fine. However, when I go to insert a name into the mode table that is 8 characters or more, I get an exception. i.e.

SQL & ::Insert(MODES) (NAME, "AMTORFEC");


If I change the above schema to define BANDS/NAME as 40, then the above statement works fine. Put the BANDS/NAME back to 8 and I get the exception. Never fails.

Am I doing something wrong or is this a bug?

Thanks,

Jeremy

[Updated on: Tue, 01 June 2010 19:30]

Report message to a moderator

Re: Two tables sharing same field name? [message #26837 is a reply to message #26836] Tue, 01 June 2010 19:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
jeremy_c wrote on Tue, 01 June 2010 13:28

I have this simple schema:


TABLE_(MODES)
	STRING_ (NAME, 40) UNIQUE
END_TABLE

TABLE_(BANDS)
	STRING  (NAME, 8) UNIQUE
	DOUBLE_ (FREQ_BEGIN)
	DOUBLE_ (FREQ_END)
END_TABLE


This works fine. However, when I go to insert a name into the mode table that is 8 characters or more, I get an exception. i.e.

SQL & ::Insert(MODES) (NAME, "AMTORFEC");


If I change the above schema to define BANDS/NAME as 40, then the above statement works fine. Put the BANDS/NAME back to 8 and I get the exception. Never fails.

Am I doing something wrong or is this a bug?

Thanks,

Jeremy




My guess is that you are breaking the UNIQUE contraint, SQL statement therefore end with error and exception is raised because you are executing with "&".

Put SQL.SetTrace() into MAIN and examine the log file.

Mirek
Re: Two tables sharing same field name? [message #26881 is a reply to message #26837] Sat, 05 June 2010 17:46 Go to previous message
jeremy_c is currently offline  jeremy_c
Messages: 175
Registered: August 2007
Location: Ohio, USA
Experienced Member
All of the "modes" are added in one place from a well defined list. I checked and checked and checked, there are no duplicates there. If I change the second use of "NAME" to be a length of 40, then my routine runs fine, always. If, however, I change the second use of "NAME" back to 8, then it will always err. And the second use of "NAME" is not at all where the error is occurring.

The bug log says:
ERROR SQL logic error or missing database(0): insert into MODES(NAME) values ('PSK31')


However, when looking at the created database file (SQLite) there 48 modes added out of 73 modes that I said to add.

My project is *very* small right now, I have made it available at http://jeremy.cowgar.com/files/SmartLog.zip ... maybe that would help solve the problem?

Basically at this point it's 1 window that contains a grid that does nothing. In my GUI_APP_MAIN, I create/open the database and add base data (where the problem is) if the database did not exist on this run.

I am running on Windows with the MSC9 Debug profile selected. You can run the project as is and it fails always for me. However, if you edit SmartLog.sch, line 7 and change the 8 to a 40, then the project will run (besure to remove the previously created database file and .sql files, otherwise the new data log will not happen).

Non-working SmartLog.sch:
TABLE_(MODES)
	INT_    (ID) PRIMARY_KEY AUTO_INCREMENT
	STRING_ (NAME, 40) UNIQUE
END_TABLE

TABLE_(BANDS)
	STRING  (NAME, 8) UNIQUE
	DOUBLE_ (FREQ_BEGIN)
	DOUBLE_ (FREQ_END)
END_TABLE


Working SmartLog.sch:
TABLE_(MODES)
	INT_    (ID) PRIMARY_KEY AUTO_INCREMENT
	STRING_ (NAME, 40) UNIQUE
END_TABLE

TABLE_(BANDS)
	STRING  (NAME, 40) UNIQUE
	DOUBLE_ (FREQ_BEGIN)
	DOUBLE_ (FREQ_END)
END_TABLE


Thanks for any help with this problem. For now I am just using the "working" schema file, however, I fear I will run into more issues like this later on.

Jeremy
Previous Topic: ParseForArguments does not take comments in account
Next Topic: Multiple schema files?
Goto Forum:
  


Current Time: Fri Mar 29 00:21:21 CET 2024

Total time taken to generate the page: 0.01163 seconds