Solved

SQL PERVASIVE , INSERT INTO ,  WITH A KEY  BEING identity- type in VB6

Posted on 2011-03-15
6
1,747 Views
Last Modified: 2012-05-11
I have a table where the index is identity type , thus autoincrement
in vaccess i was used to do a get last record first, then raised this index with 1 , then do a insert with new calculated value
max rexord +1,    in SQL I do not know how a SQL call should look like to get this done
either in VB6 or the pervasive utils    type 2000i  or V10 and V11
0
Comment
Question by:BIAPRO
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 35136304
Hi,

You can not perform an insert for a identity column in MS SQL, unless you use:

SET IDENTITY INSERT table ON
-- DO INSERT HERE
SET IDENTITY INSERT table OFF

However, why do you need to do that? MS SQL will auto increment that value, just do not include that identity column name in the insert statement.

--------------
You can contact me on: http://extremedev.blogspot.com/
0
 

Author Comment

by:BIAPRO
ID: 35136370
is this also true for Pervasive ?
0
 
LVL 9

Expert Comment

by:Roman Gherman
ID: 35136410
Hi,
For Pervasive you need to put 0 for identity column:
--------------------
The following example shows what occurs when you use INSERT for IDENTITY columns and columns with default values.
CREATE TABLE t (id IDENTITY, c1 INTEGER DEFAULT 100)
INSERT INTO t (id) VALUES (0)
INSERT INTO t VALUES (0,1)
INSERT INTO t VALUES (10,10)
INSERT INTO t VALUES (0,2)
INSERT INTO t (c1) VALUES (3)
SELECT * FROM t
The SELECT shows the table contains the following rows:
1, 100
2, 1
10, 10
11, 2
12, 3
The first row illustrates that if “0” is specified in the VALUES clause for an IDENTITY column, then the value inserted is “1” if the table is empty.
The first row also illustrates that if no value is specified in the VALUES clause for a column with a default value, then the specified default value is inserted.
The second row illustrates that if “0” is specified in the VALUES clause for an IDENTITY column, then the value inserted is one greater than the largest value in the IDENTITY column.
More details on this site:
--------------------

You can find me on: http://extremedev.blogspot.com/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BIAPRO
ID: 35136479
ok this is my record tabel
 WEBSHOP(BasketRecord,CustIDyymmdd,OrderNumber,StatusFlag,Customer,ItemNumber,Deliverydate,QTY)  "
These are the  FIELDS        identy key     ,  string              ,string              ,string        , string,        string,           string,          float

this i call
 INSERT INTO WEBSHOP VALUES(0, 'JACK        110316 ', '         ', '0' ,JACK        ', '05.0425       ', '110316',  0)

and give error    -2147217900


0
 
LVL 9

Accepted Solution

by:
Roman Gherman earned 500 total points
ID: 35136573
An apostrophe is missing before JACK'.
Try this

INSERT INTO WEBSHOP VALUES(0, 'JACK 110316', '', '0' ,'JACK', '05.0425', '110316',  0)
0
 

Author Comment

by:BIAPRO
ID: 35136641
great !!   working perfect!  thanks a lot!
Regards Jack
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question