I have a number of tables that are linked by a common field called StockCode. The StockCode contains maybe one and sometimes 2 single quotes. When I try to read the related tables using the StockCode as the key I get an error.
E.g.
Table: Stock, field: StockCode = Earl's Stock
Table: Sales, field: StockCode = Earl's Stock
If I read the Stock and try to find the StockCode on the Sales Table I get an error.
Related
I'm trying to build a farm management app with Laravel and I need help with my database schema. Here are some of my tables
users (id, name)
products (id, trade_name, state, category_id)
expenses (id, category_id)
activities (id, equipment_id)
equipment (id, name, type)
Equipment can either be a tractor or implement. For tractors I want to have the following columns total_distance_traveled and a fuel_quantity
Product can be fertilizers, Insecticide, Herbicides and their state can either be liquid or solid and I want to to keep track of quantity of my products as well (quantity is in liters or kilograms)
I'm not sure if it's a good idea to include the total_distance_traveled and fuel_quantity in the equipment table and a quantity column in the products table
I've thought of creating a new stocks table and have a stockable_id, and stockable_type but that would only work for quantity since it's kind of a common column between products and equipment tables
I'ld like to keep track of total_distance_traveled, fuel_quantity for the equipment table and quantity for products table. e.g. when the total_distance_traveled is changed I'd like to know when that happened so I can have logs of my activities over time
You can create a stock table if you know that this table will only use for product and equipements:
id
stockable_id
stockable_type
quantity
total_distance_traveled // nullable as they have value only when item will be tractor,
fuel_quantity // nullable as they have value only when item will be tractor,
but for same table or if you think there can come other data too then a you can have a json column in which you can save extra attributes for specific item
id
stockable_id
stockable_type
quantity
sepecific_attributes //json where you can save any additional values based on your product
"{'total_distance_traveled':'100','fuel_quantity':20,'some_other_info':'value'}
Am trying execute a sql query on oracle database and inserting the result into another table, for my trial am just performing a simple query as
SELECT 1 AS count
FROM dual
and trying to insert that into a single column table which has the name COUNT.
The content of the record on Nifi seems to be as follows
[
{
"COUNT" : "1"
}
]
but the logs keeps throwing the error
due to java.sql.SQLDataException:
None of the fields in the record map to the columns defined by
the schema_name.table_name table:
any ideas ?
I believe you get that same error message if your table name doesn't match. The Translate Field Names property only translates the fields (columns), not the table name. Try specifying the schema/table in uppercase to match what Oracle is expecting.
I have table in mysql with columns "name" and "views". I want sum views from serial whose name is in "name" column and display list of serials with views by echo from the most popular.
I think you are looking for this query:
SELECT name, SUM(views) as total_views
FROM serial
GROUP BY name
ORDER BY total_views DESC
I want to create a check constraint on several thousand columns in a database, but all constraints needs a name that is unique in the database. I wanted to use a guid, but because of limitations in Oracle, the name can't be longer than 30 characters.
Here is an example of the syntax:
CREATE TABLE mytable
(
col1 DATE
DEFAULT to_date('19000101', 'yyyymmdd')
CONSTRAINT unique_name_needed CHECK(col1 = TRUNC(col1))
NOT NULL
)
We use a 3 letter short name for every table. These three letters we use to name our constraints. So the short name for mytable could be mtb.
Constraint names are then:
Primary: mtb_pk
Unique: mtb_uk
Foreign: mtb_otb_fk where otb is the short name of the other table.
The trick of course is to come up with unique short names for every table.
I am having troubles when i want to create a named calculation from two different tables.
I have the table "CallesDim" with an id(PK) and a description and the table "UbicacionesDim" with an id (PK), another id (FK to "CallesDim") and a description:
--
CallesDim
id PK
Descripcion VARCHAR
--
UbicacionesDim
id PK
CalleId FK to id from CallesDIM
Altura INT
--
I want to concatenate "Descripcion" from "CallesDim" with Altura from "UbicacionesDim".
I try doing this:
CallesDim.Descripcion + ' ' + CONVERT(VARCHAR,UbicacionesDim.Altura)
but i am having the following error:
the multi-part identifier "CallesDim.Descripcion" could not be bound
Any ideas?
Thanks!
In a named calculation you can only access columns from the table that it is defined on.
Which record of the other table should it take in case it would accept columns from other tables? How should it join? All this cannot be configured.
If you need to join two (or more) tables, you can define a named query that can contain joins and access as many tables as you like. A named query can contain everything that you can state in a single select statement.