In access I have Form name FB (table name = FB) and SubForm name FBB ( table =FBB) (relationship one to many)
I use
( currentdb.execute "insert into FBB (FBID, ProductName, Quantity) "& _value (" & me.FBID &",'" & me.ProductName &"','" & me.Quantity &"')
What i want now is how if ProductName is a duplicate update the value Quantity by sum with me.Quantity in the same FBID
And thank you in advance
I tried to use on duplicate update the key but doesn't exist in access
Related
I have an app in Oracle Apex 22.21. There are multiple tables (ORDERS, ORDER_ITEMS, STORES, and PRODUCTS).
ORDERS table
enter image description here
I have a Master Detail report that is editable. The main report shows the ORDERS table and the detail shows the ORDER_ITEMS table.
Report image
enter image description here
In the ORDERS table, there is a column STORE_ID which is a foreign key to the STORES table. The STORES table has a column STORE_NAME. I am able to edit the report (change the STORE_ID to another 'id' ex: 1,2,3) when the table's Source is set to the ORDERS table.
STORES table
enter image description here
STORES table data
enter image description here
I want the ORDERS table to include the STORE_NAME column referring to the STORES table. As it does not make sense for the user to enter a STORE_ID to edit a row. I want the user to be able to edit the STORE_ID by entering the STORE_NAME or by choosing an LOV. I changed the report Source Type to SQL Query and ran the below code.
select
ORDERS_LOCAL.*,
STORES.STORE_NAME
from ORDERS_LOCAL
inner join STORES
ON ORDERS_LOCAL.STORE_ID=STORES.STORE_ID
However, when I try to edit a cell, I encounter an error ORA-01776: cannot modify more than one base table through a join view
I've found a post/solution regarding this error and tried to follow the instructions. The first solution does not work in my case because I actually want the user to be able to edit the STORE_ID column by showing STORE_NAME.
enter image description here
I've tried changing and running the PL/SQL code exactly as instructed but nothing saves when I change a cell value and click save. But I don't receive any error.
BEGIN
CASE :apex$row_status
WHEN 'C'
THEN
INSERT INTO stores (store_id, store_name)
VALUES ( :p10_store_id, :p10_store_name);
INSERT INTO orders_local (order_id,
order_number,
order_date,
store_id,
full_name,
email,
city,
state,
zip_code,
credit_card,
order_items
)
VALUES ( :p10_order_id,
:p10_order_number,
:p10_order_date,
:p10_store_id,
:p10_full_name,
:p10_email,
:p10_city,
:p10_state,
:p10_zip_code,
:p10_credit_card,
:p10_order_items);
WHEN 'U'
THEN
UPDATE orders_local
SET order_id = :p10_order_id,
order_number = :p10_order_number,
order_date = :p10_order_date,
store_id = :p10_store_id,
full_name = :p10_full_name,
email = :p10_email,
city= :p10_city,
state= :p10_state,
zip_code= :p10_zip_code,
credit_card= :p10_credit_card,
order_items= :p10_order_items
WHERE order_id = :p10_order_id;
UPDATE stores
SET store_name = :p10_store_name
WHERE store_id = :p10_store_id;
WHEN 'D'
THEN
DELETE orders_local
WHERE order_id = :p10_order_id;
DELETE stores
WHERE store_id = :p10_store_id;
END CASE;
END;
Take a step back. The "report that is editable" is an interactive grid. If the report is display only, then you can use any SQL to display data. However, if it is editable then the SQL statement is used to update the rows as well. The statement
select
ORDERS_LOCAL.*,
STORES.STORE_NAME
from ORDERS_LOCAL
inner join STORES
ON ORDERS_LOCAL.STORE_ID=STORES.STORE_ID
Cannot be used to update the store_id in the orders_local table. Currently you're trying to work around this by using custom code for the update but that is overcomplicating things. So, take a step back and restart.
The query for the interactive grid should be
select
*
from ORDERS_LOCAL
Define a List of Values to display the select list for Stores. The query for that list of values is
select
store_id as return_value,
store_name as display_value
from stores
In the interactive grid us this list of values for the store_id column.
That is all there is to it. This will allow you to use the native process for handling the IG updates.
Is this valid in Cassandra? Can we use Set, List, Map as cluster key.
1)
CREATE TABLE employee (
id text,
exams SET<text>,
courses list<text>,
results map<text, text>
PRIMARY KEY (id, exams)
);
CREATE TABLE employee (
id text,
exams SET,
courses list,
results map<text, text>
PRIMARY KEY (id, courses)
);
CREATE TABLE employee (
id text,
exams SET,
courses list,
results map<text, text>
PRIMARY KEY (id, results)
);
You can use collections as part of the primary key but they have to be frozen collections.
This schema is invalid:
CREATE TABLE student_results (
studentid text,
results list<text>,
PRIMARY KEY (studentid, results)
)
If you try to create the table, it will throw an invalid query exception:
Invalid non-frozen collection type for PRIMARY KEY component
The correct schema is when the collection is frozen:
CREATE TABLE student_results (
studentid text,
results frozen<list<text>>,
PRIMARY KEY (studentid, results)
)
Cheers!
I am trying to create a column in PowerBI that counts how times a customer name occurs in a list.
I may be going in the wrong direction, but what I have so far is;
My SQL query returns a table of customer site visits (Query1), from which I have created a new table (Unique) and column (Customer) that lists the distinct names (cust_company_descr) from Query1;
Unique = DISTINCT(Query1[cust_company_descr])
What I need is a new column in the Unique table (Count) that will give me a count of how many times each customer name in the Query1 table appears.
If I were working in Excel, the solution would be to generate a list of unique values and do a COUNTIF, but I can't find a way to replicate this.
I have seen a few solutions that involve this sort of thing;
CountValues =
CALCULATE ( COUNTROWS ( TableName ); TableName[ColumnName] = " This Value " )
The issue I have with this is the Unique table contains over 300 unique entries, so I can't make this work.
Example (The Count column is what I'm trying to create)
Query 1
cust_company_descr
Company A
Company B
Company A
Company C
Company B
Company A
Unique
Company_____Count
Company A_____3
Company B_____2
Company C_____1
Any help is gratefully received.
I have an error with my trigger. it show
LINE/COL ERROR
-------- --------------------------------------------
2/2 PL/SQL: SQL Statement ignored
2/6 PL/SQL: ORA-00922: missing or invalid option
I want this trigger run if the customertype is member.
Here are my table
TABLE CUSTOMER
CREATE TABLE CUSTOMER
(CUSTOMERID VARCHAR2(100) primary key,
CUSTOMERNAME VARCHAR2(50),
CUSTOMERADDRESS VARCHAR2(100),
CUSTOMERPHONE VARCHAR2(15),
CUSTOMEREMAIL VARCHAR2(50),
CUSTOMERTYPE VARCHAR2(15)
)
TABLE MEMBER
CREATE TABLE MEMBER
(MEMBERID VARCHAR2(100),
USERNAME VARCHAR2(25),
PASSWORD VARCHAR2(10),
CUSTOMERID VARCHAR2(100),
CONSTRAINT FK_Member Foreign Key (CustomerId)
REFERENCES Customer(CustomerId)
);
This is my trigger
CREATE or replace TRIGGER insertMember
after insert ON CUSTOMER
for each row
BEGIN
SET NOCOUNT ON
If (select customertype from customer) = 'member'
begin
INSERT INTO MEMBER (customerid ) values
(:new.customerid);
END insertMember;
/
I have a table 'Person' with columns as 'Person_id as primary key','DOB' and 'place' as follows:
'Person'
Person_id |Name|DOB | place
Another table is "employee" where emp_id is primary key as follows:
'employee'
Person_id |emp_id|dateofjoin
And one more table "Details":
'Details'
emp_id|competency|rating
Now what i want is once i add the 'Person' table details the rest of the two tables as'employe' and 'Details' to get updated also with respect to the new Person added in the Person table. So, how can i have this using sql query? Also i want to clear that i am not very much familiar with database.
I think your after something like this ( for SQL Server ):
Create Procedure dbo.CreateMyEmployee ( #empName varchar(50),
#dob datetime,
#doj datetime,
#place as varchar(100),
#competency varchar(100),
#rating int)
As
Begin
Declare #empId int
Begin Transaction
Begin Try
Insert into Person (Name, DOB, Place)
Values ( #empName, #dob, #place)
Insert into employe (Name, dateofJoin) -- Assuming emp_id is identity columen
Values ( #empName, #doj)
Select #empId = SCOPE_IDENTITY()
Insert Into Details(emp_id, competency, rating)
Values (#empId, #competency, #rating)
Commit transaction
End Try
Begin Catch
Rollback Transaction
SELECT ERROR_NUMBER() AS ErrorNumber, ERROR_MESSAGE() AS ErrorMessage
End Catch
End