Dynamic SQL Error SQL error code = -104 Token unknown in procedure #2

Hi all,
I'm a newbie.

I test my procedure in SQL interactive  but got error:
--------------------------------------------------------
Error at line 1
Dynamic SQL Error
SQL error code = -104
Token unknown - line 5, char 3
:
SQL - CREATE PROCEDURE CreateNewSystem(NewSystemID VarChar(10), CurrentSelection Int, NewSystemName VarChar(20), CheckChild Boolean)
AS
DECLARE VARIABLE LeftRightValue INTEGER;
begin
	IF :CheckChild THEN
		SELECT LeftRightValue = lft FROM "MEP_SYSTEMS"
			WHERE category_id=:CurrentSelection;
	ELSE
		SELECT LeftRightValue = rgt FROM "MEP_SYSTEMS"
			WHERE category_id=:CurrentSelection;
	UPDATE "MEP_SYSTEM" SET rgt = rgt + 2 WHERE rgt > LeftRightValue;
	UPDATE "MEP_SYSTEM" SET lft = lft + 2 WHERE lft > LeftRightValue;
	INSERT INTO "MEP_SYSTEM"(system_id,system_name, lft, rgt)
                       VALUES(:NewSystemID,:NewSystemName, LeftRightValue + 1, LeftRightValue + 2);
end ^
--------------------------------------------------------
I try change the name (CheckChild --> Child), the error still same, put ":CheckChild" in paratheses (), the error still the same.

What is wrong? Please help
0
Nguyen
6/16/2013 1:25:21 PM
embarcadero.delphi.interbase 331 articles. 1 followers. Follow

5 Replies
5283 Views

Similar Articles

[PageSpeed] 10

Nguyen Van Khanh wrote:
> Hi all,
> I'm a newbie.
> 
> I test my procedure in SQL interactive  but got error:
> --------------------------------------------------------
> Error at line 1
> Dynamic SQL Error
> SQL error code = -104
> Token unknown - line 5, char 3
> :
> SQL - CREATE PROCEDURE CreateNewSystem(NewSystemID VarChar(10), CurrentSelection Int, NewSystemName VarChar(20), CheckChild Boolean)
> AS
> DECLARE VARIABLE LeftRightValue INTEGER;
> begin
> 	IF :CheckChild THEN
> 		SELECT LeftRightValue = lft FROM "MEP_SYSTEMS"
> 			WHERE category_id=:CurrentSelection;
> 	ELSE
> 		SELECT LeftRightValue = rgt FROM "MEP_SYSTEMS"
> 			WHERE category_id=:CurrentSelection;
> 	UPDATE "MEP_SYSTEM" SET rgt = rgt + 2 WHERE rgt > LeftRightValue;
> 	UPDATE "MEP_SYSTEM" SET lft = lft + 2 WHERE lft > LeftRightValue;
> 	INSERT INTO "MEP_SYSTEM"(system_id,system_name, lft, rgt)
>                        VALUES(:NewSystemID,:NewSystemName, LeftRightValue + 1, LeftRightValue + 2);
> end ^
> --------------------------------------------------------
> I try change the name (CheckChild --> Child), the error still same, put ":CheckChild" in paratheses (), the error still the same.
> 
> What is wrong? Please help

In InterBase If Then statements the conditional must be in ().  I also think it 
might be expecting a conditional expression, so try


IF (:CheckChild = true) THEN

-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
And so I patrol in the valley of the shadow of the tricolor
I must fear evil. For I am but mortal and mortals can only die.
Asking questions, pleading answers from the nameless
faceless watchers that stalk the carpeted  corridors of Whitehall.
              (Fish)
0
Jeff
6/17/2013 3:58:09 AM
"Nguyen Van Khanh" wrote in message news:588058@forums.embarcadero.com...
>
> I test my procedure in SQL interactive  but got error:
> --------------------------------------------------------
> Error at line 1
> Dynamic SQL Error
> SQL error code = -104
> Token unknown - line 5, char 3
> :
> SQL - CREATE PROCEDURE CreateNewSystem(NewSystemID VarChar(10), 
> CurrentSelection Int, NewSystemName VarChar(20), CheckChild Boolean)
> AS
> DECLARE VARIABLE LeftRightValue INTEGER;
> begin
> IF :CheckChild THEN

Need parenthesis in IF statements ...

 IF (:CheckChild) THEN

> SELECT LeftRightValue = lft FROM "MEP_SYSTEMS"
> WHERE category_id=:CurrentSelection;
> ELSE
> SELECT LeftRightValue = rgt FROM "MEP_SYSTEMS"
> WHERE category_id=:CurrentSelection;

