dql


Symfony2 - Custom DQL function not found


I followed this tuto : http://iksela.tumblr.com/post/4985265226/custom-dql-functions-nvl-convert-to-number.
But I still get the same error:
SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION my_project.TO_NUMBER does not exist
This is my code:
in My_project\MyBundle\DoctrineFunctions\ToNumberFunction.php :
namespace My_project\MyBundle\DoctrineFunctions;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
class ToNumberFunction extends FunctionNode {
public $field;
/**
* Parse DQL Function
*
* #param \Doctrine\ORM\Query\Parser $parser
*/
public function parse (\Doctrine\ORM\Query\Parser $parser)
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->field = $parser->StringPrimary();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
/**
* Get SQL
*
* #param \Doctrine\ORM\Query\SqlWalker $sqlWalker
*
* #return int
*/
public function getSql (\Doctrine\ORM\Query\SqlWalker $sqlWalker)
{
return 'TO_NUMBER('.$this->field->dispatch($sqlWalker).')';
}
}
In my config.yml, I have the following :
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
mappings:
..........
tree:
loggable:
.......
dql:
numeric_functions:
TO_NUMBER: My_project\MyBundle\DoctrineFunctions\ToNumberFunction
Try like this:
orm:
auto_generate_proxy_classes: %kernel.debug%
entity_managers:
default:
mappings:
..........
tree:
loggable:
.......
dql:
numeric_functions:
TO_NUMBER: My_project\MyBundle\DoctrineFunctions\ToNumberFunction
Or like this:
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: default
dql:
numeric_functions:
TO_NUMBER: My_project\MyBundle\DoctrineFunctions\ToNumberFunction
if you dont have multimple entity managers is not necesary to declare:
default_entity_manager: default.
http://symfony.com/doc/current/cookbook/doctrine/custom_dql_functions.html
It looks like the Doctrine code is working fine, but TO_NUMBER isn't a function recognised by the database you are using.
TO_NUMBER appears to be an Oracle SQL specific function, so if you are using a different SQL database that is probably your issue.

Related Links

How to delete an acl from dm_acl object table
how to fetch the objects in dm_acl who grants the same sets of permission at the same time
Need a clarification on Auto Approval activity in documentum
count how many objects have been updated in Documentum
the fetched data from documentum (dm_acl Object Table) turns out to be null ? why?
Selecting N rows from each category DQL
the table is not registered or you do not have access to it (documentum)
DQL script for using order by clause to get case insensitive values
to calculate number of days between two dates in dql documentum
EMC Documentum DQL - How to delete repeating attribute
documentum dql return cabinets where r_accessor_permit > 2
Export the latest document to local machine
How to return cabinets not including hidden ones with DQL
Documentum DQL: Change user type
DQL query to find active users count
DQL: enable (return_top 10) performance impact

Categories

HOME
vue.js
npm
scipy
wildcard
firebase-app-indexing
aem
playframework
apollo
chaiscript
value
iis-7.5
dropbear
wysiwyg
data-synchronization
dlib
symfony2-easyadmin
scaling
r-lavaan
pyephem
prestodb
cython
header-files
kong
dss
classpath
pitest
roundcube
hibernate-cache
exponential
shapes
swiftcharts
transient
recurrence-relation
large-data
oscommerce
discord.net
jrules
openweathermap
archer
recycle-bin
maintenance
gmt
pdfkit
android-navigationview
tomee
packagemaker
galleriffic
zurb-foundation-apps
multifile-uploader
multilingual-app-toolkit
fps
faraday
project-online
elastix
amazon-kcl
usb-drive
coldfusion-7
datasnap
mysqldumpslow
graphical-logo
sysfs
hana-xs
pisa
java-melody
io.js
asp.net-mvc-scaffolding
multiple-login
haskell-platform
client-library
dropdownlistfor
feof
cadisplaylink
icefaces-3
responsetext
concurrent-programming
objectbrowser
clients
grooveshark
oggvorbis

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App