I'm using Orbeon 3.9.0 PE RC1 with liferay-portal-6.0.5. When using Localhost Mysql persistence layer, its works.
but when try to use remote (Local Network) Mysql database, then Form builder can't publish any form and no data shown.
Properties-local.xml configaretion
`
Error Log sample.
2011-04-07 12:37:18,118 INFO ProcessorService - /fr/service/mysql/search/orbeon/builder - Received request
2011-04-07 12:37:20,853 ERROR SQLProcessor - PreparedStatement:
select
(
select count(*) from orbeon_form_data
where
(app, form, document_id, last_modified) in (
select app, form, document_id, max(last_modified) last_modified
from orbeon_form_data
where
app = ?
and form = ?
group by app, form, document_id)
and deleted = 'N'
) total,
(
select count(*) from (
select
data.created, data.last_modified, data.document_id
, extractValue(data.xml, '/*/xhtml:head/xforms:model[#id = ''fr-form-model'']/xforms:instance[#id = ''fr-form-metadata'']/*/application-name') detail_1
, extractValue(data.xml, '/*/xhtml:head/xforms:model[#id = ''fr-form-model'']/xforms:instance[#id = ''fr-form-metadata'']/*/form-name') detail_2
, extractValue(data.xml, '/*/xhtml:head/xforms:model[#id = ''fr-form-model'']/xforms:instance[#id = ''fr-form-metadata'']/*/title[#xml:lang = ''en'']') detail_3
, extractValue(data.xml, '/*/xhtml:head/xforms:model[#id = ''fr-form-model'']/xforms:instance[#id = ''fr-form-metadata'']/*/description[#xml:lang = ''en'']') detail_4
from orbeon_form_data data,
(
select max(last_modified) last_modified, app, form, document_id
from orbeon_form_data
where
app = ?
and form = ?
group by app, form, document_id
) latest
where
data.last_modified = latest.last_modified
and data.app = latest.app
and data.form = latest.form
and data.document_id = latest.document_id
and data.deleted = 'N'
order by created desc
)a
) search_total
2011-04-07 12:37:20,868 INFO DatabaseContext - Rolling back JDBC connection for datasource: jdbc/mysql.
2011-04-07 12:37:20,868 ERROR ProcessorService - Exception at oxf:/apps/fr/persistence/mysql/search.xpl (executing XSLT transformation)
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: FUNCTION orbeon.extractValue does not exist
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:874)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:169)
at org.orbeon.oxf.processor.sql.interpreters.QueryInterpreter.end(QueryInterpreter.java:600)
at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:540)
at org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
at org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
at org.orbeon.oxf.processor.sql.SQLProcessor$ForwardingContentHandler.endElement(SQLProcessor.java:635)
at org.orbeon.oxf.processor.sql.SQLProcessor$InterpreterContentHandler.endElement(SQLProcessor.java:542)
at org.orbeon.oxf.processor.sql.SQLProcessor$RootInterpreter.endElement(SQLProcessor.java:290)
at org.orbeon.oxf.xml.SAXStore.replay(SAXStore.java:288)
at org.orbeon.oxf.xml.SAXStore.replay(SAXStore.java:202)
at org.orbeon.oxf.processor.sql.SQLProcessor.execute(SQLProcessor.java:251)
at org.orbeon.oxf.processor.sql.SQLProcessor$1.readImpl(SQLProcessor.java:89)
at org.orbeon.oxf.processor.impl.ProcessorOutputImpl$TopLevelOutputFilter.read(ProcessorOutputImpl.java:263)
at org.orbeon.oxf.processor.impl.ProcessorOutputImpl.read(ProcessorOutputImpl.java:406)
at `
Since the error you're getting is FUNCTION orbeon.extractValue does not exist, I suspect this is because the other (remote) version of MySQL is an older version which doesn't support extractValue(). The MySQL persistence layer relies on XML functions that have been introduced in MySQL 5.1, so you need to be using the MySQL 5.1 (which was released in November 2008) or newer.
Related
(django 3.2.12, python 3.9.3, MySQL 8.0.28)
Imagine models like the following:
class User(models.Model):
email = models.EmailField(...)
created_datetime = models.DatetimeField(...)
class UserLog(models.Model):
created_datetime = models.DatetimeField(...)
user = models.ForeignKey('user.User' ...)
login = models.BooleanField('Log in' ..)
And the following query, destined to annotate each user in the queryset with the frequency of their logs(when log.login=True):
users = User.objects.filter(
Q(...)
).annotate(
login_count=Count('userlog', filter=Q(userlog__login=True)),
login_duration_over=Now() - F('created_datetime'),
login_frequency=ExpressionWrapper(
F('login_duration_over') / F('login_count'),
output_field=models.DurationField()
),
)
This results in a SQL error:
(1064, "You have an error in your SQL syntax;)
The generated SQL (fragment for login_frequency) looks like this:
(
INTERVAL TIMESTAMPDIFF(
MICROSECOND,
`user_user`.`created_datetime`,
CURRENT_TIMESTAMP
) MICROSECOND / (
COUNT(
CASE WHEN `user_userlog`.`login` THEN `user_userlog`.`id` ELSE NULL END
)
)
) AS `login_frequency`,
and MySQL does not seem to like it. A similar code works on SQLlite and, I am told on PG.
What is wrong with the ExpressionWrapper on MySQL, any idea?
Found a workaround:
users = User.objects.filter(
Q(...)
).annotate(
login_count=Count('userlog', filter=Q(userlog__login=True)),
login_duration_over=Now() - F('created_datetime'),
login_frequency=Cast(
ExpressionWrapper(
Cast(F('login_duration_over'), output_field=models.BigIntegerField()) / F('login_count'),
output_field=models.BigIntegerField()
),
output_field=models.DurationField()
)
)
this forces the DIVIDE operation to be performed db-side on bigints and once that is done, cast it back to a timedelta.
MySQL stopped screaming and the results are correct.
Even though that work, this feels ugly. Could there not be a better way?
My question has 2 parts, and i am unsure if it is my query which is causing the error or data adapter.
Part 1. I have a mySQL query which works fine on SQLyog, the query involves selection from tables existing in different databases. And both databases has been set to have the same accecss rights for the user account used at the connection string.
Below will be my query.
SELECT `portaldb`.`users`.`full_name` AS 'Name of User'
,`Systemrevamp`.`System_countries`.`CountryName` AS 'Quoted For'
,`Systemrevamp`.`uniquequote`.`UniqueQuote` AS 'System Quote ID'
, IF (
LEFT(`Systemrevamp`.`uniquequote`.`username`, 1) = ' '
,'Web Access'
,'Bulk Upload'
) AS 'Type'
,DATE_FORMAT(`Systemrevamp`.`uniquequote`.`insertedon`, '%d-%b-%Y') AS 'Quoted On'
FROM `portaldb`.`users`
INNER JOIN `Systemrevamp`.`uniquequote` ON TRIM(`Systemrevamp`.`uniquequote`.`UserName`) = `portaldb`.`users`.`usrname`
INNER JOIN `Systemrevamp`.`System_countries` ON `Systemrevamp`.`System_countries`.`Code` = `Systemrevamp`.`uniquequote`.`CountryCode`
INNER JOIN `portaldb`.`permission_details` ON `portaldb`.`permission_details`.`user_ID` = `portaldb`.`users`.`user_ID`
WHERE `portaldb`.`permission_details`.`group_ID` = '5'
AND `Systemrevamp`.`uniquequote`.`insertedon` >= (NOW() - INTERVAL 3 MONTH)
ORDER BY `portaldb`.`users`.`full_name` ASC,`Systemrevamp`.`uniquequote`.`insertedon` ASC
Visual studio keeps telling me there is syntax error and to check the version of SQL, but I am able to retrieve at the database.
Part 2. Below is a snippet of my code. My question for this part is, if the above query is used, what source table should I put for the data adapter to fill at 'XXX'?
myDataAdapter = New MySqlDataAdapter(strSQL, myConnection)
allUserDataset = New DataSet()
myDataAdapter.Fill(allUserDataset, "XXX")
gvAllQuotes.DataSource = allUserDataset
gvAllQuotes.DataBind()
Please let me know if more information is needed. Thank you.
SQL Code:
SELECT id, album_date AS timestamp, CONCAT((SELECT detail_value
FROM people_db.user_details_tbl WHERE detail_field = 'first_name' AND user_id = pictures_db.albums.owner), ' uploaded pictures!') AS title_html
FROM pictures_db.albums
WHERE id IN
(SELECT DISTINCT(album_id)
FROM pictures_db.album_pics
WHERE pic_id IN
(SELECT DISTINCT(picture_id)
FROM pictures_db.picture_access_tbl
WHERE grantee_group_id IN
(SELECT group_id
FROM people_db.group_membership_tbl
WHERE member_id = '2'
)
)
);
PHP Code:
$albums_sql = mysql_query("SELECT id, album_date AS timestamp, CONCAT((SELECT detail_value
FROM people_db.user_details_tbl
WHERE detail_field = 'first_name' AND user_id = pictures_db.albums.owner), ' uploaded pictures!') AS title_html
FROM pictures_db.albums
WHERE id IN (
SELECT DISTINCT(album_id)
FROM pictures_db.album_pics
WHERE pic_id IN (
SELECT DISTINCT(picture_id)
FROM pictures_db.picture_access_tbl
WHERE grantee_group_id IN (
SELECT group_id
FROM people_db.group_membership_tbl
WHERE member_id = '2'
)
)
)") or die(mysql_error());
When the PHP is run, the error is: Table 'pictures_db.albums' doesn't exist
I tried executing as the same user, regranted all permissions, and even flushed privileges. Works in shell, not in PHP.
Any ideas?
The error message is quite clear: MySQL sees the database pictures_db but not the table albums.
That could be due to permissions, but you seem to have checked that thoroughly.
Another possible reason is that the connection string you're using in PHP points to a different database instance than the one you're using at the command line. Perhaps the connection string still points to a different environment, such as DEV but you're in QA or points to an old test version of the database?
Do you call mysql_select_db() before running the query?
mysql_select_db('pictures_db');
I have an Access file running a query that does not have the same behavior on my desktop and on a server running Windows 2003 Server.
This query retrieves data from several MySQL linked tables using the MyODBC connector in order to insert it into another work table in my Access file.
On my desktop, everything just works fine, the query takes approximatively 20 seconds to run.
But when I try to do the same thing on the 2003 server, the query takes infinite time to run, and even after several minutes, it keeps running without populating my Access table.
Here is what is logged by the MySQL ODBC connector on my desktop :
SELECT `wsDispo_produits`.`code_fournisseur` ,`wsDispo_produits`.`code_int_produit` ,`wsDispo_produits`.`ref_fournisseur` ,`wsDispo_produits`.`qte_plaque` ,`wsDispo_produits`.`plaques_par_roll` ,`wsDispo_produits`.`prix` ,`wsDispo_produits`.`prix_etage` ,`wsDispo_produits`.`prix_roll` ,`wsProduits`.`designation` ,`wsProduits`.`taille_pot` ,`wsProduits`.`hauteur` ,`wsProduits`.`gencod` ,`wsFournisseur`.`raison_sociale` ,`wsProvenance`.`type_expedition` ,`wsProvenance`.`comm_produit` ,`wsProvenance`.`comm_transport` ,`wsProvenance`.`coef_transport` ,`wsTarifs_expedition`.`tarif` FROM `wsDetail_offre`,`wsZone_departements`,`wsDispo_produits`,`wsProduits`,`wsProvenance`,{oj `wsFournisseur` LEFT OUTER JOIN `wsTarifs_expedition` ON (`wsFournisseur`.`code_fournisseur` = `wsTarifs_expedition`.`code_fou` ) } WHERE ((((((`wsDetail_offre`.`code_int_produit` = `wsDispo_produits`.`code_int_produit` ) AND (`wsDetail_offre`.`code_fournisseur` = `wsDispo_produits`.`code_fournisseur` ) ) AND (((`wsZone_departements`.`departement` IN ('*' ,'75' ) ) AND ((`wsZone_departements`.`code_fournisseur` = `wsDispo_produits`.`code_fournisseur` ) AND (`wsZone_departements`.`code_zone` = `wsDispo_produits`.`code_zone` ) ) ) AND (`wsDispo_produits`.`code_fournisseur` = `wsFournisseur`.`code_fournisseur` ) ) ) AND (`wsDispo_produits`.`code_int_produit` = `wsProduits`.`code_produit` ) ) AND (`wsFournisseur`.`code_pro` = `wsProvenance`.`code_pro` ) ) AND (((`wsTarifs_expedition`.`departement` IS NULL ) OR ((`wsTarifs_expedition`.`departement` = '75' ) AND (`wsTarifs_expedition`.`nb_max_roll` = 3 ) ) ) AND ((`wsDetail_offre`.`code_liste` )= ANY (SELECT `wsOffre`.`code_liste` FROM `wsOffre` WHERE ((`wsOffre`.`date_deb` = {ts '2011-07-01 15:00:00'} ) AND (`wsOffre`.`date_fin` = {ts '2011-07-08 15:00:00'} ) ) ))) ) ;
COMMIT;
And next the log on the 2003 server :
SELECT `wsDetail_offre`.`code_liste` ,`wsDispo_produits`.`code_fournisseur` ,`wsDispo_produits`.`code_int_produit` ,`wsDispo_produits`.`ref_fournisseur` ,`wsDispo_produits`.`qte_plaque` ,`wsDispo_produits`.`plaques_par_roll` ,`wsDispo_produits`.`prix` ,`wsDispo_produits`.`prix_etage` ,`wsDispo_produits`.`prix_roll` ,`wsFournisseur`.`code_fournisseur` ,`wsFournisseur`.`raison_sociale` ,`wsFournisseur`.`code_pro` ,`wsProduits`.`designation` ,`wsProduits`.`taille_pot` ,`wsProduits`.`hauteur` ,`wsProduits`.`gencod` FROM `wsDetail_offre`,`wsZone_departements`,`wsDispo_produits`,`wsFournisseur`,`wsProduits` WHERE ((((`wsDetail_offre`.`code_int_produit` = `wsDispo_produits`.`code_int_produit` ) AND (`wsDetail_offre`.`code_fournisseur` = `wsDispo_produits`.`code_fournisseur` ) ) AND (((`wsZone_departements`.`departement` IN ('*' ,'75' ) ) AND ((`wsZone_departements`.`code_fournisseur` = `wsDispo_produits`.`code_fournisseur` ) AND (`wsZone_departements`.`code_zone` = `wsDispo_produits`.`code_zone` ) ) ) AND (`wsDispo_produits`.`code_fournisseur` = `wsFournisseur`.`code_fournisseur` ) ) ) AND (`wsDispo_produits`.`code_int_produit` = `wsProduits`.`code_produit` ) ) ;
SELECT `code_fou` ,`departement` ,`nb_max_roll` ,`tarif` FROM `wsTarifs_expedition` WHERE (`code_fou` = 1);
SELECT `code_pro` ,`type_expedition` ,`comm_produit` ,`comm_transport` ,`coef_transport` FROM `wsProvenance` WHERE (`code_pro` = 1);
SELECT `code_pro` ,`type_expedition` ,`comm_produit` ,`comm_transport` ,`coef_transport` FROM `wsProvenance` WHERE (`code_pro` = 1);
...
And it keeps running queries like the last two until I kill MsAccess.
I can't figure out why the query is not executed the same way. Already checked that same versions of both MsAccess and ODBC Connector are ran (MsAccess 2003 SP3 and MySQL Connector 5.1.8).
I ran the same test on another server running Windows Server 2008 and it works fine like my desktop. I even tried on the 2003 server to repair Office and uninstall / reinstall ODBC Connector.
The only thing I noticed is that on the 2003 server the query is transformed in order not to use the LEFT OUTER JOIN.
Has someone any explainations on this ?
Thanks.
I am executing the following code (names changed to protect the innocent, so the model structure might seem weird):
memberships =
models.Membership.objects.filter(
degree__gt=0.0,
group=request.user.get_profile().group
)
exclude_count =
memberships.filter(
member__officerships__profile=request.user.get_profile()
).count()
if exclude_officers_with_profile:
memberships = memberships.exclude(
member__officerships__profile=request.user.get_profile()
)
total_count = memberships.count()
which at this point results in:
OperationalError at /
(1054, "Unknown column 'U1.id' in 'on clause'")
The SQL generated is:
SELECT
COUNT(*)
FROM
`membership`
WHERE (
`membership`.`group_id` = 2 AND
`membership`.`level` > 0.0 AND
NOT (
`membership`.`member_id`
IN (
SELECT
U2.`member_id`
FROM
`membership` U0 INNER JOIN `officers` U2
ON (U1.`id` = U2.`member_id`)
WHERE U2.`profile_id` = 2
)
)
)
It appears that the SQL Join's ON statement is referencing an alias that hasn't been defined. Any ideas why!? I dropped my MySQL database and re-synced the tables from my models to try and ensure that there weren't any inconsistencies there.
The structure of the models I'm using are:
class Membership(models.Model):
member = models.ForeignKey(Member, related_name='memberships')
group = models.ForeignKey(Group, related_name='memberships')
level = models.FloatField(default=0.0)
class Member(models.Model):
name = models.CharField(max_length=32)
class Officer(models.Model):
member = models.ForeignKey(Member, related_name='officerships')
profile = models.ForeignKey(UserProfile)
class UserProfile(models.Model)
group = models.ForeignKey(Group)
class Group(models.Model)
pass
I think this may be a symptom of:
http://code.djangoproject.com/ticket/9188
which was fixed as of django revision 9589, I think. Now how to figure out which revision I'm working from...
Confirmed. When I implemented the change referenced in the ticket above:
http://code.djangoproject.com/changeset/9589
my error went away.