Updated PSDDLMODEL table for DDL Model Deaults, now getting buffer errors on page - peoplesoft

I was modifying the Model DDL Defaults in PeopleSoft and deleted and then re-added an index model default for Microsoft DB. I noticed when I re-added it that the Statement Type was blank and there was no option to select that it was an Index. I ended up performing an UPDATE SQL statement on the table PSDDLMODEL and I set the STATEMENT_TYPE equal to 2 (it was 0 previously).
Now when I load the page 'DDL Model Defaults' and select Microsoft as the platform I receive the message:
No matching buffer found for level. (15,26)
When retrieving data for a page, a data value was retrieved for which there was no matching data value at a higher level scroll entry. (For example, at scroll level 2, a value of ABC was read in and scroll level 1 contained this higher level field but did not have a row with a key value of ABC.) This usually occurs because of an error in a database record or view; or because of improper deletion of values in a database. Correct the page definition or contact your system administrator.
What can I do to fix this?
EDIT:
I was able to run the SQL UPDATE statement and set the STATMENT_TYPE back to 0 and refreshed the page online and it now loads properly. But I still have the issue of not having the STATEMENT_TYPE set to 'Index' and I have no option online to update it. I am puzzled how I am supposed to change it, if updating the table directly causes the buffer issues...

Your DDL parameters are orphaned if you change the statement type in PSDDLMODEL.
You will have to perform an SQL UPDATE on STATEMENT_TYPE in PSDDLDEFPARMS as well.
UPDATE PSDDLDEFPARMS
SET STATEMENT_TYPE = '2'
WHERE STATEMENT_TYPE = '0'
AND PLATFORMID = '7';
Your problem:
You add a new row in PSDDLMODEL (STATEMENT_TYPE will be 0)
You add parameters, they get inserted in PSDDLDEFPARMS with STATEMENT_TYPE 0
You update PSDDLMODEL setting STATEMENT_TYPE to 2 for 'Index'
Buffer mismatch.
The buffer loads PSDDLMODEL and PSDDLDEFPARMS, finds entries in PSDDLDEFPARMS for STATEMENT_TYPE 0, but can not match it to a parent row in PSDDLMODEL because you updated it. This is why setting STATEMENT_TYPE back to 0 in PSDDLMODEL 'fixes' the error.

Related

Sqlite: Are updates to two tables within an insert trigger atomic?

I refactored a table that stored both metadata and data into two tables, one for metadata and one for data. This allows metadata to be queried efficiently.
I also created an updatable view with the original table's columns, using sqlite's insert, update and delete triggers. This allows calling code that needs both data and metadata to remain unchanged.
The insert and update triggers write each incoming row as two rows - one in the metadata table and one in the data table, like this:
// View
CREATE VIEW IF NOT EXISTS Item as select n.Id, n.Title, n.Author, c.Content
FROM ItemMetadata n, ItemData c where n.id = c.Id
// Trigger
CREATE TRIGGER IF NOT EXISTS item_update
INSTEAD OF UPDATE OF id, Title, Author, Content ON Item
BEGIN
UPDATE ItemMetadata
SET Title=NEW.Title, Author=NEW.Author
WHERE Id=old.Id;
UPDATE ItemData SET Content=NEW.Content
WHERE Id=old.Id;
END;
Questions:
Are the updates to the ItemMetadata and ItemData tables atomic? Is there a chance that a reader can see the result of the first update before the second update has completed?
Originally I had the WHERE clauses be WHERE rowid=old.rowid but that seemed to cause random problems so I changed them to WHERE Id=old.Id. The original version was based on tutorial code I found. But after thinking about it I wonder how sqlite even comes up with an old rowid - after all, this is a view across multiple tables. What rowid does sqlite pass to an update trigger, and is the WHERE clause the way I first coded it problematic?
The documentation says:
No changes can be made to the database except within a transaction. Any command that changes the database (basically, any SQL command other than SELECT) will automatically start a transaction if one is not already in effect.
Commands in a trigger are considered part of the command that triggered the trigger.
So all commands in a trigger are part of a transaction, and atomic.
Views do not have a (usable) rowid.

How to assign an ID but then delete if not used

I am unsure on how to do this 'best practice' wise.
I have a web application (asp.net VB) that connects to an MS SQL server 2012. Currently when the page loads the app connects to a DB table and gets the last ID and adds 1 to it and displays this to the user. When the user submits the form the new ID is saved to the DB.
The problem being the app may be opened by 2 users at the same time and therefore they will get assigned the same ref number which will cause problems when the data is saved.
How can I assign different numbers to different users if the app is opened at the same time without saving unnecessary data?
You have multiple solutions for this, I'll try to outline a few approaches. (I'll assume that you need to insert things into a DB that I'll call "orders".)
First of all, you can move the ID-generation to the moment when the order is actually inserted, and not at the moment when the user start to enter the data. That way, you do not generate an ID for a user that never completes the form. Also this scenario is easy to accomplish using autoincrementing values in sql server. You can, for example do:
-- create a table with an identity column
create table Orders (
ID int identity(1,1) not null,
Description nvarchar(max) not null
);
-- insert values, without specifying the ID column
insert into Orders (Description) values ()
-- select the row back
-- returns 1, 'My First Order'
select * from Orders;
Another way to do this is to use SQL Server Sequences. These are things that do nothing except generate numbers in a row. They guarantee that the numbers won't be repeated, and always keep count of the current value, i.e.
-- create a sequence
create sequence OrderIdSequence
start with 1
increment by 1;
-- get the next sequence value
select next value for OrderIdSequence

