Explanation of Oslo error "M2037: SQL Generation Internal Error: Missing generator for variable"? - oslo

In Microsoft Oslo SDK CTP 2008 (using Intellipad) the following code compiles fine:
module T {
type A {
Id : Integer32 = AutoNumber();
} where identity Id;
As : A*;
type B {
Id : Integer32 = AutoNumber();
// A : A;
// } where A in As && identity Id;
} where identity Id;
Bs : B*;
type C {
Id : Integer32 = AutoNumber();
B : B;
} where B in Bs && identity Id;
Cs : C*;
}
and results in the following Reach SQL output:
set xact_abort on;
go
begin transaction;
go
set ansi_nulls on;
go
create schema [T];
go
create table [T].[As]
(
[Id] int not null identity,
constraint [PK_As] primary key clustered ([Id])
);
go
create table [T].[Bs]
(
[Id] int not null identity,
constraint [PK_Bs] primary key clustered ([Id])
);
go
create table [T].[Cs]
(
[Id] int not null identity,
[B] int not null,
constraint [PK_Cs] primary key clustered ([Id]),
constraint [FK_Cs_B_T_Bs] foreign key ([B]) references [T].[Bs] ([Id])
);
go
commit transaction;
go
But after changing the commented line in module T as follows
A : A;
} where A in As && identity Id;
// } where identity Id;
the error message "M2037: SQL Generation Internal Error: Missing generator for variable 'A'" is displayed (in Intellipad's Reach SQL Window).
Any Ideas?
Regards, tamberg

I think what you want is:
type A {
Id : Integer32 = AutoNumber();
} where identity Id;
As : A*;
type B {
Id : Integer32 = AutoNumber();
A : A;
} where identity Id;
Bs : (B where value.A in As)*;
type C {
Id : Integer32 = AutoNumber();
B : B;
} where identity Id && B in Bs;
Cs : (C where value.B in Bs)*;
Note that the constraints are on the externs, not the types here. I was able to get similar code when the constraints where on the types but not able to go more than one relationship deep. Moving them to the externs seems correct and generates the expected Reach SQL.

http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/05103bf8-4e0f-4976-bcdd-2c724cb08738/

Related

Sonar issue Assignments should not be redundant (squid:S4165)

private void updateEmployee(String employeeCode, UpdateUserDto updateUserDto){
Employee emp = getEmpDetails(employeeCode);
emp = updateMobile&Email(emp, updateUserDto.getMobile(), updateUserDto.getMail());
// Remove this useless assignment; "emp" already holds the assigned value along all execution paths.
...
...
emp.setisActive(updateUserDto.getIsActive());
empRepo.save(emp);
}
private Employee updateMobile&Email(Employee emp, String mobile, String mail){
if(emp.getMobile() == null && (mobile != null || mobile.isBlank())){
emp.setMobile(mobile);
}
if(emp.getMail() == null && (getMail != null || getMail.isBlank())){
emp.setMail(mail);
}
return emp;
}
Due to connectivity complexity I made some functions. Above one is just for example, the code is bigger
Remove this useless assignment; "emp" already holds the assigned value along all execution paths.
At line 2 of updateEmployee()
Sonar issue details
Assignments should not be redundant (squid:S4165)
Noncompliant
a = b;
c = a;
b = c; // Noncompliant: c and b are already the same
Compilant
a = b;
c = a;
The emp parameter will be passed by reference into the updateMobile&Email method, meaning the line 2 assignment is unnecessary.
I suggest updating updateMobile&Email to have a void return type.

How to fix this Purescript error: Could not match {...} with (...)?

I have a state for a halogen component including a lens like this:
import Optic.Core (Lens', lens)
type State =
{ userName :: String
, password :: String
, formError :: String
}
_userName :: Lens' State String
_userName = lens _.userName (\r str -> r { userName = str })
And I want to modify the state in the eval function of the same component like this:
eval :: forall eff.
Query ~> ParentDSL State Query UserNameField.Query Slot Void (Aff (console :: CONSOLE , ajax :: AJAX | eff))
eval = case _ of
HandleInput userName next -> do
-- this code causes trouble:
_userName .= userName
-- while this code works:
-- modify (set _userName userName)
pure next
However, I get the error message:
Could not match type
{ userName :: String
, password :: String
, formError :: String
}
with type
( userName :: String
, password :: String
, formError :: String
)
while trying to match type t3
{ userName :: String
, password :: String
, formError :: String
}
with type t2
while checking that expression _userName
has type (t0 -> t1) -> t2 -> t2
in value declaration eval
where t1 is an unknown type
t0 is an unknown type
t2 is an unknown type
t3 is an unknown type
[TypesDoNotUnify]
Note the difference between { and ( (took me a while). I don't even know what the latter type actually means and I have no clue why this error is introduced by a MonadState-based lense.
Mystery solved: I unintentionally mixed two packages
purescript-lens and purescript-profunctor-lenses. My lenses came from the former and the assign function (.=) is only present in the latter, which was installed apparently as some implicit subdependency.

Using snmpgetnext on a table

I am writing my own MIB Module containing a table with 2 columns. Using snmptable works just fine and retrieves all values of the table with all the rows.
But with snmpgetnext I can only retrieve the first row of the table.
snmpgetnext -v2c -c public localhost sensorTable
MY-PERSONAL-MIB::sensorVoltage."1" = STRING: "2.3V"
To retrieve the next value I must run:
snmpgetnext -v2c -c public localhost sensorVoltage."2"
MY-PERSONAL-MIB::sensorTemperature."1" = "3.2C"
Running snmpgetnext -v2c -c public localhost sensorVoltage."1" would result in sensorVoltage."1" again, the same for sensorTemperature."1".
snmpgetnext -v2c -c public localhost sensorTemperature."2"
SNMPv2-MIB::snmpSetSerialNo.0 = INTEGER: 1664041205
Also, I ran snmptable -CB so the manager only uses GETNEXT to retrieve the table values. This works fine as well.
So why can't I retrieve the single values with a simple snmpgetnext request?
As last, snmpget doesn't work at all. I get the following error:
snmpget -v2c -c publicl localhost sensorTemperature."1"
MY-PERSONAL-MIB::sensorTemperature.1 = No such Instance currently exists at this OID
At last, my code I use for my MIB-Module. I use the handler to read data from a file and create a table struct through it. I tried using snmpgetnext with a table created through the initialization routine resulting in the same problem, so the handler routine shouldn't be the issue here but I still appended it just for completion and well, who knows!
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "sensorTable.h"
#define firstEntryRow 2
netsnmp_table_data_set *table_set;
void
initialize_table_sensorTable(void)
{
netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_X_SOCKET, "tcp:localhost:705");
const oid sensorTable_oid[] = { 1 ,3 ,6 ,1 ,4 ,1 ,8072 ,1259 ,1 ,1 };
table_set = netsnmp_create_table_data_set("sensorTable");
netsnmp_table_row *row;
table_set->allow_creation = 1;
DEBUGMSGTL(("initialize_table_sensorTable",
"adding indexes to table sensorTable\n"));
netsnmp_table_dataset_add_index(table_set,
ASN_OCTET_STR);
DEBUGMSGTL(("initialize_table_sensorTable",
"adding column types to table sensorTable\n"));
netsnmp_table_set_multi_add_default_row(table_set,
COLUMN_SENSORVOLTAGE, ASN_OCTET_STR, 1,
NULL, 0,
COLUMN_SENSORTEMPERATURE, ASN_OCTET_STR, 1,
NULL, 0,
0);
netsnmp_register_table_data_set(netsnmp_create_handler_registration("sensorTable", sensorTable_handler,
sensorTable_oid,
OID_LENGTH(sensorTable_oid),
HANDLER_CAN_RWRITE),
table_set, NULL);
row = netsnmp_create_table_data_row();
netsnmp_table_row_add_index(row, ASN_OCTET_STR, "1",
strlen("1"));
netsnmp_set_row_column(row, 2, ASN_OCTET_STR,
"5.9V", strlen("5.9V"));
netsnmp_set_row_column(row, 3, ASN_OCTET_STR,
"21.5C", strlen("21.5C"));
netsnmp_table_dataset_add_row(table_set, row);
}
void
init_sensorTable(void)
{
initialize_table_sensorTable();
}
int
sensorTable_handler(
netsnmp_mib_handler *handler,
netsnmp_handler_registration *reginfo,
netsnmp_agent_request_info *reqinfo,
netsnmp_request_info *requests) {
netsnmp_table_row *row, *tempRow;
if( table_set != NULL )
{
for ( tempRow = table_set->table->first_row;
tempRow; tempRow = tempRow->next )
{
row = netsnmp_table_data_set_get_first_row(table_set);
netsnmp_table_dataset_remove_row(table_set, row);
}
}
/* Start reading "input.txt */
char sensorValues[32];
char *singleValue;
FILE *f = fopen("/home/supra/Desktop/input.txt", "r");
/* check if the file was found */
if( f == NULL ) {
printf("Error opening file!\n");
exit(EXIT_FAILURE);
}
/* check if the file is empty */
if ( fgets( sensorValues, sizeof(sensorValues), f) == NULL )
{
printf("Warning: File is empty!\n");
exit(EXIT_FAILURE);
}
/* if the file is not empty, create a row and start
* breaking the string into words. Fill the row with the words
* and add it to the table. */
do
{
int rowEntries = firstEntryRow;
singleValue = strtok( sensorValues, " ");
row = netsnmp_create_table_data_row();
netsnmp_table_row_add_index(row, ASN_OCTET_STR, singleValue, strlen(singleValue) );
singleValue = strtok( NULL, " ");
/* Fill the row with values */
while(singleValue != NULL)
{
netsnmp_set_row_column(row, rowEntries, ASN_OCTET_STR, singleValue, strlen(singleValue) );
rowEntries++;
singleValue = strtok(NULL, " ");
}
netsnmp_table_dataset_add_row(table_set, row);
} while( fgets( sensorValues, sizeof(sensorValues), f) != NULL);
fclose(f);
return SNMP_ERR_NOERROR;
}
Regarding :
So why can't I retrieve the single values with a simple snmpgetnext request?
Quoting man snmpgetnext
DESCRIPTION
snmpget is an SNMP application that uses the SNMP GETNEXT request to query for information on a network entity. One or more
object identifiers (OIDs) may
be given as arguments on the command line. Each variable name is given in the format specified in variables(5). For each one, the
variable that is lexicographically "next" in the remote entity's MIB will be returned. For example:
snmpgetnext -c public zeus interfaces.ifTable.ifEntry.ifType.1
will retrieve the variable
interfaces.ifTable.ifEntry.ifType.2
In other words its job is to get one thing back.
If you want to use it to get a full table, you need to invoke it multiple times. Quoting man page for snmptable :
snmptable is an SNMP application that repeatedly uses the SNMP GETNEXT or GETBULK requests to query for information on a network entity.

Return one value from a table using a function

I have this code:
public int GetUserIdByEmail(string email)
{
using (SqlConnection conn = new SqlConnection(ZincModelContainer.CONNECTIONSTRING))
{
using (SqlCommand cmd = conn.CreateCommand())
{
conn.Open();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = String.Concat("SELECT [Zinc].[GetUserIdByEmail] (", email, ")"); //is this correct??? the problem lies here
return (int)cmd.ExecuteScalar();
}
}
}
I get the error here in above code. this is still not right
I have my function now as below suggested by veljasije
thanks
Modify your procedure:
CREATE PROCEDURE [Zinc].[GetUserIdByEmail]
(
#Email varchar (100)
)
AS
BEGIN
SELECT zu.UserId from Zinc.Users zu WHERE Email = #Email
END
And in you code change type of parameter from NVarChar to VarChar
Function
CREATE FUNCTION [Zinc].[GetUserIdByEmail]
(
#Email varchar(100)
)
RETURNS int
AS
BEGIN
DECLARE #UserId int;
SET #UserId = (SELECT zu.UserId from Zinc.Users zu WHERE Email = #Email)
RETURN #UserId
END
Firstly, specify the size for the #Email parameter in the sproc - without it, it will default to 1 character which will therefore not be attempting to match on the value you are expecting it to.
Always specify the size explicitly to avoid any issues (e.g. per Marc_s's comment, plus demo I blogged about here, it behaves differently bu defaulting to 30 chars when using CAST/CONVERT )
Secondly, use SqlCommand.ExecuteScalar()
e.g.
userId = (int)cmd.ExecuteScalar();

arithmetic overflow error converting numeric to data type datetime

I've this simple update statement
UPDATE EmpSchedual2
SET AttH = 0, AttM = 0, AttC = 'AM', DisH = 0, DisM = 0, DisC = 'PM', changeDate = 0
WHERE (EmpID = 4) AND (WeekDay = 2)
I get this error when run:
arithmetic overflow error converting numeric to data type datetime
and this is the table definition:
Column Name DataType
Serial int
EmpID int
WeekDay int
AttH int
AttM int
AttC char
DisH int
DisM int
DisC char
changeDate int
WorkM int
Can someone figure why i receive this error?
Thank you
I'm sorry for posting such question.
I found the error in a trigger attached to that table

Resources