Sap B1 Quantity Field on Recommendation Form - sapb1

I make some inserts on ORCM table by programmatically. Everything looks normal on database. Here is the insert query for ORCM table:
insert into ORCM (DocEntry,ObjAbs,ObjType,ItemCode,DueDate,OrderType,Quantity,UOM,CardCode,Warehouse,Price,Origin,Status,UserSign,DocDate,ReleasDate) values ("+mx+"," + objAbs +",199,'"+sale.itemCode+"',GETDATE(),'P',"+sale.quantity+",'','V10000','01',0,'M','O',1,GETDATE(),GETDATE())
But the quantity field on recommendation form is coming empty.
I couldn't find why this is happenning.

Related

Replicate all column options for each entry

I'm fairly new to SQL and all I need to populate a table automatically where the values from column2 are always present for each value in column 1. For example, for every new item inserted on Column1(Names) I want a pre-defined set of values to populate Column2(Illnesses) I have no idea what to call this process and all my google searches returned nothing.
As an example:
When John is added to the Database it creates a row, I want to automatically duplicate John and fill column2 it with the following pre-defined options
I hope I'm explaining myself ok...probably I'm not so apologies.
You can use CROSS APPLY. Something like this:
SELECT [name], Illness
FROM
(
VALUES ('John')
) Names ([name])
CROSS APPLY
(
VALUES ('Flu')
,('Covid')
,('Common Cold')
,('Constipations')
,('Food Posoning')
) Illnesses(Illness)
You are showing a many-to-many data relationship which requires 3 tables. There should be a table of People and a table of Illnesses where in both each record is unique. Then a junction table PeopleIllnesses which should save PeopleID and IllnessID as foreign keys of the ID's from People and Illnesses.
You want to 'batch create' a set of records. Possibly need code in whatever app you are using to program interface (Access, vb.net, C#, etc). The new People record must first be committed to table. In VBA, code could be in click event of a button on data entry form for People and like:
Sub btnAddRecords_Click()
DoCmd.RunCommand acCmdSaveRecord
CurrentDb.Execute "INSERT INTO PeopleIllnesses(PeopleID, IllnessID) SELECT " & Me.tbxPID & ", IllnessID FROM Illnesses"
End Sub

Access Form - Combo Box From Lookup Table, Updating Look Up Value Text to LookupID - No code telling it to

First time poster, long time Junior Varsity Access Developer
MS Access 2016 on Win 10 system (not connectable to public network)
I have form with a text field - Event Name (Pulled from existing value in Events table) and 3 unbound combo boxes (created from Wizard, select key field and lookup value text, hide key field, save value for later use) on a form that each pull values from a respective lookup table
Lookup table structure:
tblCategories: CategoryID (PK, Integer) | CategoryName (Text 255)
tblDirectorate: DirectorateID (PK, Integer) | DirectorateName (Text 255)
tblLocation: LocationID (PK, Integer) | LocationName (Text 255)
What should happen:
User completes the form, selects values from each of the combo boxes (Category, Directorate, Location) clicks Save Event button. (Tested - Values passed to SQL statement correspond to values from combo box)
Update SQL Statement runs, updates Events table and sets values in table to values on form (Update SQL Syntax correct, I did a debug.print to immediate window, copy and paste to QBE, run SQL, Update runs correctly)
What does happen:
User completes the form, selects values from each of the combo boxes (Category, Directorate, Location) clicks Save Event button. (Tested - Values passed to SQL statement correspond to values from combo box)
Update SQL Statement runs, updates Events table and sets values in table to values on form (Update SQL Syntax correct, I did a debug.print to immediate window, copy and paste to QBE, run SQL, Update runs correctly)
(Here's the part that I can't explain) The value of CategoryName in tblCategories updates to the value of CategoryID
a. I do not have cascade updates on any of the tables
b. Nowhere in ANY of the code in the entire DB is there a SQL statement to update tblCategories
c. Nowhere in any part of the DB is there a command to update the value of CategoryName in tblCategories
d. Neither the values of [tblDirectorate].[DirectorateName] nor [tblLocations].[LocationName] update to their corresponding ID field value.
I'm completely befuddled by this. I've deleted / recreated the combo box for the Category lookup, verified that the actions / properties for all 3 lookups are the same.
Has anyone previously experiences this, or can throw out some additional troubleshooting ideas?
Thanks!
Jordan

primary key of newly added row in sql table, vb.net

I have a vb.net application where datagridview is databound to sql table at design time(with table adapter and dataset). All I wanted is to get newly added row's Primary key(int) when i add new row to it. I have searched, but it's showing sql commands like below:
INSERT INTO #Customers
(Name)
VALUES ('Customer 1')
SELECT SCOPE_IDENTITY()
so using scope_identity(). But is there any way I can do it with adapter(or dataset) in vb.net or same command can be given though adapter or similar ?
Thanks in advance!
try this!
SCOPE_IDENTITY() will give you the last identity value inserted into any table directly within the current scope (scope = batch, stored procedure, etc. but not within, say, a trigger that was fired by the current scope)
Use the OUTPUT clause if you are inserting multiple rows and need to retrieve the set of IDs that were generated.
INSERT #a(x) OUTPUT inserted.identity_column VALUES('b'),('c');
--
result will be
1
2

Oracle PLSQL: insert ID that is in sequence of one table into another

I am trying to create a trigger that whenever you insert values inside a table called hotel, it takes some values from the field and inserts it inside another table called Restaurant.
My Hotel_ID is in sequence so I don't really give its value when I am using the insert statement to insert values inside the hotel table. Which creates problems for the restaurant table as it sets the value of Hotel_ID to null. I know in the insert statement I can just add the sequence name so that it works but the thing is, later on I have to convert my tables into APEX forms and with them, you can't insert the ID at all.
Anyway, here is my trigger that is basically supposed to take values from some fields of Hotel table and insert them into the Restaurant table:-
create or replace TRIGGER HOTELREST BEFORE INSERT ON HOTEL
FOR EACH ROW
BEGIN
IF INSERTING THEN
INSERT INTO RESTAURANT(CITY,ADDRESS,HOTEL_ID)
VALUES (:NEW.CITY,:NEW.ADDRESS,:NEW.HOTEL_ID);
END IF;
END;
Although the values of City and address get inserted inside the restaurant table, the value of hotel_id doesn't. Here is my insert statement for hotel:
INSERT INTO HOTEL(NAME,CITY,COUNTRY,ADDRESS,RATINGS)
VALUES ('Westin','Manchester','UK',5);
Now again, before you say that I didn't give an Id of the hotel, like I said, I am using sequence so when this row gets inserted inside the hotel table, a value for Hotel_Id is automatically generated. My trigger is also supposed to add Hotel_Id in my Restaurant table but it doesn't. It remains null. What do I do?

Oracle: selfcopying data from Oracle tables

Application has different versions. Each version has it's own set of values in each table. I need to provide functionality to copy data from one version to another. Problem :
By inserting data I am trying to insert Ids which has already been in use in this table. So, I need to change ids of components which I want to insert but I must save relationship between those components. How cat I do that?
Create a master table which has a surrogate key as your primary key. A numeric value of type NUMBER(9) works well. You can create a sequence and trigger to automatically insert this.
The rest of the table is the column of your current table plus a column to indicate which version the row is for.
For simplicity you may wish to create views on top of the table along the lines of
select * from master_table where version_id = ####;
To copy the data from one version to another this will work:
Insert into master_table seq_master_table.nextval, new version_id,.....
from master_table
where version_id = ####;