[Solved] Unexpected token "" requires AS in statement

Discuss the database features
Post Reply
miguelmunteanu
Posts: 5
Joined: Mon Feb 07, 2022 7:53 pm

[Solved] Unexpected token "" requires AS in statement

Post by miguelmunteanu »

Hello,

I'm learning how to use OpenOffice Base and I've stumbled upon an error.

Image
T107151.jpg
Since I've got no idea about SQL nor any database coding yet, I've created a copy, I turned it into a .zip file, went into database and found a scripts file.

The line 13 (where it's supposed to be located the error) has the following:

CREATE VIEW "PeliculasCadaGenero" ( COUNT("Pel\u00edculas"."Id_pel\u00edcula"),"Nombre") AS SELECT COUNT( "Pel\u00edculas"."Id_pel\u00edcula" ), "Generos"."Nombre" FROM "Pel\u00edculas", "Generos" WHERE "Pel\u00edculas"."Generos" = "Generos"."Id_genero" GROUP BY "Generos"."Nombre" ORDER BY "Generos"."Nombre" ASC


I hope someone can help me!

Thanks in advance.
 Edit: Attached image since the imgur·com link will eventually break and since the forum doesn't understand WEBP format for display 
-- MrProgrammer, forum moderator 
Last edited by MrProgrammer on Mon Feb 14, 2022 9:38 pm, edited 4 times in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 4.1.11 on Windows 10.
UnklDonald418
Volunteer
Posts: 1548
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Error: Unexpected token "" requires AS in statement...

Post by UnklDonald418 »

The error message is complaining about the the comma in
,"Nombre")
if "Nombre" is an alias for
COUNT("Pel\u00edculas"."Id_pel\u00edcula")
which is how the parser is trying to interpret your statement, just remove the comma or for better clarity replace it with AS
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
miguelmunteanu
Posts: 5
Joined: Mon Feb 07, 2022 7:53 pm

Re: Error: Unexpected token "" requires AS in statement...

Post by miguelmunteanu »

UnklDonald418 wrote:The error message is complaining about the the comma in
,"Nombre")
if "Nombre" is an alias for
COUNT("Pel\u00edculas"."Id_pel\u00edcula")
which is how the parser is trying to interpret your statement, just remove the comma or for better clarity replace it with AS
Hey, thanks for your answer.

Right now it's looking like this:

CREATE VIEW "PeliculasCadaGenero" ( COUNT("Pel\u00edculas"."Id_pel\u00edcula") AS "Nombre") AS SELECT COUNT( "Pel\u00edculas"."Id_pel\u00edcula" ), "Generos"."Nombre" FROM "Pel\u00edculas", "Generos" WHERE "Pel\u00edculas"."Generos" = "Generos"."Id_genero" GROUP BY "Generos"."Nombre" ORDER BY "Generos"."Nombre" ASC

Now I'm getting a different error:
Attachments
error1.PNG
error1.PNG (10.4 KiB) Viewed 2772 times
OpenOffice 4.1.11 on Windows 10.
UnklDonald418
Volunteer
Posts: 1548
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Error: Unexpected token "" requires AS in statement...

Post by UnklDonald418 »

The basic form for View creation is
CREATE VIEW "ViewName"AS some query
You have
CREATE VIEW "PeliculasCadaGenero"
The next thing should be AS
But after that you have
( COUNT("Pel\u00edculas"."Id_pel\u00edcula") AS "Nombre")
which is not a query. I'm not sure what you are attempting but perhaps you could use
SELECT ( COUNT("Pel\u00edculas"."Id_pel\u00edcula"),"Nombre") FROM some data source
Then what appears to be a valid query could be used as the data source
SELECT COUNT( "Pel\u00edculas"."Id_pel\u00edcula" ), "Generos"."Nombre" FROM "Pel\u00edculas", "Generos" WHERE "Pel\u00edculas"."Generos" = "Generos"."Id_genero" GROUP BY "Generos"."Nombre" ORDER BY "Generos"."Nombre" ASC

Get the query working first then creating the View is simple
CREATE VIEW "PeliculasCadaGenero" AS your working query
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
miguelmunteanu
Posts: 5
Joined: Mon Feb 07, 2022 7:53 pm

Re: Error: Unexpected token "" requires AS in statement...

Post by miguelmunteanu »

UnklDonald418 wrote:The basic form for View creation is
CREATE VIEW "ViewName"AS some query
You have
CREATE VIEW "PeliculasCadaGenero"
The next thing should be AS
But after that you have
( COUNT("Pel\u00edculas"."Id_pel\u00edcula") AS "Nombre")
which is not a query. I'm not sure what you are attempting but perhaps you could use
SELECT ( COUNT("Pel\u00edculas"."Id_pel\u00edcula"),"Nombre") FROM some data source
Then what appears to be a valid query could be used as the data source
SELECT COUNT( "Pel\u00edculas"."Id_pel\u00edcula" ), "Generos"."Nombre" FROM "Pel\u00edculas", "Generos" WHERE "Pel\u00edculas"."Generos" = "Generos"."Id_genero" GROUP BY "Generos"."Nombre" ORDER BY "Generos"."Nombre" ASC

Get the query working first then creating the View is simple
CREATE VIEW "PeliculasCadaGenero" AS your working query
Hey, thanks again for your answer.

The problem is that I've got no idea about coding. I got this error by simply ussing OpenOffice Base, without any sort of coding. So I don't really feel familiar with anything that you're mentioning.
OpenOffice 4.1.11 on Windows 10.
UnklDonald418
Volunteer
Posts: 1548
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Error: Unexpected token "" requires AS in statement...

Post by UnklDonald418 »

What are you actually trying to accomplish with this View?

We're doing a lot of guessing, so if you could upload a sample database with your tables and a few records we might be able to give more specific help.
[Forum] How to attach a document here
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
miguelmunteanu
Posts: 5
Joined: Mon Feb 07, 2022 7:53 pm

Re: Error: Unexpected token "" requires AS in statement...

Post by miguelmunteanu »

UnklDonald418 wrote:What are you actually trying to accomplish with this View?

We're doing a lot of guessing, so if you could upload a sample database with your tables and a few records we might be able to give more specific help.
[Forum] How to attach a document here
The only thing I want to accomplish is to solve the error I'm getting. I'll attach my database in this message.

When you enter the database and you try to select the Tables section on the left, you get the error that I mentioned at the beggining of the post.


Cheers.
Attachments
myDataBase_exercise.odb
(62.05 KiB) Downloaded 129 times
OpenOffice 4.1.11 on Windows 10.
User avatar
Sliderule
Volunteer
Posts: 1279
Joined: Thu Nov 29, 2007 9:46 am

Re: Error: Unexpected token "" requires AS in statement...

Post by Sliderule »

Find as an attachment a working version of your database myDataBase_exercise.odb.

I modified the View "PeliculasCadaGenero" to give it a column name "Cantidad" for the first column calculated.
myDataBase_exercise.odb
(61.94 KiB) Downloaded 105 times
I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.
miguelmunteanu
Posts: 5
Joined: Mon Feb 07, 2022 7:53 pm

Re: Error: Unexpected token "" requires AS in statement...

Post by miguelmunteanu »

Sliderule wrote:Find as an attachment a working version of your database myDataBase_exercise.odb.

I modified the View "PeliculasCadaGenero" to give it a column name "Cantidad" for the first column calculated.
myDataBase_exercise.odb
I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your 1st post Subject (edit button top right) if this issue has been resolved.

Thanks a lot mate! You solved it! :D
OpenOffice 4.1.11 on Windows 10.
Post Reply