Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"} - vb.net

I'm trying to run the following in a VB.NET application using Entity Framework 6 on an Oracle database:
mrstage.ExecuteStoreCommand("DELETE FROM CB_LISTINGS WHERE ELIGIBLE={0}", eligible)
When it executes, I get the error: {"ORA-00936: missing expression"}
On my table, ELIGIBLE is of type VARCHAR2, and the eligible variable is a string.
If I hardcode the parameter, for example:
mrstage.ExecuteStoreCommand("DELETE FROM CB_LISTINGS WHERE ELIGIBLE='ECB'")
It works fine.
I'd be very grateful if someone can offer any suggestions.
Thanks!
James

In Oracle parameters are named differently, use a column parameter like :0 instead of {0}.
So your code is now:
mrstage.ExecuteStoreCommand(
"DELETE FROM CB_LISTINGS WHERE ELIGIBLE=:0",
eligible)

Related

select globalmap using tDBinput with Talend give the error: Invalid character constant

I have to remove the accents from the person's name, but I cannot apply the function in Talend while it works in SQL oracle.
this query works in my tDBInput component :
"SELECT '"+((String)globalMap.get("copyOfSORTIE.NOM"))+"' as nom_nom_compl,
'"+((String)globalMap.get("copyOfSORTIE.ENTETE"))+"' entete
FROM DUAL"
However, when I want to add the convert function, it doesn't work
this query does not work :
"SELECT '"+((String)globalMap.get(CONVERT("copyOfSORTIE.NOM",'US7ASCII')))+"' as nom_nom_compl,
'"+((String)globalMap.get("copyOfSORTIE.ENTETE"))+"' entete
FROM DUAL"
In my talend :
I am getting this error
What is the syntax for it to work?
Thank you!
Two things there :
I don't know the CONVERT method, but I can see that you are applying it to the key of your globalMap variable , and not the value (as if you wanted to convert "myKey" and not "myValue" which is attached to the key). Are you sure this is what you want to achieve ? if not, the syntax should be something similar to "SELECT CONVERT('"+((String)globalMap.get("copyOfSORTIE.NOM"))+"','US7ASCII') "
A useful java method implemented in talend is TalendString.removeAccents("") that you can apply directly on your talend variable, thus not using a SQL method.

F#: Cannot call stored procedure on MariaDB database using SQLProvider

I adapted my code from the instructions here.
open FSharp.Data.Sql
let [<Literal>] connection_str = "Server=localhost;Port=3306;SSL Mode=None;Uid=<UID>;Pwd=<PWD>;Database=<DB>"
type provider = SqlDataProvider<Common.DatabaseProviderTypes.MYSQL, connection_str>
let context = provider.GetDataContext()
context.Procedures.SpGetFrontContracts.Invoke(1)
Intellisense works until the period after SpGetFrontContracts. After that, nothing. Trying to compile, I get:
Error FS0039 The field, constructor or member 'Invoke' is not defined.
I am otherwise able to connect to the database and insert and query data, as long as I stick to tables and views.
SpGetFrontContracts is a valid stored procedure in my database (its actual name is sp_get_front_contracts, but the type provider seems to remove underscores). I can run it successfully using HeidiSQL. In case it's useful, here's the create code:
CREATE DEFINER=`<UID>`#`localhost` PROCEDURE `sp_get_front_contracts`(
IN `Group` INT
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
SELECT p.DateTime, p.Contract, p.Volume, c.Name
FROM tbl_contract_price_data p
INNER JOIN tbl_contracts c on p.Contract = c.ID
WHERE c.`Group` = `Group`
ORDER BY p.DateTime
LIMIT 1000;
END
I tried creating a simpler sproc that was named 'test', took no parameters, and simply ran a select statement. It showed up in the type provider under Procedures, but again I could not call Invoke on it.
My best guess is that Invoke is being inherited from some namespace or assembly reference I don't have, so I'm currently looking through the SqlProvider source to try to figure out what it might be. I'm currently referencing:
FSharp.Core
FSharp.Data
FSharp.Data.SqlProvider
mscorlib
System
System.Core
System.Data
System.Numerics
System.ValueTyple
System.Xml.Linq
Thank you for any suggestions.
Edit: It looks like the action is in SqlDesignTime.fs in a function called generateSprocMethod that starts on line 346. I'll try to figure out what's going on in there.
Edit: After three days banging my head against this, I gave up and just used MySQL Connector/NET.
I'm not sure about your underlying data or structures, but I know these are two other (correct) ways to solve it:
WHERE c.`Group` = `Group` -- what you have.
-- possible corrections:
WHERE c.`Group` = p.`Group` -- did you mean this?
WHERE c.`Group` = "Group" -- or this?

can not get a type of DBGrid Column, free pascal

I use a free pascal lazarus. I have DBGrid that loads table from DB. I created columns in designer and sqlqueries to these columns. Everything is excellent. But when i need to get type of field i get an error: Project Admin raised exception class 'External: SIGSEGV'. I do it like this:
var s:Variant;
begin
s:=Column.FieldName; // there is ok. I get right column name
s:=Column.Field.FieldKind;//here i get an error
Thanks.

NH QueryOver FetchMany Exception

I am trying to query a parent User and then their UserRoleMappings. I have something similar to the below statement:
Dim userObj As User = session.Queryable(Of User)().Where(Function(x) x.username.Equals("someone")).FetchMany(Function(y) y.UserRoleMappings).SingleOrDefault()
When I try to run this statement I get the following exception:
A fetch request must be a simple member access expression; 'Convert(y.UserRoleMappings)' is a UnaryExpression instead.
Parameter name: relatedObjectSelector
I can confirm that I got this to work in a C# Test Case, but unfortunately I need it to work in VB. Can anyone assist?

.NET ODBC Oracle Params getting param name returned by db provider- possible?

I'm converting some RDO code to ODBC Provider code in .NET.
The problem is parameter names were not specified in the orignal code, but param values were retrieved by parameter name after the command was executed.
Is there anyway to have parameter names populated by the provider once the command is executed so calling code can access params by name.
Let me show you an example of the declaration of param and accessing of it.
With rdqryClntBasic
.Parameters.Add(.CreateParameter) : .Parameters(0).Direction = ParameterDirection.Input
.Parameters(0).DbType = DbType.String
.Parameters(0).Value = sClntProdCd
End With
.EffectiveDate = ToDate(rdqryClntBasic.Parameters("dtEffDt").Value)
You can now see how this "used to work in RDO/VB". For some reason it would accept this and know what the param names were after execution. I imagine it had to do another round trip to the db to get this info.
Is there anyway to mimic this behaviour in .NET for ODBC Provider (using Oracle)? Or am I stuck manually specifying the param names in the code (I understand this is the better option, but wondering what the alternative is to match the original code as closely as possible).
No, parameters in ODBC are positional not by name.