Ms Access AddItem with VBA

I have a Form that has a button on it. The button basically copies records from one Table to the other.
As records are read and copied, it is also checked for specific values. E.g. If one of the fields in the table has a value of "" then it should call another form that allows me to enter a date. Once the date is entered and the form is closed the programme carries on with copying.
It can also happen that the key fields in the table that is being copied are duplicate. In this case I should a 'listbox form' should be launched with a listbox displaying the values of the duplicate records. I should then select the correct record that I need copied.
Dim NumberCount As Long
NumberCount = RecordsetElementValue.RecordCount
If NumberCount > 1 Then
With Form_F_ListBox.List30
RecordsetElementValue.MoveFirst
Do
With Forms!F_ListBox.List30.AddItem(RecordsetElementValue!E_ElementValue)
End With
RecordsetElementValue.MoveNext
Loop Until RecordsetElementValue.EOF = True
DoCmd.OpenForm "F_ListBox", acNormal
End With
End If
The code sample above is what I have for in case there are duplicate records (NumberCount > 1)
The listbox in my F_ListBox form should be filled with the values in my recordset.
I now run into a runtime error 6014. The RowSourceType property must be set to 'Value List' to use this method.
What am I doing wrong?
The usual way to set the row source of a combo or list box in MS Access is to use an SQL statement, however, you can also use a list. This is controlled by the row source type.
Me.MylistBox.RowSourceType = "Value List"
From your notes, it seems that an SQL statement for the row source would be easier:
Me.MylistBox.RowSource = "SELECT ID FROM MyTable"

GridView does not load schema from the SQL stored Procedure

I have gridview, when I connect the sqldatasource and run the application, data from stored procedure is shown but when i switch to design mode, the schema does not loads in gridview. I need that schema to rearrange columns and for formatting purpose.
I never had this problem before, All of sudden it is a problem.
What I tried so far "Refresh Schema" brings up the dialog which list all the parameters I am passing to the storedprocedure. After I changed DBType for every single parameter, it still give me an error, says "check your connection and storedprocedure". While the storedprodure does run, shouldn't it automatically update the schema in gridview. I still have the default 3 columns of gridview.
Note: I may get around the problem by adding each column manually but I am doing this to fix problem in the page, in the first place, dont want to run again in gridview problem. This is a new page that I am building. Thanks
It looks like, Schema is not updated just from StoredProcedure because simple there is not enough information how many columns will be returned.
To work around this issue and sort of quick fix, do the following.
Copy the query from you stored procedure and change the SQLDatasource from stored procedure to Select statement. Run your select statement and finish. Notice that your schema will now be updated.
You can now set your SQLDataSource back to stored procedure and the schema will remain the same.
It also occured to me that when you run a stored procedure, the column names are updated in the query using the name 'Databound col0' 'Databound Col1' and so on
I am not sure sometime it does, sometime it does not. Right click on Gridview and click Referesh Schema does not work as it gives some error.
Along the lines of #hmd, when there is not enough info, especially if there is another perceived dataset being return, i.e you are doing something that returns blank or debug data (rows affected, etc.). A workaround for this is to put "SET NOCOUNT OFF" in the beginning of your procedure and then set it back "ON" again before you return the data. This is also a problem on SSRS.

asp.net InsertCommand to return latest insert ID

I'm unable to retrieve the latest inserted id from my SQL Server 2000 db using a typed dataset in asp.NET
I have created a tableadapter and I ticked the "Refresh datatable" and "Generate Insert, Update and Delete statements". This auto-generates the Fill and GetData methods, and the Insert, Update, Select and Delete statements.
I have tried every possible solution in this thread
http://forums.asp.net/t/990365.aspx
but I'm still unsuccesfull, it always returns 1(=number of affected rows).
I do not want to create a seperate insert method as the auto-generated insertCommand perfectly suits my needs.
As suggested in the thread above, I have tried to update the InsertCommand SQL syntax to add SELECT SCOPY_IDENTITY() or something similar, I have tried to add a parameter of type ReturnValue, but all I get is the number of affected rows.
Does anyone has a different take on this?
Thanks in advance!
Stijn
I decided to give up, I can't afford to waste any more time on this.
I use the Insert statement after which I do a select MAX(id) query to hget the insert ID
If anyone should have a solution, I'll be glad to read it here
Thanks
Stijn
I successfully found a way to get the incremental id after insert using my table adapter.
My approach is a little different, I'm using a Store procedure to make the insert, so my insert command has all the values but the ID, I made the sp return the ID just calling:
SET #ID=SCOPE_IDENTITY()
and then
COMMIT TRAN
and last line will be
RETURN #ID
Then I searched my table adapter parameters for InsertCommand and set the #RETURNVALUE to the column of the incremental ID of the table, so when it's executed automatically put the return value on the id field.
Hope this help
You need to tell your table's table-adapter to refresh the
data-table after update/insert operation.
This is how you can do that.
Open the properties of TableAdapter -> Default Select Query -> Advnaced options. and Check the option of Refresh the data table. Save the adapter now. Now when you call update on table-adapter, the data-table will be updated [refreshed] after the update/insert operation and will reflect the latest values from database table. if the primary-key or any coloumn is set to auto-increment, the data-table will have those latest value post recent update.
Now you can Call the update as TableAdapterObj.Update(ds.dataTable);
Read latest values from the DataTable(ds.dataTable) coloumns and assign respective values into the child table before update/insert. This will work exactly the way you want.
alt text http://ruchitsurati.net/files/tds1.png

Resources