SQL Script Problems

smoochy boys on tour

Geordiehc

Mad Dog Geo
VIP
Jul 4, 2007
2,827
49
195
Redditch, UK
Ive been trying to learn to SQL manip but iv come to a dead end, can anyone tell me where iv gone wrong please.
Iv tried adding 1 field at a time and it all goes well until i get more in depth and then it jsut falls apart. this is my CD error

17:49:29:Exception) FormatStr '%s',%s,%s,%s Geo 0 0,(WizzardArts)_Merlin,TaoistTemple\WizzBook
17:49:29:Exception) TFrmSql.WriteSqlValue -> ExecSQL 2
17:49:29: :insert into Mainquest (Name,QuestLevel,Qsect,Qgold) Values(Name='Geo')


Code:
[@main]
#SAY
<Quest/@qqq>\\

[@qqq]
#ACT
    FormatStr "Name='%s'" %USERNAME 
  ReadValueSql  "Mainquest"  %A9  "Name,QuestLevel,Qsect,Qgold" [@precheck1]   
 
;We use %A9 as this is a temp variable stored and created by Mir3 from the previous FormatStr, in other words, %A9 = FLD_NOTHING1='%GUILDNAME'
;Now this line will try to read your guildname in TBL_NOTHING, and look up the name, and the amount of gold your guild has. 
 
[@precheck1()]
#ACT
    Mov   A3      %ARG(1)     ;Retrieve Username and stores into A3
    Mov   D1      %ARG(2)    ;Retrieves section and stores into D1 variable 1levrl
    Mov   D2      %ARG(3) ;qsect
    Mov   D3      %ARG(4) ;qgold
goto @menu2
#IF
   Equal  A3   ""     ;If there is no guild listed under this name it makes an entry below
#ACT
    FormatStr "'%s',%s,%s,%s" %USERNAME 0 0, 0      ;We format your guildname and add in 0 gold to the string
    Mov A8 %A9          ;Move the temporarily generated mir3 variable into a permanent one
    FormatStr "Name='%s'" %USERNAME          ;Format your guildname to do a search for the guild in the field
    Mov A2 %A9          ;Move the results into a permanent A2 variable
    WriteValueSql "Mainquest" %A2 "Name,QuestLevel,Qsect,Qgold" %A8    ;So we add in a new entry to the table, that includes your guildname and the amount 0 gold
    goto @menu2
#ELSEACT
goto @menu2
 

Yolom

LOMCN Veteran
Veteran
Aug 7, 2010
325
21
45
Spain
All is correct, but are missing TBL_ and FLD_

Try this, and tell me.

Code:
[@main]
#SAY
<Quest/@qqq>\\

[@qqq]
#ACT
    FormatStr "[COLOR="#006400"]FLD_[/COLOR]Name='%s'" %USERNAME 
  ReadValueSql  "[COLOR="#006400"]TBL_[/COLOR]Mainquest"  %A9  "[COLOR="#006400"]FLD_[/COLOR]Name,[COLOR="#006400"]FLD_[/COLOR]QuestLevel,[COLOR="#006400"]FLD_[/COLOR]Qsect,[COLOR="#006400"]FLD_[/COLOR]Qgold" [@precheck1]   
 
;We use %A9 as this is a temp variable stored and created by Mir3 from the previous FormatStr, in other ;words, %A9 = FLD_NOTHING1='%GUILDNAME'
;Now this line will try to read your guildname in TBL_NOTHING, and look up the name, and the amount of ;gold your guild has. 
 
[@precheck1()]
#ACT
    Mov   A3      %ARG(1)     ;Retrieve Username and stores into A3
    Mov   D1      %ARG(2)    ;Retrieves section and stores into D1 variable 1levrl
    Mov   D2      %ARG(3) ;qsect
    Mov   D3      %ARG(4) ;qgold
goto @menu2
#IF
   Equal  A3   ""     ;If there is no guild listed under this name it makes an entry below
#ACT
    FormatStr "'%s',%s" %USERNAME 0   
    Mov A8 %A9         
    FormatStr "[COLOR="#006400"]FLD_[/COLOR]Name='%s'" %USERNAME       
    Mov A2 %A9          
    WriteValueSql "TBL_Mainquest" %A2 "FLD_Name,FLD_QuestLevel,FLD_Qsect,FLD_Qgold" %A8    ;So we add in a new entry to the table, that includes your guildname and the amount 0 gold
    goto @menu2
#ELSEACT
goto @menu2

Hope it works.

If you have more questions, feel free to ask me anything, I can help with SQL whatever.


Regards
 
Last edited:
Upvote 0

Geordiehc

Mad Dog Geo
VIP
Jul 4, 2007
2,827
49
195
Redditch, UK
kk ty and so do i, but i always dodged learning SQL lol

---------- Post added 25-02-2012 at 05:15 PM ---------- Previous post was 22-02-2012 at 10:27 PM ----------

since an argument can only hold 3 entries, whats the best way to add multiple entries, like my new script i have 8 fields, how would i set them all as 0 in a minimal script
 
Upvote 0

Tai

HEAD CAPTAIN
Staff member
Administrator
May 11, 2003
14,280
2
2,645
515
United Kingdom
kk ty and so do i, but i always dodged learning SQL lol

---------- Post added 25-02-2012 at 05:15 PM ---------- Previous post was 22-02-2012 at 10:27 PM ----------

since an argument can only hold 3 entries, whats the best way to add multiple entries, like my new script i have 8 fields, how would i set them all as 0 in a minimal script

Lol ?
 
Upvote 0

Tai

HEAD CAPTAIN
Staff member
Administrator
May 11, 2003
14,280
2
2,645
515
United Kingdom
no... scripting is very different/more logical in mir2. And it doesn't make sense because.... I don't see how it relates to the definition of the word...
 
Upvote 0