You must select INTO...
 SELECT lft FROM "MEP_SYSTEMS"
 WHERE category_id=:CurrentSelection
 INTO :LeftRightValue;

An important question for the above query: is the CurrentSelection field 
unique in the table? If not then this is no good. You must either make sure 
the query only returns a single row, or else handle it with a FOR SELECT 
loop.

> UPDATE "MEP_SYSTEM" SET rgt = rgt + 2 WHERE rgt > LeftRightValue;
> UPDATE "MEP_SYSTEM" SET lft = lft + 2 WHERE lft > LeftRightValue;
> INSERT INTO "MEP_SYSTEM"(system_id,system_name, lft, rgt)
>                       VALUES(:NewSystemID,:NewSystemName, LeftRightValue + 
> 1, LeftRightValue + 2);

The above require the colons on the local variable...
 UPDATE "MEP_SYSTEM" SET rgt = rgt + 2 WHERE rgt > :LeftRightValue;
 UPDATE "MEP_SYSTEM" SET lft = lft + 2 WHERE lft > :LeftRightValue;
 INSERT INTO "MEP_SYSTEM"(system_id,system_name, lft, rgt)
    VALUES(:NewSystemID,:NewSystemName, :LeftRightValue + 1, :LeftRightValue 
+ 2);


-- 
Wayne Niddery (TeamB)
"You know what they call alternative medicine that has been proven to work? 
Medicine." - Tim Minchin
0
Wayne
6/17/2013 4:04:10 AM
Hi Wayne Niddery,
thanks for your advices. However, the problem still same. Below is the error message. Even such error message, maybe another hidden cause but I don't know?


Error at line 2
Dynamic SQL Error
SQL error code = -104
Token unknown - line 5, char 15
)
SQL - CREATE PROCEDURE CreateNewSystem(NewSystemID VarChar(10), CurrentSelection Int, NewSystemName VarChar(20), CheckChild Boolean)
AS
DECLARE VARIABLE LeftRightValue INTEGER;
begin
	IF (:CheckChild) THEN
		SELECT lft FROM "MEP_SYSTEMS"
			WHERE category_id=:CurrentSelection
			INTO :LeftRightValue;
	ELSE
		SELECT rgt FROM "MEP_SYSTEMS"
			WHERE category_id=:CurrentSelection;
			INTO :LeftRightValue;
	UPDATE "MEP_SYSTEM" SET rgt = rgt + 2 WHERE rgt > :LeftRightValue;
	UPDATE "MEP_SYSTEM" SET lft = lft + 2 WHERE lft > :LeftRightValue;
	INSERT INTO "MEP_SYSTEM"(system_id,system_name, lft, rgt)
                       VALUES(:NewSystemID,:NewSystemName, :LeftRightValue + 1, :LeftRightValue + 2);
end ^
0
Nguyen
6/17/2013 1:41:48 PM
"Nguyen Van Khanh" wrote in message news:588241@forums.embarcadero.com...
> thanks for your advices. However, the problem still same. Below is the 
> error message. Even such error message, maybe another hidden cause but I 
> don't know?


See Jeff's reply, I think that probably covers it.

-- 
Wayne Niddery (TeamB)
"You know what they call alternative medicine that has been proven to work? 
Medicine." - Tim Minchin
0
Wayne
6/17/2013 3:07:51 PM
Hi all,
thanks for your reply.
I found the problem.

local variable using: 
- read: without colones (:)
- write: prefix by colones (:).

And I rewrote my procedure as below, and it's ok:

CREATE PROCEDURE CreateNewSystem(NewSystemID VarChar(10), CurrentSelection Int, NewSystemName VarChar(20), CheckChild Boolean)
AS
DECLARE VARIABLE LeftRightValue INTEGER;
begin
	IF (CheckChild=TRUE) THEN
		SELECT lft FROM "MEP_SYSTEMS"
			WHERE category_id=:CurrentSelection
			INTO :LeftRightValue;
	ELSE
		SELECT rgt FROM "MEP_SYSTEMS"
			WHERE category_id=:CurrentSelection
			INTO :LeftRightValue;
	UPDATE "MEP_SYSTEMS" SET rgt = rgt + 2 WHERE rgt > :LeftRightValue;
	UPDATE "MEP_SYSTEMS" SET lft = lft + 2 WHERE lft > :LeftRightValue;
	INSERT INTO "MEP_SYSTEMS"(system_id,system_name, lft, rgt)
                       VALUES(:NewSystemID,:NewSystemName, :LeftRightValue + 1, :LeftRightValue + 2);
end
0
Nguyen
6/18/2013 2:34:49 AM
Reply:

Similar Artilces:

