Hello Experts,

How can i execute a query from user defined function.

the user defined function is defined inside sqlite itself
    (in shell.c opendb function, there is user defined function shellstatic but 
it doenst query the DB)

for example:

an user defined function is intended to get the rowcount of the input table.

user can type the below command

select rowcount('employee') from sqlite_master;

the user defined function should replace rowcount('employee') with the actual 
rowcount of the employee table.

pls note that the function should be defined within sqlite only and should be 
usable from sqlite command line interface as described above.

actual code:
it fails since m unable to get call back reference from context variable and 
bcoz of that application terminates while printing the value to the o/p 
interface (user screen)

static void rowcount(
  sqlite3_context *context,
  int argc,
  sqlite3_value **argv
){
    struct callback_data *p;
    char *rowcounttest;
    rowcounttest = "SELECT 10 from sqlite_master";
    char *zErrMsg = 0;
    sqlite3 *db = sqlite3_context_db_handle(context);
    shell_exec(db, rowcounttest, shell_callback, context, &zErrMsg);
}








                        
                                
            
                    
        


        

        
            
                
                    
                        
                             
                             
                            
                            
                            
                        
                    
                
            
            
                
                    
                        
                            
                            

                            
                                
                                    
                                         
                                        
                                        
                                            
                                                
                                                    
                                                
                                                 
                                                
                                                    
                                                
                                                 
                                                 
                                                 
                                            
                                        
                                    
                                        
                                        
                                    
                                
                            
                            
                         
                    
                
            
        
            
                    
                        
                            
                            
                                
                                    
                                        
                                        
                                            
                                                
                                                
                                                    
                                                     
                                                    
                                                
                                                
                                                    
                                                     
                                                    
                                                
                                                                                
        
                                                    

                                                
                                                
                                            
                                        
                                        
                                    
                                    
                                        
                                        
                                            
                                                
                                                    
                                                        
                                                            
                                                                 
                                                                
                                                            
                                                            
                                                                 
                                                                
                                                            
                                                            
                                                                 
                                                                
                                                            
                                                            
                                                                

                                                            
                                                        
                                                    
                                                    
                                                    
                                                        
                                                            
                                                                
                                                                

                                                            
                                                            
                                                                 
                                                                
                                                            
                                                            
                                                                 
                                                                
                                                            
                                                            
                                                                 
                                                                
                                                            
                                                            
                                                                
                                                                    
                                                                

                                                                                
                                
                                                                                
                            
                                                    
                                                
                                            
                                        
                                        
                                    
                                    
                                    
                                        
                                            
                                        
                                    
                                
                            
                            
                        
                                
            
                    
        
            
                    
                        
                            
                            
                            
                        
                                
            
                    
        


                                          
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to