INSERT into PostGreSQL triggers "RevdbError" but no error

Pierre Sahores psahores at free.fr
Thu Sep 30 18:17:45 EDT 2010


Have an eye on this about irev <=> postgreSQL production state design skills :

> 			put "SELECT module_name,activation FROM" && CustModules && "WHERE module_name = '" & tparam1 & "'" into sqlStatement
> 			put revQueryDatabase(myDatabaseID,sqlStatement) into dbCursorID
> 			if dbCursorID is not a number 
> 			then return the result
> 			else 
> 						
> 				put revDatabaseColumnNamed(dbCursorID,"activation") into nModuleState
> 				if nModuleState is in "NY" then
> 					
> 					if nModuleState is "Y"
> 					then put "N" into nModuleState
> 					else if nModuleState is "N"
> 					then put "Y" into nModuleState
> 					put "UPDATE" && CustModules && "SET activation = '" & nModuleState & "' WHERE module_name = '" & tparam1 & "'" into sqlStatement2
> 					revExecuteSQL myDatabaseID,sqlStatement2
> 					if the result is not a number
> 					then return the result
> 					else
> 						return "MODULE_" & nModuleState & "_OK"
> 					end if
> 					
> 				else
> 					
> 					put "INSERT INTO" && CustModules && "(module_name,activation) VALUES ('" & tparam1 & "','Y')" into sqlStatement2
> 					revExecuteSQL myDatabaseID,sqlStatement2
> 					if the result is not a number
> 					then return the result # "error while submitting the INSERT statement ..."
> 					else return "MODULE_UPDATE_OK"
> 					
> 				end if
> 				
> 			end if

each "then return the result" will expose the original postgreSQL error message

HTH,

P.

Le 30 sept. 2010 à 23:54, Sivakatirswami a écrit :

> Slightly OT if this is more about PostGreSQL than LiveCodeServer
> 
> I'm doing my very first dbase insertion from an iRev form. finally getting
> a successful a connection ID after fiddling with pg_hba.conf
> 
> ASIDE: does RevServer connect on local unix domain socket or local tcp/ip
> 
> Then tried this (all copied from the rev lesson on line)
> 
> get revOpenDatabase("postgresql","localhost","useful_rodents","human","")  #no password required.
> 
> put "INSERT INTO rats-w-wings (first_name, last_name, anonymous) \
>       VALUES ('Batman', 'MosquitoEater', TRUE);" into tSQL
> 
> # we have to keep him anonymous because
> # he's embarrassed that he eats mosquitos.
> # sorry... I'm into kids' stories lately... I like to have fun the names of
> # my test objects and vars... lightens up tedious debugging
> 
>  -- query the database
> 
> put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
> 
>   -- check the result and display the data or an error message
> 
>    if item 1 of tData = "revdberr" then
>        put "There was a problem querying the database:" & cr & tData into tResponse
>    else
>        put tData into tResponse
>    end if
> 
> Now the odd part:  tData returns "revdberr,"  but no error verbiage
> 
> So I'm scratching my head... I open PhpPgAdmin and check...
> 
> Aha! Batman is there in Row 1! So, why the mysterious revdberr, from revServer?
> 
> So I log in via terminal sudo postgres and try the insertion "by hand"
> 
> useful_rodents=# INSERT INTO  rats-w-wings (first_name, last_name, anonymous)
>   VALUES ('Batman', 'MosquitoEater', TRUE);
> 
> % INSERT 0 1
> 
> useful_rodents=#  I'm back at the prompt:
> 
> Again,quick check and the insertion of the data works... Null is allowed in all fields except anonymous,
> 
> I'm a complete SQL newbie: what do the params being returned after INSERT "0 1" mean?  the "useful_rodents" table has one row successfully added and the useful_rodents_rat-w-wings_seq integer which is linked the main table primary key: rat-w-wings_id is incremented by one integer... so two things are happening on insertion. and as far as I can tell, no errors are being generated... unless one of those two mysterious results params "INSERT 0 1" are telling us something I don't understand (searching the web for the meaning of those two results integers, but not getting anything)
> 
> so, why the revdberr,  ?
> 
> Any ideas?
> 
> Thanks!
> 
> Sivakatirswami
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 

--
Pierre Sahores
mobile : (33) 6 03 95 77 70

www.woooooooords.com
www.sahores-conseil.com









More information about the Use-livecode mailing list