CIFs Error: Storage Error Unknown error with error code: -602
Server was an Identity Migration target (source single server tree nw6sp5/edir8737/gw8hp1 to oes2sp1x64+latest patches), but I have been having problems with getting cifs to work since the migration. Whenever I go into iManager, file protocols, cifs & try to make any change other than stopping/starting the service I get the error in the subject (even to change something simple like the comment). Other oddities I noticed since the actual IM swap that somehow might have something to do with this: users arent LUM enabled or so it seems the afpProxyUser- & cifsProxyUser- both...

SQL syntax error using dynamic SQL
I have below code:    set @SQL='(select top 1 @idOUT = id from prospects where result=0' + @SQL_excludeprospects + ' order by id ASC)'    print @SQL    SET @ParmDefinition = N'@idOUT int OUTPUT';    EXECUTE sp_executesql @SQL, @ParmDefinition, @idOUT=@id OUTPUT;    SELECT @id; I get this output:(select top 1 @idOUT = id from prospects where result=0 AND id<>2 AND id<>6 AND id<>9 order by id ASC)Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'order'.I do...

Clustering error
To whom it may concern We are using SLES SP1- OES2.We have 4 cluster nodes and 8 existing cluster resources. When we want to create a new cluster resource, we follow the following under mentioned steps. > Select cluster Options > Select new resource > resource > next > add new cluster resource name > inherit frame template - select template Generic IP > Define additional properties > next - load script > next - unload script > next - monitor script > next - resource policies > resource preferred nodes > finish Then it shows the foll...

SQL statement failed: (-305) I/O error Fatal error: A disk read from file "SomeDatabase.db" failed with error code: (38)
SQL Anywhere 10.0.1.3831 E. 2009-09-11 21:55:41. SQL statement failed: (-305) I/O error Fatal error: A disk read from file "D:\FHMSL\iFHMS\Data\Feedlot111.db" failed with error code: (38) -- transaction rolled back E. 2009-09-11 21:55:41. Error while executing hook procedure sp_hook_dbmlsync_end. Received this error while running a proc during sync. Tried to validate the db in Sybase Central resulting in the same error. I saw the post at http://groups.google.com/group/sybase.public.sqlanywhere.general/browse_thread/thread/b5d958904160e576?fwc=1 and am wondering if th...

Capturing SQL error codes in Delphi
Anyone know if it is possible to get the SQLERROR or SQLSTATE codes back in Delphi? After an error, you can issue the following queries. select SQLCODE or select SQLSTATE Chris Dean Wooldridge wrote: > Anyone know if it is possible to get the SQLERROR or SQLSTATE codes back in > Delphi? >Anyone know if it is possible to get the SQLERROR or SQLSTATE codes back in >Delphi? There may be more direct ways, but you could always SELECT SQLSTATE INTO somevariable; But keep in mind that this must be the first statement following the failure, as ...

sql stored procedure ( code error )
hello guys.....I am new to writing stored procedures and pretty weak in sql , but I am writing this sql sp and it gives me error ( near as , near if ) please if someone can make it correct for me I'd be really helpful , what am trying to do is 3 types of searching , by uploadername , by id , by name ...search by id is a bit complicated , that when someone enters the id , it'll show the file related to that id , plus all files who has higher id number , and has the same uploaderCREATE PROCEDURE display_results @Name varchar(120),@Uploader varchar(50), @ID int, AS IF ( @ID != NU...

ASA Error -300: Run time SQL error #2
When I right click on a specific table and select Validate I get the following error: com.sybase.jdbc2.jdbc.SybSQLException: ASA Error -300: Run time SQL error -- Primary key for "PRS_VRT" has missing index entries at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2538) at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1922) at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69) at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:201) at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:182) at com.sybase.jdbc2.jdbc.SybSt...

PB Runtime error
I have an PB 7 application, build 8033, where when we run it in the development enviroment it runs fine, but when we try to do an Query by Example with the executable, the application fails with this error. We are using informix 7.03 as our database. Any ideas? Thanks George We tried this on a couple of other non powebuilder development machines, and the application runs fine. It appears either to be an invalid .dll on that machine or an issue with Citrix and PB702. Anyone else using PB702 and Citrix? THanks George Can you get the SQL-Syntax? geocal99@ya...

iManager error with Error: NMAS LDAP Transport Error javax.naming.CommunicationException: [LDAP: error code 2
I have a problem exactly as related in tid (3947462), but the fix that I tried as posted in the TID did not do anything to rectify the problem. My server shows only 6 nmasldap before and after performing nmasinstall. This is a netware 6.5 server with service pack 5. No additional configuration changes or service packs were installed on the server since the last time this part of the functionality worked. The document says that there are 2 possible causes. The second cause, I don't beleive applies as there is only 1 netware server. I ran both the nmasinstall command on a wi...

DW, SQL Code 2, Select error:
We use Sybase 11 in NT 4.0 Server and Powerbuilder 6.5 for application design. This case happened when I upload certain amount of data (2000+ records) into a table and then try to use the data window to view the data, the following message appear: SQL Code 2 encountered Select error: I made sure the following things: 1. I only use one table without any link 2. The table contains no foriegn key 3. The data is imported from a text file (no header), when I use powerbuilder 6.5 to view the table directly, there is no error message occure, and the data seems alright. 4. The da...

Error, Error and more errors
Okay, all I wanted to do was test this app out and it has been a nightmare. 1.) Didn't install the sql database. I had to manually install it. 2.) I get errors when trying to add a picture to an album. "Procedure or function ngUpdatePicture has too many arguments specified" Any ideas? I've gotten more errors than this, but there is no use in bitchin. Are you using the v1.6.1 installer? Also, did you select to install the SQL Server db and give it a valid admin login? What were some of the error messages? Did you have an existing DB from a previous install? ...

error error error
These are the 2 new errors i am getting now:   1).  Server Error in '/' Application. Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.Source Error: Line 53: ...

errors errors errors..
Name: harun Email: harunbjk1903hrnatgmaildotcom Product: Firefox Summary: errors errors errors.. Comments: first of all when i launch firefox (3) i cant enter websites via writing.. for example when I type "google" and then press ctrl and enter, it crashes.. and i take lots of error reports. firefox 2 was better.. see you again , harun Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.9) Gecko/2008052906 Firefox/3.0 From URL: http://hendrix.mozilla.org/ ...

SQl Server Error: ----> Named Pipes Provider, error: 40
  Hi Friends, Im using .Net2008 and MS SQL Server2005, I Have a web application , i want to connect to the server machine SQL Server,  When i run the application im getting the following error. Im trying to connect to the database from local machine application to server machine database   An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Cou...

SQL Network Interfaces, error: 26
 I am getting this errorSQL Network Interfaces, error: 26 - Error Locating Server/Instance Specifiedaparently there is something wrong with my db connection.So what happened. I was using sql 2005 and decided mid way into my project to upgrade to 2008...stupid me!None the less after many hours my site is semi operational again. Here is the wierd thing.The first page in my site is a login page that opens a DB connection and queries the db for login verification. Works fine! Other pages that access the DB work fine too, however some pages spit out the error above. Anyone know how...

Web resources about - Dynamic SQL Error SQL error code = -104 Token unknown in procedure #2 - embarcadero.delphi.interbase

Invasiveness of surgical procedures - Wikipedia, the free encyclopedia
There are three main categories which describe the invasiveness of surgical procedures . These are: non-invasive procedures , minimally invasive ...

Procedure is more a snap than a snip
A QUEENSLAND doctor is bidding to set an unusual world record by performing the highest number of vasectomies in one day, with the help of fellow ...

Rushed cosmetic procedures a 'recipe for disaster'
&#8203;When Chanelle O'Hare went searching online for a deal on potential cosmetic procedures, she could not have imagined that what she ended ...

Jetstar procedures under investigation after planes took off too heavy
Jetstar's procedures for calculating the weight of its aircraft are under review by the Australian Transport Safety Bureau after two of its planes ...

Old Lady Lawyer: Uncivil Procedure
What is some of the worst behavior you've witnesses by attorneys?

NFL Announces Changes to Officiating Procedures for Playoffs - Bleacher Report
The NFL formally approved changes to its postseason officiating procedures to allow referees the opportunity to consult Vice President of Officiating ...

Will Paul Ryan Make His Mark As Speaker By Instituting Impeachment Procedures Against President Obama ...
Wisconsin Ayn Rand devotee Paul Ryan just started his new job as Speaker of the dysfunctional House Republicans. And he's already headed for ...

TSA Updates Screening Procedure, Will Mandate Some Passengers Use Full-Body Scanners
... Imaging Technologies, or AIT, in favor of full-body pat-downs by TSA agents. Under the new mandate, not everyone can opt for the pat-down procedure. ...

'Painless' dental cavity procedure regrows tooth enamel
... "cavity" a lot of people sweat thinking about painful injections and relentless drilling. But scientists in Britain have developed a new procedure ...

Why Are Web Login Security Procedures So #$*&!% Dumb And Obnoxious?
The geeks who design our websites talk a lot about user friendliness, but they often let an exaggerated security concerns get in the way of commonsense. ...

Resources last updated: 12/29/2015 12:13:02 AM