SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Using variable in SQL Insert

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Using variable in SQL Insert
Author Message
Martyn



Joined: 26 May 2004
Posts: 27

Post Using variable in SQL Insert Reply with quote

I am trying to insert a string Error message into
SQL Server but it doesn't seem to work.

blah, blah.... code

NOTIFY_ERR:
DIM sql_rows, number
DIM ERR_MSG, string
GetLastError ERR_MSG
**good here i get the error i expect**

DatabaseConnect("MyDB")
** still good **

DataseExecute(INSERT INTO JobLog VALUES(@V"job_id", ERR_MSG)", sql_rows)

** no dice, i get the following error on ERR_MSG
when trying to insert **

SQLSTATE = 37000
[Microsoft][ODBC SQL Server Driver][SQL Server]The name 'ERR_MSG' is not permitted
in this context. Only constants, expressions, or variables allowed here.
Column names are not permitted.

Question: How do I get this to recognize it as the string
error i expect, which is the error that brought me to this label
which was incorrect password (did this for testing).

Wed May 26, 2004 4:14 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: Using variable in SQL Insert Reply with quote

Here is what you need to code

//---------------------------------
Dim(my_sql, string)
ConcatEx("INSERT INTO JobLog VALUES(@V"job_id", '", ERR_MSG, "')", my_sql)
DataseExecute(my_sql, sql_rows)
//---------------------------------

: I am trying to insert a string Error message into
: SQL Server but it doesn't seem to work.

: blah, blah.... code

: NOTIFY_ERR: DIM sql_rows, number
: DIM ERR_MSG, string
: GetLastError ERR_MSG
: **good here i get the error i expect**

: DatabaseConnect("MyDB")
: ** still good **

: DataseExecute(INSERT INTO JobLog VALUES(@V"job_id", ERR_MSG)",
: sql_rows)

: ** no dice, i get the following error on ERR_MSG
: when trying to insert **

: SQLSTATE = 37000
: [Microsoft][ODBC SQL Server Driver][SQL Server]The name 'ERR_MSG' is not
: permitted
: in this context. Only constants, expressions, or variables allowed here.
: Column names are not permitted.

: Question: How do I get this to recognize it as the string
: error i expect, which is the error that brought me to this label
: which was incorrect password (did this for testing).

Wed May 26, 2004 4:42 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.