Joining Two Tables with Different Data types MS ACCESS - 'type mismatch in expression' error - sql

I'm trying to run a query on access using two live CSVs which has a common field with different data types(numbers and short text). I've discovered that you can join different data types using 'CStr'. I've added the 'CStr' to my code on the sql view. Please find the see the code below.
This gives me the output i want on access and i can now see the output when i click on 'datasheet view'. However, when i try to export the data (i'm actually trying create a export specification so that i can export a csv using macro) as a csv i'm getting a 'type mismatch in expression' error message.
Here's my code:
SELECT Sixthform_Reg_Year_Groups.Forename,
Sixthform_Reg_Year_Groups.Surname,
Sixthform_Reg_Year_Groups.Reg, Students.objectGUID
FROM Sixthform_Reg_Year_Groups INNER JOIN
Students
ON CStr(Sixthform_Reg_Year_Groups.Person_id) = Students.employeeID
WHERE (((Sixthform_Reg_Year_Groups.Reg)="12E"));`
I've also tried adding 'CStr' on both sides. as below, but experiencing the same issue.
FROM Sixthform_Reg_Year_Groups INNER JOIN
Students
ON CStr(Sixthform_Reg_Year_Groups.Person_id) = CStr (Students.employeeID)
WHERE (((Sixthform_Reg_Year_Groups.Reg) = "12E"));`
And of course, without 'CStr' i can't even view the output on 'datasheet view'. Every time when i click on datasheet view it's giving me the 'type mismatch in expression' error message.
Any help in resolving this would be much appreciated.
Thanks in advance.
Additinal info: the data types are EmpoyeeID is 'Short Text' and Person ID is 'Number'

Try the other way round:
ON Sixthform_Reg_Year_Groups.Person_id = Val(Students.employeeID)
and/or prevent Null errors:
ON CStr(Nz(Sixthform_Reg_Year_Groups.Person_id, 0)) = Nz(Students.employeeID)

OK guys, I've managed to resolve this issue, It turned out to be simple in the end. This is what i did.
Basically, I re imported the linked table. This time on the import window i clicked on 'advanced' and changed the data type to 'short text' on the 'person ID' column to match with the 'employeeID' data type. And then all problems solved. (I didn't know you could do this)
Thank you all for your replies. Going through your comments guided me to the right path.
Much appreciated.

Related

Error : Field "S_MARA-MATNR" is unkown during FOR statement

DATA: t_mara type STANDARD TABLE OF mara WITH EMPTY KEY.
DATA(t_data1) = VALUE ty_data( FOR s_mara IN t_mara ( s_mara–matnr ) ).
I am trying to implement a similar code using FOR statement but I am getting an error that the field is unknown in the work area even though it would be declared inline.
Can you please let me know what went wrong? This is my first time I am facing this error on FOR loop.
Not sure because you are not providing too much detail but try this:
DATA t_mara type STANDARD TABLE OF mara WITH EMPTY KEY.
DATA(t_data1) = VALUE ty_data( FOR s_mara IN t_mara ( matnr = s_mara-matnr ) ).

Why am I getting a `Data type mismatch` error when I add "CF" to the end of my search string in a SQL statement in Access?

The following query (qryCurLotNewProducts) produces a data set that I want process further with another query (qryBNP_CFRecordset):
//qryCurLotNewProducts
SELECT tblNewProducts.*
FROM tblNewProducts INNER JOIN tblCurLot ON (tblCurLot.CatalogNum = tblNewProducts.CatalogNum) AND
(tblNewProducts.LotNum = tblCurLot.CurLot);
When I run this second query to list only the "CF" products found in the first query, I get the `Data type mismatch in criteria expression' error.
//qryBNP_CFRecordset
SELECT qryCurLotNewProducts.*, tblABCategory.UNSPSC, tblAmount.ProductSize
FROM tblAmount RIGHT JOIN (tblABCategory RIGHT JOIN qryCurLotNewProducts ON tblABCategory.ABCategory = qryCurLotNewProducts.ABCategory) ON tblAmount.Amount = qryCurLotNewProducts.Amount
WHERE (((qryCurLotNewProducts.CatalogNum) Like "A700-###CF") AND ((qryCurLotNewProducts.DateEntered) Between #1/1/2000# And #3/1/2020#))
ORDER BY qryCurLotNewProducts.CatalogNum, Abs(qryCurLotNewProducts.LotNum);
If I remove the CF from the search string (so "A700-###"), the query correctly outputs a list containing all items that contain that pattern:
If I use strings like "A700-####F" or "A700-###ZZ" or other combinations like that, I don't get an error but rather an empty results set.
Notably, "A700-001CF", "A700-002CF", etc all create the data type error. It seems there is something about the CF key combination that is causing trouble.
Has anybody else ever seen this issue? Do I need to use some kind of delimiter to tell SQL to not view CF as some kind of special switch?
Abs(qryCurLotNewProducts.LotNum) wont work with the values for Products ending in CF. Your LotNum-Column has a text-type.
Edit: Your LotNum-Column has a text-type as you can see in your first screenshot.

Error: Not found: Dataset my-project-name:domain_public was not found in location US

I need to make a query for a dataset provided by a public project. I created my own project and added their dataset to my project. There is a table named: domain_public. When I make query to this table I get this error:
Query Failed
Error: Not found: Dataset my-project-name:domain_public was not found in location US
Job ID: my-project-name:US.bquijob_xxxx
I am from non-US country. What is the issue and how to fix it please?
EDIT 1:
I change the processing location to asia-northeast1 (I am based in Singapore) but the same error:
Error: Not found: Dataset censys-my-projectname:domain_public was not found in location asia-northeast1
Here is a view of my project and the public project censys-io:
Please advise.
EDIT 2:
The query I used to type is based on censys tutorial is:
#standardsql
SELECT domain, alexa_rank
FROM domain_public.current
WHERE p443.https.tls.cipher_suite = 'some_cipher_suite_goes_here';
When I changed the FROM clause to:
FROM `censys-io.domain_public.current`
And the last line to:
WHERE p443.https.tls.cipher_suite.name = 'some_cipher_suite_goes_here';
It worked. Shall I understand that I should always include the projectname.dataset.table (if I'm using the correct terms) and point the typo the Censys? Or is this special case to this project for some reason?
BigQuery can't find your data
How to fix it
Make sure your FROM location contains 3 parts
A project (e.g. bigquery-public-data)
A database (e.g. hacker_news)
A table (e.g. stories)
Like so
`bigquery-public-data.hacker_news.stories`
*note the backticks
Examples
Wrong
SELECT *
FROM `stories`
Wrong
SELECT *
FROM `hacker_news.stories`
Correct
SELECT *
FROM `bigquery-public-data.hacker_news.stories`
In Web UI - click Show Options button and than select your location for "Processing Location"!
Specify the location in which the query will execute. Queries that run in a specific location may only reference data in that location. For data in US/EU, you may choose Unspecified to run the query in the location where the data resides. For data in other locations, you must specify the query location explicitly.
Update
As it stated above - Queries that run in a specific location may only reference data in that location
Assuming that censys-io.domain_public dataset has its data in US - you need to specify US for Processing Location
The problem turned out to be due to wrong table name in the FROM clause.
The right FROM clause should be:
FROM `censys-io.domain_public.current`
While I was typing:
FROM domain_public.current
So the project name is required in the FROM and `` are required because of - in the project name.
Make sure your FROM location contains 3 parts as #stevec mentioned
A project (e.g. bigquery-public-data)
A database (e.g. hacker_news)
A table (e.g. stories)
But in my case, I was using the LegacySql within the Google script editor, so in that case you need to state that to false, for example:
var projectId = 'xxxxxxx';
var request = {
query: 'select * from project.database.table',
useLegacySql: false
};
var queryResults = BigQuery.Jobs.query(request, projectId);
check exact case [upper or lower] and spelling of table or view name.
copy it from table definition and your problem will be solved.
i was using FPL009_Year_Categorization instead of FPL009_Year_categorization
using c as C and getting the error "not found in location asia-south1"
I copied with exact case and problem is resolved.
On your Big Query console, go to the Data Explorer on the left pane, click the small three dots, then select query option from the list. This step confirms you choose the correct project and dataset. Then you can edit the query on the query pane on the right.
may be dataset name changed in create dataset option. it should be US or default location
enter image description here

Access 2007 CInt Query Issue

There is probably a pretty basic answer to this question, but I'm pulling my hair out trying to resolve my issue. I'm using Access 2007.
My query is shown below:
SELECT Pricing.*
FROM OrderReceipt_be
INNER JOIN Pricing ON CInt(OrderReceipt_be.[Pricing Table Option Code]) = Pricing.ID
WHERE OrderReceipt_be.[PO_Number] = PONumber();
For whatever reason, the [PO_Number] field is stored as text against my key which is a long int. This is why I'm trying to convert it to an integer.
However, when I run my query I get the error
"Compile error. in query expression CInt(OrderReceipt_be.[Pricing
Table Option Code]) = Pricing.ID".
I've done some basic research and it seems like the most common issue is that I'm missing a reference library. Howver, having gone through the entire list, I don't see any references that are tagged as "Missing" so it must be something else. I've also tried disabling and re-enabling all enabled reference libraries to see if that helps, but so far nothing.
Any thoughts?
If you can have codes of Null, try:
SELECT Pricing.*
FROM OrderReceipt_be
INNER JOIN Pricing ON Val(Nz(OrderReceipt_be.[Pricing Table Option Code])) = Pricing.ID
WHERE OrderReceipt_be.[PO_Number] = PONumber();
or try the reverse conversion:
SELECT Pricing.*
FROM OrderReceipt_be
INNER JOIN Pricing ON OrderReceipt_be.[Pricing Table Option Code] = CStr(Pricing.ID)
WHERE OrderReceipt_be.[PO_Number] = PONumber();

Sap Code Inspector - Generating a table of all PCodes linked to the classes

I have problems to read the error codes and corresponding messages of SCI message classes.
Is there an way to easy access those?
I'm using "Praxishandbuch SAP Code Inspector" as a reference, but in that regard it is of no help.
I looked in Se11 but the information to the messages isn't helpful.
Has someone an approch to build such a table?
You can try this, perhaps it will work for you. I use the code below to get the access to all the errors found by Code Inspector for particular user(s):
data: ref_inspec_a type ref to cl_ci_inspection.
ref_inspec_a = cl_ci_inspection=>get_ref(
p_user = pa_iuser
p_name = pa_inam
p_vers = pa_ivers ).
data: ls_resp type scir_resp,
lt_resp type scit_resp.
clear: ls_resp, lt_resp.
ls_resp-sign = 'I'.
ls_resp-option = 'EQ'.
ls_resp-low = pa_fuser.
insert ls_resp into table lt_resp.
call method ref_inspec_a->get_results
exporting
p_responsibl = lt_resp
exceptions
insp_not_yet_executed = 1
overflow = 2
others = 3.
Playing around with LT_RESP you can get results for more users at the same time.
After you execute the code above, you can check the attributes SCIRESTPS and SCIRESTHD of the object REF_INSPEC_A. These are the large tables, which contain the result data of the SCI check. You can either work with them on your own, or you can simply pass the object REF_INSPEC_A into the function module SCI_SHOW_RESULTS to get regular SCI user interface.
I found out that you can get all the changeable messages (found in SCI GoTo/Management Of/ Message Priorities) can be read from the scimessages attribute of the test classes.
With this help you can get about 60% of all errors.