I.T. Discussion Community!
-Collapse +Expand
Paradox
Search Paradox Group:

Advanced
-Collapse +Expand Paradox To/From
To/FromCODEGuides
-Collapse +Expand Paradox Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyCorel Paradox / ObjectPAL Coding BoardObjectPAL Topic   Print This     

Primary Key inside of query?

Primary Key inside of query? in ObjectPAL topic (part of our Corel Paradox / ObjectPAL Coding group).

Quick Search: Primary   Primary Key   Primary Key inside   of query  
S0nY
Baton Rouge, LA USA

I was sitting here at my desk trying to write a query out in a script i was creating, thinking I was able to make a Primary Key field in the table that is made from my query... Ill write an example:

var
 Q Query
endvar

Q=

Query

KEY on Images.DB | envelopenum |

Images.DB               | envelopenum  | crdate    |
                                     | Check _join1 | >today-91 |

invoiceimages.db | invoicenum | envelopenum |
                                     | Check      | _join1      |

EndQuery

if not Q.executeQBE("Last90Days.DB") then
 errorshow()
endif

Now.. Maybe in a dream I may have had, but for some strange reason I thought I have used that " Key On " code to make my executeQBE table have a primary key.. Anyways I have been trying to figure our how to make my query make a primary key on my table that it creates... Is this not possible? Am I just simply going bananas?

 Posted 10 years ago (Thread Starter)
Comment Quote
About S0nY -Collapse +Expand
Visit Profile
Approved member.
Member does not subscribe to this thread.

Post ID #13964, 4 replies
Thread Started 2/15/2010 11:21:09 AM
View Counter=3686
Last Reply Posted 2/17/2010 9:27:12 AM)
Location=Baton Rouge, LA USA 
Joined=13 years ago   MB Posts=53  
Moderator
Mike Prestwood
Prestwood IT
Prestwood IT office in Citrus Heights, CA

Of course there is always a way to do something, but I'm afraid what you want to do isn't the "normal" usage of a QBE query. The answer table is just a collection of records with no keys or indexes. You could add a primary key or indexes after the fact, of course, but that's not what you want to do.

When Borland was prepping Paradox 7, one of the betas really enhanced QBE with live data back to the tables, there was even a little heartbeat icon that was pretty cool. The enhanced features were ripped out before shipping because of related problems.

I wish Local SQL supported adding a primary key using standard SQL as in...

ALTER TABLE NoKeyTable ADD PRIMARY KEY (FullName);

...but it doesn't.

Local SQL does support creating a primary key when creating a table, but that's a bit off topic.

Alternatively, you could create the table ahead of time and populate it with code, use a DLL that "can" restructure a Paradox table, use an insert SQL query, etc.

--
Mike Prestwood
Prestwood IT Solutions

 Posted 10 years ago
Comment Quote
About Mike Prestwood -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Mike Prestwood

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Web Presence
Facebook, Prestwood IT Facebook page -- fan page. (Visit Me)
Twitter, Follow Prestwood IT on Twitter. (Visit Me)
LinkedIn, Prestwood IT company page on LinkedIn. (Visit Me)
YouTube, Prestwood IT YouTube Channel (Visit My Channel)
Website, My drum website where I sell my drum books. (http://www.play-drums.com)

Post ID #13966 (Level 1.1)  Reply to 13964
Thread Started 2/15/2010 12:01:08 PM
Location=Prestwood IT office in Citrus Heights, CA 
Joined=20 years ago   MB Posts=1410   KB Posts=1805   KB Comments=69   BLOG, Topics=4  
S0nY
Baton Rouge, LA USA

Hmm, Thanks for the reply Mike.

I am not good with DLLs yet, actually I don't understand how to call them and use them properly within Paradox. ( I am still trying to figure out how to use IJL10.dll to convert picture formats within paradox, I have no clue what I am doing.. )

If i were to run my qbe and create a table with my query, is there not simple syntax I can write to make a field on the table a primary key? Something similar to createindex() or something of that nature?

 Posted 10 years ago (Thread Starter)
Comment Quote
About S0nY -Collapse +Expand
Visit Profile
Approved member.
Member does not subscribe to this thread.

Post ID #13977 (Level 2.1)  Reply to 13966 and Parent is 13964
Thread Started 2/16/2010 3:44:38 PM
Location=Baton Rouge, LA USA 
Joined=13 years ago   MB Posts=53  
Moderator
Mike Prestwood
Prestwood IT
Prestwood IT office in Citrus Heights, CA

Sure, createIndex() will work. Here's a simple example using createIndex() to create a paradox primary key:

method pushButton(var eventInfo Event)
var
 tblNoKeyTable Table
 dynAttribs Dynarray[] Anytype
 dynFieldnums Array[1] Smallint
endvar
  
dynFieldnums[1]=1
dynAttribs["PRIMARY"] = True
  
tblNoKeyTable.attach(":work:NoKeyTable.db")
tblNoKeyTable.createindex(dynAttribs, dynFieldnums)
endMethod

 

The example in the ObjectPAL help for createIndex() shows how to create a secondary index and add error checking too.

--
Mike Prestwood
Prestwood IT Solutions

 Posted 10 years ago
Comment Quote
About Mike Prestwood -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Mike Prestwood

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Web Presence
Facebook, Prestwood IT Facebook page -- fan page. (Visit Me)
Twitter, Follow Prestwood IT on Twitter. (Visit Me)
LinkedIn, Prestwood IT company page on LinkedIn. (Visit Me)
YouTube, Prestwood IT YouTube Channel (Visit My Channel)
Website, My drum website where I sell my drum books. (http://www.play-drums.com)

Post ID #13979 (Level 3.1)  Reply to 13977 and Parent is 13964
Thread Started 2/16/2010 7:29:38 PM
Last Reply Posted 2/18/2010 8:13:33 AM)
Location=Prestwood IT office in Citrus Heights, CA 
Joined=20 years ago   MB Posts=1410   KB Posts=1805   KB Comments=69   BLOG, Topics=4  
Most Recent Post
S0nY
Baton Rouge, LA USA

Thanks alot Mike, this code worked great and created my primary key correctly. Thanks again.

 Posted 10 years ago (Thread Starter)
Comment Quote
About S0nY -Collapse +Expand
Visit Profile
Approved member.
Member does not subscribe to this thread.

Post ID #13981 (Level 4.1)  Reply to 13979 and Parent is 13964
Thread Started 2/17/2010 9:26:19 AM
Location=Baton Rouge, LA USA 
Joined=13 years ago   MB Posts=53  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P187A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #13964 Counter
3686
Since 2/15/2010

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech