Re: (no subject)
Jonathan de Halleux <[email protected]> Thu, 18 Mar 2004 16:52:20 +0100
| Newsgroups | gmane.comp.lib.sql.sqlpp |
|---|---|
| Message-ID | <[email protected]> |
--=====================_282258326==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
In order to have multiple column primary key, you must do:
0) suppose we have the table User, we want the two columns Name, LastName
to be the PK
table_shared_ptr user = db->add_table( ... );
1) add the fields that are part of the primary key and store de
fied_shared_ptr:
field_shared_ptr user_name = user->add_field("Name", ...);
field_shared_ptr last_name = user->add_field("Name", ...);
2) use set_primary_key method to specify the table PK. You can do that by
passing the names of the columns, the field pointer, etc...
field_container_type fields;
fields.push_back( user_name );
fields.push_back( last_name );
user->set_primary_key( fields );
That's it :)
At 09:04 18/03/2004 -0600, you wrote:
>The question(s) and comments below were transferred from support request.
>I am still using sqlpp and I have had few problems with the C++ Libs. I
>use the multi-column primary and foreign key methods extensively. In fact,
>I have generated flawless queries with multiple tables having multi-column
>PK and FK relationships. The problems outlined below began when I
>generated ASPX, C# code behind and C#. Regards, Randall Davis
>
>
>
>
>
>
>Previous JD comments:
>Hi, if you are still using sqlpp it would be nice to discuss
>such features in the mailing list. You can define multiple primary key
>without problem. I'll put an example on the wiki.
>R.D. Question:
>Summary: Primary Keys Initial Comment: I am using sqlpp to model and QBE
>using a meta data repository and I have had great success with a
>few exceptions(spacing around "AND" in joins). I make a few changes and
>it seems to work fine. I am now testing CS and aspnet generation. I am
>using release 2.9, XP pro and VS2003. I am new to C# and ASP.NET and the
>DNN approach to data access, but the problems I am having actually occur
>due the assumption that primary keys are generated ids or sequences. All
>of the pk's and fk's in my repository are multi-column
>and must be input by the user. The CS generator and aspnet generators
>(implicitly) assume that the pks are generated. Is there a way to get
>around this assumption? BTW, the control generator generates code to
>access text boxes that are not created for primary key columns. There
>is also a problem with this construct
>// m_RA_IDE_CHANGE_RULE_TBLDataGrid.OnItemCommand=
>"m_RA_IDE_CHANGE_RULE_TBLDataGrid_Click"; the method is not accessible due
>to protection level. Booleans should be initialized with true (currently
>"True"). This gives a string conversion error.
-----------------------------------------------------------------------------------
Jonathan de Halleux, Research Assistant
Center for Systems Engineering and Applied Mechanics (CESAME)
Universite catholique de Louvain
Batiment Euler , Av. Georges Lemaitre, 4 Tel : +32-10-47 2595
B-1348 Louvain-la-Neuve Belgium
E-mail : [email protected]
-----------------------------------------------------------------------------------
--=====================_282258326==.ALT
Content-Type: text/html; charset="us-ascii"
<html>
<body>
In order to have multiple column primary key, you must do:<br><br>
0) suppose we have the table User, we want the two columns Name, LastName
to be the PK<br><br>
table_shared_ptr user = db->add_table( ... );<br><br>
1) add the fields that are part of the primary key and store de
fied_shared_ptr:<br><br>
field_shared_ptr user_name = user->add_field("Name",
...);<br>
field_shared_ptr last_name = user->add_field("Name",
...);<br><br>
2) use set_primary_key method to specify the table PK. You can do that by
passing the names of the columns, the field pointer, etc...<br><br>
field_container_type fields;<br>
fields.push_back( user_name );<br>
fields.push_back( last_name );<br><br>
user->set_primary_key( fields );<br><br>
That's it :)<br><br>
At 09:04 18/03/2004 -0600, you
wrote:<br><br><blockquote type=cite class=cite cite>
<ul>
<ul>
<font face="Courier New, Courier" size=2>The question(s) and comments
below were transferred</font>
<font face="Courier New, Courier" size=2>from</font>
<font face="Courier New, Courier" size=2>support request.</font>
<font face="Courier New, Courier" size=2>I am still using sqlpp and I have had few problems with the C++ Libs. I use the multi-column primary and foreign key methods extensively.</font> <font face="Courier New, Courier" size=2>In fact, I have generated flawless queries with multiple tables having multi-column PK and FK relationships.</font> <font face="Courier New, Courier" size=2>The problems outlined below began when I generated ASPX, C# code behind and C#.</font>
<font face="Courier New, Courier" size=2>Regards,</font>
<font face="Courier New, Courier" size=2>Randall Davis</font><br>
<br>
<br>
<br>
<br>
<br><br>
</ul>
</ul><font face="Courier New, Courier" size=2>Previous JD comments:</font>
<ul>
<ul>
<font face="Courier New, Courier" size=2>Hi, if you are still using sqlpp it would be nice to discuss such </font>
<font face="Courier New, Courier" size=2>features in the mailing list.</font>
<font face="Courier New, Courier" size=2>You can define multiple primary key without problem. I'll put </font>
<font face="Courier New, Courier" size=2>an example on the wiki.</font>
</ul>
</ul><font size=2>R.D. Question:</font>
<ul>
<ul>
<ul>
<ul>
<ul>
<ul>
<font face="Courier New, Courier" size=2>Summary: Primary Keys</font>
<font face="Courier New, Courier" size=2>Initial Comment:</font>
<font face="Courier New, Courier" size=2>I am using sqlpp to model and QBE using a meta data </font>
<font face="Courier New, Courier" size=2>repository and I have had great success with a few </font>
<font face="Courier New, Courier" size=2>exceptions(spacing around "AND" in joins). I make a few </font>
<font face="Courier New, Courier" size=2>changes and it seems to work fine.</font>
<font face="Courier New, Courier" size=2>I am now testing CS and aspnet generation. I am using </font>
<font face="Courier New, Courier" size=2>release 2.9, XP pro and VS2003. I am new to C# and </font>
<font face="Courier New, Courier" size=2>ASP.NET and the DNN approach to data access, but the </font>
<font face="Courier New, Courier" size=2>problems I am having actually occur due the assumption </font>
<font face="Courier New, Courier" size=2>that primary keys are generated ids or sequences. All of </font>
<font face="Courier New, Courier" size=2>the pk&#039;s and fk&#039;s in my repository are multi-column and </font>
<font face="Courier New, Courier" size=2>must be input by the user. The CS generator and aspnet </font>
<font face="Courier New, Courier" size=2>generators (implicitly) assume that the pks are </font>
<font face="Courier New, Courier" size=2>generated. Is there a way to get around this </font>
<font face="Courier New, Courier" size=2>assumption?</font>
<font face="Courier New, Courier" size=2>BTW, the control generator generates code to access </font>
<font face="Courier New, Courier" size=2>text boxes that are not created for primary key </font>
<font face="Courier New, Courier" size=2>columns. </font>
<font face="Courier New, Courier" size=2>There is also a problem with this construct</font>
<font face="Courier New, Courier" size=2>// </font>
<font face="Courier New, Courier" size=2>m_RA_IDE_CHANGE_RULE_TBLDataGrid.OnItemCommand=</font>
<font face="Courier New, Courier" size=2>"m_RA_IDE_CHANGE_RULE_TBLDataGrid_Click";</font>
<font face="Courier New, Courier" size=2>the method is not accessible due to protection level.</font>
<font face="Courier New, Courier" size=2>Booleans should be initialized with true </font>
<font face="Courier New, Courier" size=2>(currently "True"). This gives a string conversion error.</blockquote>
<x-sigsep><p></x-sigsep>
</ul>
</ul>
</ul>
</ul>
</ul>
</ul>-----------------------------------------------------------------------------------<br>
Jonathan de Halleux, Research Assistant<br>
Center for Systems Engineering and Applied Mechanics (CESAME)<br>
Universite catholique de Louvain <br>
Batiment Euler , Av. Georges Lemaitre, 4 Tel : +32-10-47 2595 <br>
B-1348 Louvain-la-Neuve Belgium <br>
E-mail : [email protected] <br>
-----------------------------------------------------------------------------------<br>
</font></body>
</html>
--=====================_282258326==.ALT--
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click